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

Method execute

internagent/mas/agents/evolution_agent.py:326–505  ·  view source on GitHub ↗

Evolve hypothesis by addressing critiques and incorporating feedback. Generates improved hypothesis versions that systematically address identified weaknesses while preserving core strengths. Incorporates evidence and feedback to produce scientifically stronger, mor

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

Source from the content-addressed store, hash-verified

324 return []
325
326 async def execute(self, context: Dict[str, Any], params: Dict[str, Any]) -> Dict[str, Any]:
327 """
328 Evolve hypothesis by addressing critiques and incorporating feedback.
329
330 Generates improved hypothesis versions that systematically address identified
331 weaknesses while preserving core strengths. Incorporates evidence and feedback
332 to produce scientifically stronger, more testable hypotheses. Documents specific
333 improvements and changes made during evolution.
334
335 Args:
336 context (Dict[str, Any]): Execution context with keys:
337 - goal (Dict): Research goal and constraints
338 - hypothesis (Dict): Hypothesis to evolve with text/rationale
339 - critiques (List[Dict]): Identified weaknesses to address
340 - evidence (List[Dict]): Supporting evidence (optional)
341 - feedback (List[Dict]): Scientist feedback (optional)
342 - iteration (int): Current iteration number
343 params (Dict[str, Any]): Runtime parameters:
344 - evolution_count (int): Override evolution count (optional)
345
346 Returns:
347 Dict[str, Any]: Evolution results containing:
348 - evolved_hypotheses (List[Dict]): Improved versions with text/rationale/improvements
349 - reasoning (str): Evolution strategy explanation
350 - changes (List[Dict]): Documented changes by type
351 - metadata (Dict): Evolution context
352
353 Raises:
354 AgentExecutionError: If goal/hypothesis missing or evolution fails
355 """
356 # Extract parameters
357 goal = context.get("goal", {})
358 hypothesis = context.get("hypothesis", {})
359 critiques = context.get("critiques", [])
360 evidence = context.get("evidence", [])
361 feedback = context.get("feedback", [])
362
363 if not goal or not hypothesis:
364 raise AgentExecutionError("Research goal and hypothesis are required for evolution")
365
366 # Extract text from hypothesis
367 hypothesis_text = hypothesis.get("text", "")
368 if not hypothesis_text:
369 raise AgentExecutionError("Hypothesis text is required for evolution")
370
371 # Extract optional parameters
372 iteration = context.get("iteration", 0)
373 evolution_count = params.get("evolution_count", self.evolution_count)
374
375 # Initialize memory retriever if enabled and not yet initialized
376 if self.use_memory and context.get("task_name") and not self.memory_retriever:
377 from ..tools.memory_retrieval import TaskMemoryRetriever
378 self.memory_retriever = TaskMemoryRetriever(
379 task_name=context.get("task_name"),
380 memory_dir=self.memory_dir,
381 top_k=self.memory_top_k,
382 alpha=self.memory_alpha,
383 include_details=self.memory_include_details,

Callers

nothing calls this directly

Calls 7

_build_system_promptMethod · 0.95
AgentExecutionErrorClass · 0.85
TaskMemoryRetrieverClass · 0.85
_call_modelMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected