Commit e8dff76
committed
fix(level_4): replace gahmen McpToolset with FunctionTool wrappers + chart artifact passthrough (W9.3)
Fixes the W9.2 Telegram E2E failure where Level 4 returned [empty] —
gahmen tools were wired in source but never registered at runtime.
Smoking gun (verified 2026-05-01 via deployed-engine probe): every
Level 4 invocation hit `Tool 'gahmen_singstat_search_resources' not
found. Available tools: consult_level_1`.
Root cause: Smithery's hosted MCP endpoint requires `?api_key=<KEY>`
query-param auth, NOT `Authorization: Bearer <KEY>` header. McpToolset's
StreamableHTTPConnectionParams sent Bearer header → silent 401 on
tools/list lazy-fetch → 0 gahmen tools in the agent's tools_dict → LLM
saw the names in the instruction but couldn't call them. The same
configuration ghost has been present since the W8.2 NBS swarm
Strategist wiring; that integration has likely never actually served
gahmen tools either (worth a follow-up probe).
level_4_agent/gahmen_tools.py (new file)
Eight async function wrappers around Smithery's JSON-RPC-over-HTTP
endpoint, each registered as ADK 2.0's FunctionTool primitive.
Verified 2026-05-01 with a tools/list probe returning all 8 expected
tools. Same gahmen_<original> naming so the data_fetcher instruction
is unchanged.
level_4_agent/agent.py
- Drop the McpToolset construction + the gahmen_toolset variable.
- data_fetcher_agent.tools = [FunctionTool(consult_level_1), *GAHMEN_TOOLS].
- report_writer_agent: dropped output_schema=Brief. With it, the
response packaged as a JSON function-response that didn't surface
as text in the A2A response. Markdown text via instruction-enforced
headings is the contract now (same fix as the orchestrator's
writer_agent in W9.1).
- analyst_agent: appended a CHART DESCRIPTION block to the
instruction. Required text after every chart, leading with the
headline finding + 3-5 specific numbers. Coordinator quotes this
in the brief so A2A consumers (orchestrator, bot) get the chart's
narrative even when the binary artifact doesn't propagate.
deploy_a2a.py
Register google.adk.a2a.executor.interceptors.include_artifacts_in_a2a_event_interceptor
in A2aAgentExecutorConfig. Default execute_interceptors=None means
pre-W9.3 deploys never copied session artifacts into the A2A response
— that's why the orchestrator's chart_agent images died in their
containers. The interceptor reads actions.artifact_delta (which
BuiltInCodeExecutor populates via _code_execution.py:299-311) and
emits TaskArtifactUpdateEvents that surface in Task.artifacts[*].
Local probe (scripts/local_smoke.py level_4_agent ...) confirms the
full pipeline: data_fetcher → 3x gahmen_singstat_search_resources +
gahmen_datagovsg_search_dataset + consult_level_1 → analyst_agent
(chart, no gotcha-google#21 hang) → report_writer_agent (Markdown brief).
108s elapsed; 5138 chars of structured output with all 5 Markdown
headings and the CHART DESCRIPTION block.
Vertex deployments:
level_4: 7527384696859131904 (us-central1, appspot SA)
a2a_orchestrator: 1748140475035942912 (us-central1, appspot SA)
Old W9.2 engines (7335418762742464512, 3876654248921923584) deleted.
Two structural gaps surface in deployed testing, deferred to W9.4:
1. Vertex Agent Engine's ~180s per-request timeout aborts orchestrator
runs on prompts that trigger 3+ cross-region Pro 2.5 Level consults
("thorough analysis"-class wording). Returns 400 with no body. Not
configurable via agent_engines.create() parameters.
2. Orchestrator's chart_agent doesn't always fire — its instruction
has an "if chart warranted" clause that Pro 2.5 sometimes declines.
When it doesn't fire, no chart exists for the interceptor to ship.
Plan reference: new features/18-level-4-mcp-and-chart-return.md.1 parent fd3c68c commit e8dff76
3 files changed
Lines changed: 343 additions & 58 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
100 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
101 | 117 | | |
102 | 118 | | |
103 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | 112 | | |
114 | 113 | | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
132 | 132 | | |
133 | | - | |
134 | | - | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | 137 | | |
167 | 138 | | |
168 | 139 | | |
| |||
270 | 241 | | |
271 | 242 | | |
272 | 243 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 244 | + | |
278 | 245 | | |
279 | 246 | | |
280 | 247 | | |
281 | 248 | | |
282 | 249 | | |
283 | 250 | | |
284 | | - | |
| 251 | + | |
285 | 252 | | |
286 | 253 | | |
287 | 254 | | |
| |||
442 | 409 | | |
443 | 410 | | |
444 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
445 | 425 | | |
446 | 426 | | |
447 | 427 | | |
| |||
457 | 437 | | |
458 | 438 | | |
459 | 439 | | |
460 | | - | |
| 440 | + | |
461 | 441 | | |
462 | 442 | | |
463 | 443 | | |
464 | 444 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
469 | 454 | | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
476 | 485 | | |
477 | 486 | | |
478 | 487 | | |
| |||
0 commit comments