Repository navigation
feat(rig-a2a): expose activated extensions to the agent run - #85
Merged
Merged
Conversation
A tool or hook can call rig_a2a::activated_extensions() during a run to read the declared extension URIs the request activated. The executor reads them from the request's service params, which the SDK already fills from the headers, so v1.0 and v0.3 share one path. The list is set per poll of the run, so streaming and non-streaming calls both see it.
Document that a tool running on a spawned task or another thread sees an empty list, so it reads the list first. Note that a plain A2A-Extensions header on the v0.3 surface is also seen. Add tests for the typed run and for a tool that spawns a task.
pingedbrain
marked this pull request as ready for review
November 29, 2026 02:36
pingedbrain
enabled auto-merge (squash)
November 29, 2026 02:36
# Conflicts: # crates/rig-a2a/CHANGELOG.md # crates/rig-a2a/tests/integration/extensions.rs
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additive; ships in 0.47.7.
Non-breaking. This adds one public function and changes no existing signature or behavior. It is a normal
feat(rig-a2a):change, not!.What
A tool or hook in an agent run can now call
rig_a2a::activated_extensions()to get the declared extension URIs its request activated. The list is sorted, holds only URIs declared withA2aServer::extension, and is empty when nothing was activated or when called outside a run.Why
The server echoed activated extensions but the agent run could not see them. Earlier attempts found no place that did not change a signature.
Design choice
Two parts:
ExecutorContext::service_params. The A2A SDK already fills this from the request headers for both the JSON-RPC and HTTP+JSON bindings. The v0.3 middleware already copiesX-A2A-ExtensionsintoA2A-Extensionsbefore the SDK sees it. So the executor reads one key (a2a-extensions) and gets both protocol versions with no new middleware. The executor gets the declared list fromA2aServer::into_routerthrough a crate-private setter.executein a spawned task (tokio::spawnindrive_execution), so a task-local set in the axum middleware would not reach the run. Setting it around eachstream.next()poll and around the typed-run future keeps the value in scope for tool calls. Rig does not spawn tasks for tool calls, so tools see it. Streaming and non-streaming both go through this same run loop.Rejected: a field on a new per-request context passed to a custom handler. Rig's
Tool::callhas no such argument, so it would force tools to take a new type.Changes
src/executor.rs: the task-local,activated_extensions(), the parsing, adeclaredfield, and the scoped polls.src/server.rs: the declared list is computed before the handler and passed to the executor. Theextensiondocs point to the new function.src/lib.rs: re-export.Cargo.toml: tokiortfeature fortask_local!.tests/integration/extensions.rs: a tool records what it sees. Covers v1.0 and v0.3,message:send/message:streamandmessage/send/message/stream. A request activating one declared and one undeclared URI sees only the declared one. A request with no header sees an empty list.## Unreleased).How verified
cargo fmt --all -- --checkcargo clippy -p rig-a2a --all-targets --all-features -- -D warningscargo test -p rig-a2a --all-features(all pass, including the two new tests and the new doctest)RUSTDOCFLAGS=-Dwarnings cargo doc -p rig-a2a --no-deps --all-featuresLimits (added after review)
tokio::spawn,spawn_blockingor another thread sees an empty list. Tests cover this.X-A2A-Extensions. A plainA2A-Extensionsheader sent to v0.3 is also seen, since the SDK reads that key. A test pins this.A2aExecutor::typed) on both surfaces, streaming and not.