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

Function _run

src/agent/cli.py:79–140  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

77
78
79async def _run(args: argparse.Namespace) -> None:
80 from agent.plan_execute.runner import PlanExecuteRunner
81
82 llm = _build_llm(args.model_id)
83 runner = PlanExecuteRunner(llm=llm)
84 result = await runner.run(args.question)
85
86 if args.output_json:
87 output = {
88 "question": result.question,
89 "answer": result.answer,
90 "plan": [
91 {
92 "step": s.step_number,
93 "task": s.task,
94 "server": s.server,
95 "tool": s.tool,
96 "tool_args": s.tool_args,
97 "dependencies": s.dependencies,
98 "expected_output": s.expected_output,
99 }
100 for s in result.plan.steps
101 ],
102 "trajectory": [
103 {
104 "step": r.step_number,
105 "task": r.task,
106 "server": r.server,
107 "tool": r.tool,
108 "tool_args": r.tool_args,
109 "response": r.response,
110 "error": r.error,
111 "success": r.success,
112 }
113 for r in result.trajectory
114 ],
115 }
116 print(json.dumps(output, indent=2))
117 return
118
119 if args.show_plan:
120 _print_section("Plan")
121 for step in result.plan.steps:
122 deps = ", ".join(f"#{d}" for d in step.dependencies) or "none"
123 print(f" [{step.step_number}] {step.server}: {step.task}")
124 print(f" tool: {step.tool} args: {step.tool_args}")
125 print(f" deps={deps} | expected: {step.expected_output}")
126
127 if args.show_trajectory:
128 _print_section("Trajectory")
129 for r in result.trajectory:
130 status = "OK " if r.success else "ERR"
131 print(f" [{status}] Step {r.step_number} ({r.server}): {r.task}")
132 if r.tool and r.tool.lower() not in ("none", "null", ""):
133 print(f" tool: {r.tool} args: {r.tool_args}")
134 detail = r.response if r.success else f"Error: {r.error}"
135 snippet = detail[:200] + ("..." if len(detail) > 200 else "")
136 print(f" {snippet}")

Callers

nothing calls this directly

Calls 4

runMethod · 0.95
PlanExecuteRunnerClass · 0.90
_print_sectionFunction · 0.85
_build_llmFunction · 0.70

Tested by

no test coverage detected