Repository navigation
a2a: redact the extended agent card's interfaces instead of relaying them - #814
asivanadi0 wants to merge 5 commits into
Conversation
The caller's node regenerates the public agent card, but GetExtendedAgentCard (JSON-RPC) and GET .../extendedAgentCard (HTTP+JSON) are proxied untouched, so the extended card a client gets through the mesh names the agent's private interfaces. A client that follows A2A 1.0 section 3.1.11 replaces its card with that one and dials the agent directly, skipping the caller's node. regenerateAgentCardForMesh now sets capabilities.extendedAgentCard to false, and the JS and Python SDK rewrites drop it the same way. Stock clients then do not ask for the extended card: a2a-go's Client.GetExtendedAgentCard returns ErrExtendedCardNotConfigured without sending anything. This adds no work to the egress proxy hot path. A client that calls the method anyway is still proxied as before; refusing that on the wire for JSON-RPC needs the request body read that regenerating the extended card would also need. TestA2ACUJ gives the agent an extended card with private URLs and checks the regenerated card declares none and the stock client never fetches it. The node and SDK card tests cover the flag. Fixes google#675 Signed-off-by: Anpoo Sivanadi <sivanadi08@gmail.com>
Signed-off-by: Anpoo Sivanadi <sivanadi08@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request ensures that regenerated agent cards do not declare an extended agent card, preventing clients from attempting to connect directly to private interface URLs. This change is implemented across the Go backend, JS and Python SDKs, integration tests, and documentation. The review feedback correctly identifies two instances in the Go unit and integration tests where assertion messages violate Rule 3.8 of the style guide by failing to output both the observed and expected values.
| if card.Capabilities.ExtendedAgentCard { | ||
| t.Error("extendedAgentCard must be off in the regenerated card: the extended card is relayed with the agent's own URLs") | ||
| } |
There was a problem hiding this comment.
Rule 3.8 Violation\n\nAccording to the Repository Style Guide (Section 3, Rule 8), test assertion messages must state both the observed and the expected value. The current assertion message only states that the capability must be off, without printing the actual observed value.
\tif card.Capabilities.ExtendedAgentCard {\n\t\tt.Errorf(\"extendedAgentCard = %v, want false: the extended card is relayed with the agent's own URLs\", card.Capabilities.ExtendedAgentCard)\n\t}References
- Tests must be plain Go on the standard testing package and assertion messages must state both the observed and the expected value. (link)
| if extendedCardServed.Load() { | ||
| t.Error("the agent served its extended card through the mesh") | ||
| } |
There was a problem hiding this comment.
Rule 3.8 Violation\n\nAccording to the Repository Style Guide (Section 3, Rule 8), test assertion messages must state both the observed and the expected value. The current assertion message does not print the observed value of extendedCardServed.Load().
\tif extendedCardServed.Load() {\n\t\tt.Errorf(\"extendedCardServed = %v, want false: the agent served its extended card through the mesh\", extendedCardServed.Load())\n\t}References
- Tests must be plain Go on the standard testing package and assertion messages must state both the observed and the expected value. (link)
The extendedAgentCard, signatures and extendedCardServed checks now state the observed and the expected value, per style guide rule 3.8. Signed-off-by: Anpoo Sivanadi <sivanadi08@gmail.com>
|
Pushed 39e84c6: the extendedAgentCard, signatures and extendedCardServed assertions now print the observed value next to the expected one, per style guide rule 3.8. Test-only change. |
|
I'm not quite familiar with the a2a protocol so I think we should ask for the canonical way, we naively rewrite the a2a card to point to the mesh url, that is the one that is reachable ... what is the use of the extended card? to add this public exposed urls? should we stop rewriting the cards if that is affirmative ? Let me ask a2a expert like @yarolegovich |
disabling extended agent card capability can be limiting. it's unlikely that extended agent card is used for advertising agent interfaces, because you have to be already connected to an agent to access it. extended agent card is supposed to advertise extended capabilities allowed to authenticated users, for example more input modes (accept images or other media) or more skills. the use is app-specific, so nothing can be said for sure. but it's likely that private interfaces (I mean inaccessible from the outside) will leak to clients. I'd consider redacting them. |
Per review, the regenerated card no longer turns the extended card off: the extended card is how an agent offers authenticated callers more skills and input modes. Instead, the caller's node answers a GetExtendedAgentCard call itself (JSON-RPC, read from a request body of at most 64 KiB, or GET .../extendedAgentCard over HTTP+JSON): it forwards the call to the agent and serves the card back with each interface the mesh carries at the mesh URL the regenerated public card gives that binding. Interfaces whose binding the public card does not offer are dropped, so none of the agent's own URLs, private ones included, reach the client. Signatures are dropped as on the public card. A card left with no interface is refused with 502, and agent errors are relayed as before. Every other request streams through the proxy with its body intact. The JS and Python SDK transports still relay the extended card as the agent wrote it, so their rewritten card keeps declaring none; only their comments change. Signed-off-by: Anpoo Sivanadi <sivanadi08@gmail.com>
|
Thanks @yarolegovich, that makes sense. I reworked the PR in cfa7a40 to keep the extended card and redact it instead. The regenerated card now keeps To detect the JSON-RPC call, the node reads at most 64 KiB of the request body. Anything larger, and every other method, goes through the proxy unchanged with its body intact. Tests: The JS and Python SDK transports still relay the extended card unchanged, so their rewritten card keeps declaring none for now. I can bring the same redaction to them in a follow-up. |
|
Two small edge cases worth cleaning up :
|
a2aMeshRequest now sets RawQuery separately and only appends the upstream path when it is present, so an empty path with a query is libp2p://peer/type/name?q rather than a path that ends in /?q. A GetExtendedAgentCard JSON-RPC response with result null, or a non-null error, is relayed as the agent wrote it instead of 502. Signed-off-by: Anpoo Sivanadi <sivanadi08@gmail.com>
|
Thanks for catching these, both fixed. Trailing slash / query in The public well-known card fetch still hits JSON-RPC error with Tests: added |
Fixes #675
The caller's node regenerates the public agent card, but
GetExtendedAgentCard(JSON-RPC) andGET .../extendedAgentCard(HTTP+JSON) were proxied unchanged, so the extended card that came back named the agent's private interfaces. A client that follows A2A 1.0 section 3.1.11 replaces its card with that one and dials the agent directly, skipping the caller's node.Following review from @yarolegovich, the extended card stays declared and is redacted instead of turned off:
regenerateAgentCardForMeshkeepscapabilities.extendedAgentCardas the agent declares it.a2aServeExtendedAgentCard). For JSON-RPC it reads at most 64 KiB of the request body to recognize the method. Larger bodies and every other method stream through the proxy unchanged.redactExtendedAgentCardForMesh). Each interface the mesh carries gets the mesh URL that the regenerated public card gives the same binding. Interfaces whose binding the public card does not offer, gRPC included, are dropped. Skills, input and output modes and the rest of the card stay as the agent wrote them. Signatures are dropped, as on the public card.The JS and Python SDK transports still relay the extended card unchanged, so their rewrites (
rewriteAgentCard,rewrite_agent_card) keep droppingextendedAgentCardfor now. Bringing the same redaction to them can be a follow-up. The two doc pages that describe card regeneration now describe the redaction.Tests:
TestA2ACUJ: the agent declaresextendedAgentCard: trueand serves an extended card with an extra skill, an extra input mode, a private JSON-RPC URL (http://127.0.0.1:7777) and a gRPC interface. The stock client'sGetExtendedAgentCardthrough the mesh returns that card with the skill and input mode, exactly one interface at the mesh/invokeURL, none of the private addresses and no signatures, andUpdateCardaccepts it.TestA2AServeAgentCardRegenerateschecks the flag stays on.internal/nodeunit tests:TestA2AServeExtendedAgentCardJSONRPCRedacts,TestA2AServeExtendedAgentCardHTTPJSONRedacts(with and without a tenant segment),TestA2AServeExtendedAgentCardDropsBindingsTheMeshDoesNotOffer,TestA2AServeExtendedAgentCardFailsClosed,TestA2AServeExtendedAgentCardRelaysErrorsandTestA2AServeExtendedAgentCardLeavesOtherCallsToTheProxy.go build ./...,go vet,go test -race ./internal/node/,TestA2ACUJ, andgolangci-linton the touched Go packages pass. The branch merges cleanly with currentmain.