Repository navigation
feat(a2a-agent): atif/1 reads leave out the secrets the SDK knows - #827
Merged
Merged
Conversation
Every atif/1 read, inline, uploaded or paged, writes each secret the SDK holds or is handed as [redacted:<length>] wherever it occurs: the control token, the model key and extra headers' values, write-only agent-config values, MCP and CDP credentials, the parts of every transfer grant that carry its credential, a clock follower's read token, and whatever the agent registers with self.register_secret(value). Secrets are taken from each extension call before any handler runs and scrubbed at read time, matched raw, JSON-escaped and percent-encoded, the longest first; one under 8 characters is left with a warning. Cursor pages count their byte budget as they serve. Native reads are untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ets as a trie built once per change A secret used as a mapping key, or written JSON-escaped without ASCII escapes as an inbound DataPart's compact JSON is, was served as it was. Keys are scrubbed too, and each secret's non-ASCII JSON form is matched. Adding a secret no longer rebuilds the match: it is compiled when a read next needs it, as a prefix trie, so a call that hands the agent a grant per file, or a run that accumulates thousands, compiles once and scans no slower. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en't redacted Every query value of a presigned URL was registered, so AWS4-HMAC-SHA256 and the signing date were redacted wherever an agent met them, and every string in a write-only mapping was, so pi's model_params had words like "priority" redacted and short ones warned about. One rule now tells a credential by its name (signature, credential, token, key, password, auth, policy, ...) for query parameters, a signed form's fields and the keys of a write-only mapping, taking everything below a credential-like key; a write-only string is still taken whole, and a grant's URL and request line still are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… needs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… credential Each grant registered its whole URL and its path and query, about 4,700 unique characters for a 1,200-character S3 URL with a session token, so 500 grants made the trie 2.4M characters: a 5.2 s compile on the event loop and 410 MiB after each new grant. A URL now gives its credential-like query values, or the token-like path segments of a URL with no query, and its password: every copy of the URL holds them, and the session token and access key a role signs every grant with are one secret each, so a grant adds its signature. 500 such grants compile in 0.07 s and 6 MiB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f/1 is served Secrets.for_agent takes the agent's environment and write-only config defaults, and add_request now takes an agent-config call's write-only values too, so framework.py only builds it and hands it the control token and each extension call. AtifCopy is built with the scrub and serves everything through it, the task read's aux log and turn context as wire dicts, so no read path passes a scrub of its own; its cursor pages take each step's id from the step before scrubbing. Secrets._forms names a secret's four forms, the two name rules share one comment, and the tests share one string walker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y secrets as written A grant server's /v1/grants/<token>?download=1 gave no secret, since only a URL with no query had its path tokens taken: path tokens are now taken whenever the query carries no credential. A signed URL percent-encoded again, as inside another URL's query, held its token encoded twice, which no form matched: each credential query value is now taken as the URL writes it too, whose own encoding is that copy's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The last of Y2b's three PRs for FD-6076: an agent's
atif/1reads leave out every secret its SDK holds or is handed, and every one the agent registers (Y2b-4). Part of FD-6076.What changes
atif/1read is scrubbed as it's served: the document, the aux log and the turn context; inline, uploaded through the objects form, and in cursor pages. Each secret is written[redacted:<length>]wherever it occurs, in any string, mapping keys included. Native reads keep every secret byte for byte._secrets.Secrets.for_agent, one per agent that servesatif/1;framework.pyonly builds it, hands it the control token and each extension call, andAtifCopyserves everything through its scrub):LITELLM_API_KEYand the values ofLITELLM_EXTRA_HEADERS;model_paramsdoesn't getpriorityor a provider's name redacted;X-Amz-Signature,X-Amz-Credential,X-Amz-Security-Token,X-Goog-Signature, Azure'ssig,token,key, ...; notX-Amz-Algorithm,X-Amz-DateorX-Amz-SignedHeaders, soAWS4-HMAC-SHA256stays in an agent's text), else its token-like path segments (a grant server's/v1/grants/<token>, plain query or not), and a password; each query value both decoded and as the URL writes it, so a copy of the URL inside another URL's query matches too. Every copy of a URL holds those, so a URL an agent prints keeps its host and path and loses its signature. Also its headers other thanContent-Typeand the like, and a signed upload form's signing fields;self.register_secret(value), once its app exists.mcp add,agent-config set, ...) is covered too.X-Amz-Expires=900, are skipped silently.max_bytes.Choices to review
Content-Type,X-Amz-Algorithm, the upload form's key and a write-only mapping's non-credential values are left, so ordinary text isn't mangled. A credential under a name the rule doesn't know is still caught whole, in the URL or by a registration.Testing
tests/test_a2a_atif_scrubbing.py(22 tests):AWS4-HMAC-SHA256andX-Amz-Dateleft;atif/1registers nothing, and registering beforecreate_app()is refused.Removing each source's registration, or the read-time scrub, fails these tests.
Integration: a new test in
test_prompt_agent_live_trajectory_local.pydeploys the echo agent with a model key and promptsrun printenv LITELLM_API_KEY. The native read keeps the printed key; theatif/1read holds[redacted:<n>]instead and validates.put_test_agenttakes anenv.Serving chaos (the PR 1 and PR 2 harness, now with the seed's model key in the agent's environment and in some texts, messages and notes). It checks:
no
atif/1answer or upload holds the key;native reads keep it;
replaying the served inputs, then redacting the key, gives the served document.
On the vm host: 20 min on 9f68009 (89,081 seeds, 334,069 tasks, 33,253 restarts, 33,254 restores), no failures. The integration file's 4 tests passed there.
60 s locally on each commit, no failures. It caught both planted leaks: an unscrubbed cursor page, and an unscrubbed aux log and turn context.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge.Summary
The SDK removes known secrets from
atif/1reads while leaving native logs unchanged.earakely-scaleaccepted that two mapping keys can collapse after redaction, as the cost of not serving their secrets.Reviews (10) · Last reviewed commit: "docs(a2a-agent): the README names how a ..." · Reviewed by Greptile