feat: [2/2] Execute multi-agent HTTP Responses and verify recorded contracts #373
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #373"
general
weight: 0.35
franciscojavierarceo
Summary
issue: #229
PR 1 teaches the gateway to represent multi-agent Responses items, but does not run agents. This PR adds the HTTP runtime: a stored request with
multi_agent.enabled: truecan spawn and coordinate subagents, return their work in one Responses result or SSE stream, and resume the tree throughprevious_response_id. Themulti_agentoption belongs to the gateway; it is not forwarded as a provider option. The gateway exposes collaboration actions to the model as gateway-owned function tools while retaining ordinary client tools such as web search, MCP, and local shell. This is separate fromparallel_tool_calls, which controls tool-call parallelism within a model turn rather than agent lifecycles.Request admission requires
store: true, rejects a zero concurrency limit, and rejects reasoning summaries and explicit compaction triggers with multi-agent enabled. An omittedmax_concurrent_subagentsuses three active descendant slots; the root is separate from that limit. The gateway validates continuation against the stored tree, rather than trusting client-supplied collaboration transcript items to recreate an agent.Implementation and review boundary
EngineOrchestrationselects the existing single-agent path or aMultiAgentRun. The response coordinator owns the agent registry, task ownership, mailboxes, pending client calls, shared response budget, completion, and persistence. Each agent has its ownAgentPipeline, tool registry, context, and round progress. This split lets agent tasks run concurrently without creating an independent public response per child. Collaboration functions implement spawning, messaging, follow-up, waiting, interruption, and listing; per-agent guidance narrows the assigned job and discourages unnecessary delegation and waits.StoredTreeSnapshotrecords the canonical agent tree, histories, and pending-call relationships. Checkpoint loading validates references and limits before constructing live tasks. Typedcommit_treemethods on the existing response and conversation handlers persist the tree with the public result; storage serialization remains at that boundary. Continuations match client outputs to their owning agent and call ID. Public encrypted agent-message content remains separate from gateway-owned canonical mail.CompactionPlancarries the agent identity and context generation;CompactionCommit::{Applied, Stale}replaces that prefix only if the generation still matches. This preserves intervening mail, pending calls, and appended history. Discovery items and prompt-cache settings are retained through the compaction request. The existing single-agent compaction path is still available when multi-agent is disabled.The runtime code is divided across
engine/agent_turn.rs,engine/multi_agent/,executor/multi_agent/, and pipeline delivery/projection modules so the coordinator, per-agent execution, registry, collaboration actions, streaming, checkpoint validation, and compaction each have a clear owner. The resulting file-size baseline change removes the old oversizedengine.rsentry; a narrow documented allowance covers the expanded request-admission module.Recorded scenario comparison
Gateway:
Qwen/Qwen3.6-35B-A3B-FP8. OpenAI reference:gpt-5.6-sol. Counts represent unique calls across each complete session, including client-tool continuations, rather than repeated SSE appearances. Model-generated text, reasoning, names, and action counts are not expected to match exactly.Proposals
Prompt: Delegate retrieval and assessment of proposals alpha and beta, then recommend one using the returned data. Tests parallel delegation and client-owned function-call continuation.
| Metric | OpenAI nonstream | Gateway nonstream | OpenAI stream | Gateway stream |
|---|---:|---:|---:|---:|
| Successful spawns | 2 | 2 | 2 | 2 |
| Collaboration calls | 17 | 6 | 18 | 9 |
| Waits / timeouts | 4 / 4 | 4 / 2 | 7 / 5 | 1 / 0 |
| Function calls / returned outputs | 6 / 6 | 4 / 4 | 4 / 4 | 2 / 2 |
| Completed | Yes | Yes | Yes | Yes |
Gateway streaming recovered from six invalid
list_agentsrequests containingtimeout_ms.Review
Prompt: Delegate correctness, security, and test-coverage review of a Python cache using
pickle.loadson unauthenticated input, then consolidate findings. Tests agent creation, messaging, and completion without external tools.| Metric | OpenAI nonstream | Gateway nonstream | OpenAI stream | Gateway stream |
|---|---:|---:|---:|---:|
| Successful spawns | 3 | 3 | 3 | 3 |
| Collaboration calls | 6 | 9 | 7 | 7 |
| Waits / timeouts | 3 / 0 | 4 / 0 | 3 / 1 | 4 / 1 |
| Agent messages | 6 | 6 | 6 | 6 |
| Completed | Yes | Yes | Yes | Yes |
Gateway nonstreaming rejected one extra spawn at the concurrency limit.
Mixed tools
Prompt: Delegate Python CSV web research, tiktoken research through the remote GitMCP server, and the local-shell calculation
python3 -c 'print(sum(range(1, 11)))', then combine the findings. Tests mixed tool ownership and continuation with mocked client shell outputs.| Metric | OpenAI nonstream | Gateway nonstream | OpenAI stream | Gateway stream |
|---|---:|---:|---:|---:|
| Successful spawns | 3 | 3 | 4 | 3 |
| Collaboration calls | 18 | 16 | 24 | 13 |
| Waits / timeouts | 7 / 4 | 9 / 5 | 11 / 6 | 6 / 0 |
| Web / MCP calls | 2 / 2 | 1 / 2 | 2 / 2 | 2 / 4 |
| Shell calls / returned outputs | 3 / 3 | 2 / 2 | 4 / 4 | 2 / 2 |
| Completed | Yes | Yes | Yes | Yes |
OpenAI streaming created a replacement fourth agent over the session; the limit applies to concurrent subagents. Gateway repeated some shell work. Shell outputs are scripted fixtures, not actual shell executions.
All twelve recordings reached completed responses. Collaboration calls have matching outputs, and streaming sequence and item-identity checks passed. Successful gateway
list_agentsresults useagent_nameandagent_status, including completed answer text. The Rust cassette comparison tests passed: 7 passed, 0 failed, 1 optional test ignored (cargo test -p agentic-server-core --test multi_agent_contract_test --offline -- --test-threads=2).| Client-owned tools | OpenAI nonstream | Gateway nonstream | OpenAI stream | Gateway stream |
|---|---:|---:|---:|---:|
| Successful spawns | 3 | 3 | 3 | 3 |
| Collaboration calls | 8 | 5 | 15 | 5 |
| Waits / timeouts | 2 / 1 | 2 / 0 | 4 / 3 | 2 / 0 |
| Tool-search calls / returned outputs | 6 / 6 | 2 / 2 | 6 / 6 | 2 / 2 |
| Discovered function calls / returned outputs | 2 / 2 | 2 / 2 | 4 / 4 | 2 / 2 |
| Custom calls / returned outputs | 1 / 1 | 1 / 1 | 1 / 1 | 1 / 1 |
| Completed | Yes | Yes | Yes | Yes |
Stack and scope
This is PR 2 of 2, branch
multi-agent-http-support-pr-2at96494f8, targeting PR 1multi-agent-http-support-pr-1atb8e71e6.Test Plan
cargo testrecoded cassettes