Skip to content

feat: [1/2] Model multi-agent Responses items and event lifecycles - #372

Merged
maralbahari merged 6 commits into
mainfrom
multi-agent-http-support-pr-1
Sep 29, 2026
Merged

maralbahari merged 6 commits into
mainfrom
multi-agent-http-support-pr-1

Conversation

@maralbahari

@maralbahari maralbahari commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Issue: #299

A Responses stream can contain work from several agents, including multi_agent_call, multi_agent_call_output, and agent_message items. Before the gateway can execute those calls, it must preserve their wire shape and attribution through parsing, stream accumulation, response translation, and stored item conversion. This PR adds that response-side foundation. It does not accept a multi-agent request, spawn agents, or change the upstream model request to include gateway-only collaboration items.

The main changes are:

  • Add typed public collaboration items and actions, optional agent attribution, and canonical internal agent/turn identities. call_id links each collaboration call to its output; item IDs remain separate. The public encrypted agent_message content stays distinct from gateway-owned plaintext mail. The configuration type preserves an omitted concurrency limit on the wire, but request admission is left to PR 2.
  • Extend input/output conversion, OpenAPI schemas, storage item conversion, and the model-input projection. Collaboration transcript items round-trip as Responses items but are excluded from model-facing input; ordinary assistant messages keep their output-text form on continuation. Output-text metadata, including absent versus empty annotations and logprobs, is represented by the typed content enum rather than flattened text.
  • Normalize and validate collaboration items, completed message content parts, and event-level attribution. The event header's attribution and the embedded item's attribution remain separate because one may be present without the other. The accumulator binds each item to its event identity, rejects contradictory terminal snapshots or completed content parts, and accounts for retained bytes. Translation carries the source event attribution through generated tool frames instead of inventing a root agent.
  • Extend response-budget accounting to the new items and add saturating usage aggregation for later multi-agent accounting. Existing tool, storage, and request constructors are updated for the expanded item enums and optional attribution.

Several files are split by responsibility to keep production files within the repository's size policy: compaction token estimation moves to compaction/estimate.rs, item lifecycle operations to output/apply_done.rs, event item types to events/types/item.rs, agent-message accumulation to accumulator/active/agent_message.rs, client-output budgeting to response_budget/client_outputs.rs, tool-search validation to its own module, and gateway history helpers to gateway/history.rs. The large diff also includes exhaustive-match and test-fixture updates required by the new variants; these do not enable orchestration. Compaction's existing token-estimation behavior is moved, not replaced with the multi-agent safe-prefix algorithm, which belongs to PR 2.

Stack and review boundary

This is PR 1 of 2, branch multi-agent-http-support-pr-1, intended to target upstream main.

Test Plan

  • cargo check --workspace --all-targets — passed.
  • cargo build --workspace — passed.
  • cargo test -p agentic-server-core --lib — 798 passed after the main merge.
  • cargo test -p agentic-server-core --test event_normalizer_test — 43 passed. Updated one stale assertion to expect the intentionally retained initial function-call item.

@maralbahari
maralbahari added this pull request to stack #374 September 25, 2026 05:35
Signed-off-by: maral <[email protected]>
@maralbahari
maralbahari merged commit 5ce142f into main Sep 29, 2026
19 checks passed
haoshan98 added a commit that referenced this pull request Sep 30, 2026
## Summary

Several user-facing docs had fallen behind `main` or contradicted each
other and the code. This PR brings them in line with what has shipped.
It changes documentation only.


**Corrected claims**
- README listed the Messages API as "🚧 Planned" while another README
section documents `/v1/messages`. It is now listed as shipped; only
stateful Messages stays planned.
- README and `docs/index.md` advertised "Background execution" and
gateway-executed file search. Neither exists yet: background mode is
#357, and `file_search` declarations parse but are dropped before
inference (`tool/normalize.rs`). Both claims are removed.
- `docs/api/index.md` quoted fixed WebSocket and executor limits (256
KiB SSE lines, 1 MiB events and response budget). These now come from
the configurable `[responses]` settings, which default to 16 MiB and 8
MiB.
- `docs/api/index.md` listed only some of the conditions that route a
Responses request through the executor. The list now also includes
non-function tools, `multi_agent.enabled`, and tool-search state,
matching `handler/http/responses.rs`.
- CHANGELOG listed Tavily under 0.8.0, but it merged on Sep 28, after
the Sep 19 release. The two Tavily entries move to `[Unreleased]`.

**Newly documented features**
- README: a multi-agent Responses section with an example and the
gateway's limits (`store: true`, HTTP/SSE only, default of 3 concurrent
subagents, no `max_tool_calls` or reasoning summaries). Also new rows in
the API table for `/v1/responses/compact`, the full Conversations
routes, `/v1/messages` with `/v1/messages/count_tokens`, and
Swagger/OpenAPI (`ENABLE_OPENAPI_DOCS`). The features list, diagram, and
tool ownership table now include MCP, the code interpreter, Claude Code,
compaction, and OpenTelemetry.
- `docs/api/index.md`: new sections for `GET
/v1/responses/{response_id}`, multi-agent, Conversations, and Messages.
- CHANGELOG `[Unreleased]` was empty. It now has entries for #345, #347,
#349, #351/#370, #354, #368, #369, #372/#373, #380, and #387.

**Roadmap**
- ROADMAP.md marks multi-agent HTTP execution as shipped, with WebSocket
injection (#300) and stateless requests (#393) still open. It adds a
status note for Messages, a code interpreter entry, and a file search
item linking #34 and #356.
- README "Roadmap at a Glance" checks off Messages and Conversations and
adds unchecked items for multi-agent, file search, and stateful
Messages.

**Smaller fixes**
- The repository layout in README and AGENTS.md now lists
`agentic-llm-d`, `agentic-cli-docs`, and `python/agentic_api/`.
- ARCHITECTURE.md's list of multi-agent rejections now includes
`max_tool_calls`, matching `executor/rehydrate.rs`.
- `mkdocs.yaml` adds the existing but unlinked `design/shell-tool.md` to
the nav.

**Not changed:** the README's "Rust 1.85+" badge is wrong (1.85 cannot
build the lockfile, see #377), but #379 already updates it to 1.88 along
with `rust-version` and a CI check, so this PR leaves it alone to avoid
a conflict.

Signed-off-by: haoshan98 <[email protected]>
@maralbahari
maralbahari deleted the multi-agent-http-support-pr-1 branch October 1, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants