MCPcopy Create free account
hub / github.com/InternScience/InternAgent / execute

Method execute

internagent/mas/agents/dr_agent.py:142–189  ·  view source on GitHub ↗

Execute discovery research task using the DR workflow. Args: context: Dictionary containing: - task: The research task description - file_path: Optional file path for additional context - goal: Research goal inform

(self, context: Dict[str, Any], params: Dict[str, Any])

Source from the content-addressed store, hash-verified

140 return workflow_config
141
142 async def execute(self, context: Dict[str, Any], params: Dict[str, Any]) -> Dict[str, Any]:
143 """
144 Execute discovery research task using the DR workflow.
145
146 Args:
147 context: Dictionary containing:
148 - task: The research task description
149 - file_path: Optional file path for additional context
150 - goal: Research goal information (optional)
151 - iteration: Current iteration number (optional)
152 params: Dictionary containing optional configuration overrides
153
154 Returns:
155 The workflow execution result (format depends on the workflow)
156 """
157 # Extract task information from context
158 task = context.get("task", "")
159 if not task:
160 # Try alternative keys
161 task = context.get("description", "") or context.get("goal", {}).get("description", "")
162
163 if not task:
164 raise AgentExecutionError("Task description is required for DR agent execution")
165
166 # Extract optional file path
167 file_path = context.get("file_path", None)
168
169 # Check if workflow is initialized
170 if self.workflow is None:
171 logger.error("DR workflow is not initialized - cannot execute task")
172 # Return a simple fallback response
173 return f"Background research needed for: {task}\n\nNote: DR workflow is not available. Please provide background context manually."
174
175 try:
176 logger.info(f"DR Agent executing task: {task}")
177
178 # Execute the DR workflow
179 result = self.workflow.execute(task=task, file_path=file_path)
180
181 logger.info("DR workflow execution completed successfully")
182
183 # Return the result directly (user has modified return format)
184 return result
185
186 except Exception as e:
187 logger.error(f"Error during DR workflow execution: {str(e)}")
188 # Return a fallback response instead of raising error
189 return f"Background research for: {task}\n\nNote: DR workflow execution failed. Please provide background context manually."
190

Callers 12

mainFunction · 0.95
create_sessionMethod · 0.45
_run_generation_phaseMethod · 0.45
reflect_one_ideaMethod · 0.45
evolve_one_ideaMethod · 0.45
_run_ranking_phaseMethod · 0.45
develop_methodMethod · 0.45
refine_ideaMethod · 0.45
gather_evidenceMethod · 0.45

Calls 2

AgentExecutionErrorClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected