MCPcopy
hub / github.com/IBM/AssetOpsBench / run

Method run

src/agent/stirrup_agent/runner.py:144–183  ·  view source on GitHub ↗
(self, question: str)

Source from the content-addressed store, hash-verified

142 # -- run ---------------------------------------------------------------
143
144 async def run(self, question: str) -> AgentResult:
145 from stirrup import Agent
146
147 with agent_run_span(
148 "stirrup-agent", model=self._model_id, question=question
149 ) as span:
150 run_started = time.perf_counter()
151 started_at = _dt.datetime.now(_dt.UTC).isoformat()
152
153 agent = Agent(
154 client=self._build_client(),
155 name="assetops",
156 system_prompt=AGENT_SYSTEM_PROMPT,
157 tools=self._build_tools(),
158 max_turns=self._max_turns,
159 )
160
161 _log.info(
162 "StirrupAgentRunner: starting (model=%s, code=%s, backend=%s)",
163 self._model_id,
164 self._code_enabled,
165 self._code_backend,
166 )
167
168 async with agent.session() as session:
169 finish_params, history, _metadata = await session.run(question)
170
171 trajectory = build_trajectory(history)
172 trajectory.started_at = started_at
173 answer = final_answer(history, finish_params)
174
175 self._annotate_span(span, trajectory, answer, run_started)
176 persist_trajectory(
177 runner_name="stirrup-agent",
178 model=self._model_id,
179 question=question,
180 answer=answer,
181 trajectory=trajectory,
182 )
183 return AgentResult(question=question, answer=answer, trajectory=trajectory)
184
185 def _annotate_span(
186 self, span, trajectory: Trajectory, answer: str, started: float

Callers 1

_runFunction · 0.95

Calls 8

_build_clientMethod · 0.95
_build_toolsMethod · 0.95
_annotate_spanMethod · 0.95
agent_run_spanFunction · 0.90
persist_trajectoryFunction · 0.90
build_trajectoryFunction · 0.85
final_answerFunction · 0.85
AgentResultClass · 0.85

Tested by

no test coverage detected