MCPcopy Create free account
hub / github.com/IBM/AssetOpsBench / print_trajectory

Function print_trajectory

src/agent/_cli_common.py:84–108  ·  view source on GitHub ↗

Pretty-print turns, tool calls, and token totals to stdout.

(trajectory)

Source from the content-addressed store, hash-verified

82
83
84def print_trajectory(trajectory) -> None:
85 """Pretty-print turns, tool calls, and token totals to stdout."""
86 print(f"\n{HR}")
87 print(" Trace")
88 print(HR)
89 for turn in trajectory.turns:
90 print(
91 f"\n [Turn {turn.index}] "
92 f"in={turn.input_tokens} out={turn.output_tokens} tokens"
93 )
94 if turn.text:
95 snippet = turn.text[:200] + ("..." if len(turn.text) > 200 else "")
96 print(f" text: {snippet}")
97 for tc in turn.tool_calls:
98 print(f" tool: {tc.name} input: {tc.input}")
99 if tc.output is not None:
100 out_str = str(tc.output)
101 snippet = out_str[:200] + ("..." if len(out_str) > 200 else "")
102 print(f" output: {snippet}")
103 print(
104 f"\n Total: {trajectory.total_input_tokens} input / "
105 f"{trajectory.total_output_tokens} output tokens "
106 f"({len(trajectory.turns)} turns, "
107 f"{len(trajectory.all_tool_calls)} tool calls)"
108 )
109
110
111def print_answer(answer: str) -> None:

Callers 1

print_resultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected