Repository navigation
Conversation
update_secrets() mutated state.secret_registry.secret_sources in place.
ConversationState autosaves only on field assignment, so the new secret
stayed in memory: base_state.json did not have it until some other state
change happened to save, and a restart or idle eviction before that lost
it. Readers of the saved state (GET /api/conversations/{id}) could not
see it either.
Update a copy of the registry and assign it, under the state lock, so
the change is saved before update_secrets returns.
Split out of #4813 (commit 30f79f0), where it shipped together with the
agent-server changes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
update_secrets() now reassigns state.secret_registry to a fresh object so the change autosaves to base_state.json. The ACP bridge had captured state.secret_registry.mask_secrets_in_output once at session start, so a secret added later was still streamed unmasked through on_token (only the persisted event was masked). Read the registry on each call instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W9qxyUBKhzmbLrTK2wi7D7
Reads base_state.json right after the constructor and after update_secrets, then resumes from disk: start-time and runtime secrets are both there, and a runtime override of a start-time secret is the value that comes back. Fails on main, where the registry was mutated in place and never saved. Carried over from #5788 (commit 864a1e5), which fixes the same bug the same way. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
The S04 secrets program now reads base_state.json right after update_secrets and right after Conversation(secrets=...), before any message or run, and the recipe checks the names are there. On main both lists are empty; with the fix the recipe passes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
F04.create-secrets-get, F08.secrets-visible and F08.secrets-unsaved-restart report xfail twice on main and xpass twice on this branch (`map run --fresh --repeat 2`, each attempt on its own server), so their markers go and their text describes what happens now. The wording is carried over from #5788, which proved the same three bullets for the same SDK change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
The comment explained what LocalConversation.update_secrets does and pointed at another method. It now says the one thing the reader of this code needs: the registry is looked up on every call because the state's registry object is replaced when secrets change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
str(ConversationStateUpdateEvent) formatted the live value. For the
`secret_registry` key that is the registry object, whose LookupSecret
headers are a plain dict, so an Authorization header printed in clear.
Nothing in the repo prints these events today, but with secrets saved on
every change this event is now routine on the agent-server, and one
`logger.debug("%s", event)` would have leaked a credential.
Print the value through the serializer, which masks it. The new test
pins the whole contract for a secrets change: one state update, names
and masked values only, in the event, in its printed form and in the
saved event file, with and without a cipher; an unchanged update emits
nothing.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
The secret bullets hold for a conversation that is not in the middle of a step. A change posted while a run waits on its model is live at once and saved when the step ends; #5776 is the fix for that window. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||
…oad keeps today The comment records that model_copy keeps the masking cache shared with the previous registry object, which ACP credential and stream masking can still hold. The feature-map note now separates a runtime secret with a new name, which survives a reload, from a new value for a creation-time name, which the load still replaces with the copy in meta.json. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
…aved A start-time secret and a posted one are in base_state.json and in GET at once since update_secrets saves the registry; F08's summary line and an F21 gotcha still said they wait for the next save. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
This comment has been minimized.
This comment has been minimized.
On a resume the constructor fills the registry from the agent's context secrets, through update_secrets. That call now saves the state. When the conversation was opened under a key that cannot decrypt it (a changed OH_SECRET_KEY without the previous one listed), the context secrets are still cipher text and every other credential reads as unset, so the save wrote that over base_state.json: the agent's LLM key was gone for good, also after the right key was restored. On main the same load wrote nothing. A context secret that is still cipher text, or a StaticSecret left without its value, is no longer filled in. It was never a usable value, and without the fill the load does not save. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
S21.masking covers a secret added after the ACP session started, with its unit test. F08.secrets-restart no longer speaks of a secret 'that reached base_state.json': every runtime secret does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
…iled decryption The check that keeps an undecrypted context secret out of the registry ran on every construction. A new conversation whose agent carries a secret that happens to start like cipher text, or a StaticSecret without a value, would no longer have registered it. Only an agent loaded from base_state.json can hold values that failed to decrypt, so the check now applies to that case alone, and a caller's own agent is taken as given. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
…dual-source-truth-qp1x6r-1-secrets-autosave
main now writes a state change made while a step waits on its model to base_state.json immediately, so the note that such a change waits for the end of the step no longer holds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
With #5776 in main a run no longer keeps a deferred save open across the model call, so update_secrets() writes base_state.json before it returns in the middle of a step too. On main the secret is changed in place and the test fails with an empty saved registry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
… texts update_secrets replaces the registry object. The stream masker of a running step and the Codex credential lifecycle keep the object they started with, and stay correct only because model_copy shares the masking cache. A test now holds that: with a fresh SecretRegistry in update_secrets it fails with the rotated value printed in clear. The comment on the ACP bridge's masker said it was set per turn to the registry's bound method; it is bound once and reads the current registry. The S04 map says when a secrets change is written if the call is made on the run loop's own thread. mapping.md's example of a known-bug label named a bullet that is no longer one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
…dual-source-truth-qp1x6r-1-secrets-autosave
|
I re-ran the failed job once. A possible fix for the test, as a separate change: assert the order of delivery ( Generated by Claude Code |
…dual-source-truth-qp1x6r-1-secrets-autosave # Conflicts: # openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py
⏳ Review waiting on checksThe current head
No action is needed. The scheduled scan retries once every check on the head reports a conclusion. This is an automated check - no AI was used to generate this comment. |
Agent-server conversation start benchmarkBase
How this is measuredEach create is a Canvas-shaped
A timing is flagged when the 95% CIs do not overlap and the medians differ by at least 50 ms, or when a row with at least 8 samples per side moves by at least 150 ms and 25%. A create stalled the server when its slowest |
HUMAN:
Engel Nyst asked me to find the fork PR that removes the two sources of truth for a conversation's settings (
meta.jsonin the agent-server andbase_state.jsonin the SDK), which is #4813 by @BSmick6; to put its commits on branches in this repo, split so that each concern can be reviewed on its own; and to open new PRs that credit the author and say that we do the final review and tweaks. Then to review each PR, address what the review finds, and prove that the changes work by running the SDK and the agent-server the way a program or an agent does, with the repo'sverify-sdkandverify-agent-serverskills. The principle behind the request: the agent-server is a REST interface to the SDK. It should not be a different thing, and it should not repeat what the SDK already does, unless a particular case gives a special reason.This is part 1 of 3: the SDK saves secrets to
base_state.jsonthe moment they change.AGENT:
I'm Claude (Fable 5.2), an AI agent working for Engel Nyst. I brought #4813 up to date with
main, split it into a stack of three PRs, reviewed each, and verified them against real servers. The fix in this PR is @BSmick6's, from #4813; the ACP commit comes from Engel Nyst's earlier follow-up on that PR. What this final pass added is at the end of the summary.The stack: 1. this PR → 2. #6763 (a fork keeps the source's policy, analyzer and secrets) → 3. #6764 (the agent-server stops keeping its own copy). #4813's own commits, merged with
mainat56d559f6, are on the branchclaude/openhands-sdk-dual-source-truth-qp1x6rfor reference.Why
LocalConversation.update_secrets()changed the secret registry in place.ConversationStatesaves itself only when one of its fields is assigned, so the new secret stayed in memory:base_state.jsongot it only if something else happened to save the state later. Onmainthat shows up three ways:Conversation(secrets=...),POST /api/conversations) is not inbase_state.json, and the nextGETdoes not list it;This is the SDK half of the issue, and the ground the rest of the stack stands on: once
meta.jsonstops carrying secrets (#6764),base_state.jsonhas to have them every time.Summary
update_secretsupdates a copy of the registry and assigns it, under the state lock, so the state is saved before the call returns (@BSmick6, fix(agent-server): own confirmation_policy, security_analyzer, secrets in ConversationState #4813).Added in the final review:
secret_registrystate update, andstr(event)printed aLookupSecret's secret headers in clear. JSON output (the socket, the event log) was already masked; this closes thestr()path, with a test.mainthat resume writes nothing. With theupdate_secretschange alone it would: the constructor fills the registry from the agent's context secrets throughupdate_secrets, and under the wrong key (a changedOH_SECRET_KEYwithout the previous one listed) that save would write the undecrypted state overbase_state.json, so the agent's LLM key would stay lost after the right key was restored. A context secret of the agent loaded frombase_state.jsonthat is still cipher text, or aStaticSecretwithout its value, is therefore not filled in. A caller's own agent is taken as given. The limits of this are in the notes. (A resume that passes an agent, or another iteration limit, saves onmainand here alike: that assignment is a state change.)verify-sdkS04 secrets recipe, whose program now readsbase_state.jsonright afterupdate_secretsand right afterConversation(secrets=...), and the removal of threeverify-agent-serverknown-bug markers that the proof below retires.maingained fix(sdk): persist state changes made while a step waits on the model #5776. A secret posted from another thread while a step waits on its model is on disk before the call returns. And a registry object held from before an update still masks what is learned after it: a running step's stream masker and the Codex credential lifecycle keep the object they started with, which is correct only becauseupdate_secretsreplaces the registry withmodel_copy(shared masking cache) and not with a fresh object.Issue Number
Part of #4810. The last PR of the stack closes it.
How to Test
Each regression test fails without its change and passes with it. The first two rows are
main; the others are this branch with the named change reverted:test_update_secrets_saves_base_state_before_returning(onmain)assert set() == {'START_TOKEN'}test_secret_posted_during_llm_call_is_persisted_at_once(onmain)assert [] == ['POSTED_MID_STEP']test_live_token_masking_follows_update_secrets_reassignment(newupdate_secrets, old masker)test_update_secrets_keeps_masking_shared_with_a_registry_held_from_before(a fresh registry object inupdate_secrets)assert 'leak: runtime-value' == 'leak: <secret-hidden>'test_secrets_state_update_event_never_carries_a_secret_value(old__str__)str(event)test_load_under_a_key_that_cannot_decrypt_leaves_the_saved_state_alone(fill not skipped)Noneonce the right key is backtest_callers_own_context_secret_is_registered_whatever_it_looks_like(skip applied to every agent)In this section
mainismainat3c66af1d, the commit this branch is merged with. Live, with the repo skills. For the three server bullets every attempt is its own freshly launched agent-server (control-agent-server map run --fresh --repeat 2), two attempts from amaincheckout, then two from this branch. The last row is onesdk-maprun per side, with no server:mainF04.create-secrets-getF08.secrets-visibleF08.secrets-unsaved-restartS04.secrets-update,S04.secrets-constructor(sdk-map run, new checks onbase_state.json)saved_after_updateis[], nothing saved after the constructor eitherxfailmeans the bullet failed with exactly the failure its known-bug marker documents;xpassmeans the documented bug no longer reproduces. The three server bullets were replayed withmain's copy of the map, which still carries their markers, against a server launched frommainand then from this branch (--checkout). This PR removes the three markers, as the skill asks. With this branch's map the same bullets would then reportfailonmainandpasshere, since a bullet without a marker is a plainfailorpass; I did not run that combination separately. TheS04row is this branch's recipe, with its new checks onbase_state.json, run againstmain's SDK and against this branch; from amaincheckout that bullet passes, becausemain's recipe does not readbase_state.json.On this branch's final commit (
ad341922), the two SDK map families:S04local conversation (SDK map)S04.factorylabelled blocked in the mapS13security and confirmation (SDK map)S13.confirm-approve-reject,S13.llm-analyzerlabelled blocked in the mapThe whole agent-server families (
F04,F08,F10,F12,F31) and the client entry points were replayed on the top of the stack, which contains this commit; that table is in #6764.GitHub CI on
ad341922: all 52 checks that ran are green. One job,agent-server-tests, needed its one re-run: a timing test this PR does not touch failed once while the runner stalled (the comment on this PR has the details). Two checks are skipped by design: the macOS matrix placeholder, and the description check, which waits for the PR to leave draft.Type
Notes
secret_registry, as policy and analyzer changes already do. I captured the frame on a live server from this branch's final code: names and kinds, with values and secret-lookingLookupSecretheaders masked as**********.GETlists the same names and kinds, with the value asnulland without the secret-looking header. No plaintext and no cipher text in either.mainnow and this branch is merged with it; the second row of the table above is the test for it: a secret posted from another thread during the model call is read back frombase_state.jsonbefore the call returns. One case is still deferred, as for every other state change: a call made on the run loop's own thread inside a step (an event callback, or a tool under a synchronousrun()) is written when that step ends.secrets=and a laterupdate_secretsnow save, where onmainthey did not (any other state change saves there too, and loses what could not be decrypted). The agent-server passes itsmeta.jsonsecrets on every load until fix(agent-server): one owner for confirmation_policy, security_analyzer and secrets (base_state.json) #6764, which removes that path. Cipher text is recognized by itsgAAAAAprefix, so on a resume without an agent a real context secret that starts that way is skipped as well; a registry saved with this PR already holds such a secret, so this only shows on a conversation thatmaincreated and has not saved since.meta.jsoncopy on load. fix(agent-server): one owner for confirmation_policy, security_analyzer and secrets (base_state.json) #6764 removes that copy.meta.jsoncopies as creation-time seeds). This stack removes those copies instead, so fix(agent-server): persist secret, policy and analyzer changes in base_state #5788's server half is not needed if the stack lands; its SDK test and its feature-map wording are carried here.🤖 Generated with Claude Code
https://claude.ai/code/session_013ArwwMuszm1Nt9r2whddpY
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:6d9b169-pythonRun
All tags pushed for this build
About Multi-Architecture Support
6d9b169-python) is a multi-arch manifest supporting both amd64 and arm646d9b169-python-amd64) are also available if needed