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

Method execute

internagent/mas/agents/scholar_agent.py:68–140  ·  view source on GitHub ↗

Gather external evidence for a research hypothesis. Args: context: Dictionary containing: - goal: Research goal information - hypothesis: The hypothesis to gather evidence for - iteration: Current iteration number

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

Source from the content-addressed store, hash-verified

66 logger.warning(f"Failed to initialize literature search: {str(e)}")
67
68 async def execute(self, context: Dict[str, Any], params: Dict[str, Any]) -> Dict[str, Any]:
69 """
70 Gather external evidence for a research hypothesis.
71
72 Args:
73 context: Dictionary containing:
74 - goal: Research goal information
75 - hypothesis: The hypothesis to gather evidence for
76 - iteration: Current iteration number
77 params: Dictionary containing optional configuration overrides
78
79 Returns:
80 Dictionary containing:
81 - evidence: List of evidence items
82 - references: List of references
83 - relevance_summary: Summary of relevance to hypothesis
84 """
85 # Extract parameters
86 goal = context.get("goal", {})
87 hypothesis = context.get("hypothesis", {})
88 # feedback = context.get("feedback", [])
89 feedback = []
90
91 if not goal or not hypothesis:
92 raise AgentExecutionError("Research goal and hypothesis are required for scholar search")
93
94 # Extract text from hypothesis
95 hypothesis_text = hypothesis.get("text", "")
96 if not hypothesis_text:
97 raise AgentExecutionError("Hypothesis text is required for scholar search")
98
99 # Extract optional parameters
100 iteration = context.get("iteration", 0)
101 max_papers = params.get("max_papers", self.max_papers)
102 search_depth = params.get("search_depth", self.search_depth)
103 method_phase = params.get("method_phase", False)
104
105 # Prepare search queries
106 search_queries = await self._generate_search_queries(
107 goal=goal,
108 hypothesis=hypothesis,
109 search_depth=search_depth,
110 feedback=feedback
111 )
112
113 # Gather evidence from literature
114 evidence, references = await self._gather_literature_evidence(
115 search_queries=search_queries,
116 hypothesis=hypothesis,
117 max_papers=max_papers,
118 method_phase=method_phase
119 )
120
121 # Generate relevance summary
122 relevance_summary = await self._generate_relevance_summary(
123 hypothesis=hypothesis,
124 evidence=evidence
125 )

Callers

nothing calls this directly

Calls 5

AgentExecutionErrorClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected