Repository navigation
Description
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
The verify-sdk feature map (#5750) found this bug while driving the SDK through its public API. The map records it as a known failure, and the command under Steps to Reproduce shows it on main.
Is there an existing issue for the same bug?
- I have searched existing issues and this is not a duplicate.
Bug Description
When the first lookup of a LookupSecret happens while a tool observation is being masked (ToolDefinition.__call__ → mask_secrets_in_model), the conversation's state lock is still held during the HTTP request. The secrets service answers by calling back into the conversation (update_secrets), which waits on that lock, so the request blocks until httpx's 30 s timeout. The lookup fails, the back-off skips the secret, and its value is left in clear text in the observation the model and event log see. The same lookup triggered while masking an agent message is masked and takes 0.1 s.
Expected Behavior
Both values are masked (the values are <secret-hidden> and <secret-hidden>) in well under a second, whichever event triggers the first lookup.
Actual Behavior
async.tool_step.messages.0 is the values are loop-val and <secret-hidden> and the step takes 30.5 s.
Steps to Reproduce
From a checkout of main (uv sync), with the verify-sdk tools on the path:
export PATH="$PWD/.agents/skills/verify-sdk/scripts:$PATH"
sdk-map run --file S13 --only S13.mask-asyncThat runs this recipe from the map (each control-sdk call runs a short program in its own HOME, persistence and workspace):
export SDK_VERIFY_RUN=$(control-sdk new --field run)
control-sdk program S13/secrets_run --arg async \
--check async.message_step.status eq finished \
--check async.message_step.messages.1 eq "the values are <secret-hidden> and <secret-hidden>" \
--check async.message_step.seconds lt 10 \
--check async.tool_step.status eq finished \
--check async.tool_step.messages.0 eq "the values are <secret-hidden> and <secret-hidden>" \
--check async.tool_step.seconds lt 10Acceptance Criteria
- No secret lookup runs while the state lock is held, or the service callback does not need that lock.
- A value whose lookup fails is never written unmasked into an observation.
- A test covers a lookup first triggered by masking a tool observation under
arun(). - The
S13.mask-asyncbullet in.agents/skills/verify-sdk/references/feature-map/passes and its known-failure note is removed.
Installation Method
uv sync in a checkout of main
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
Confirmed by code inspection of main: arun() holds the conversation state lock across the awaited step (local_conversation.py), and ToolDefinition.__call__ (openhands/sdk/tool/tool.py) masks the observation via SecretRegistry.mask_secrets_in_model → mask_secrets_in_output, which resolves uncached LookupSecret sources with a blocking HTTP request. When that lookup's response is produced on the same event loop, the responder's conversation.update_secrets() waits on the state lock held across the step, the request stalls to httpx's 30 s timeout, the lookup fails, and the back-off (FAILED_LOOKUP_RETRY_SECONDS) leaves the resolved value unmasked in the emitted observation. Agent-message masking already avoids this by masking under _released_state_lock_during_io() with a registry re-scan loop — the established pattern.
Scope: fix the tool-observation masking path under arun() so a lookup first triggered there cannot stall on the state lock and cannot write an unmasked resolved value into the observation, plus a regression test and removal of the known-failure note. Non-goals: no change to LookupSecret HTTP semantics or the 30 s client timeout; no change to the failed-lookup back-off window or its contract; no least-privilege secret scoping (deferred to #1039); no change to the sync run() path beyond whatever the shared masking code needs; no public API, serialization, or persisted-event-format changes.
Acceptance Criteria
- The
S13.mask-asyncverification recipe (.agents/skills/verify-sdk/programs/S13/secrets_run.py --arg asyncviacontrol-sdk, as documented in.agents/skills/verify-sdk/references/feature-map/S13-security-confirmation.md) passes onmain: bothasync.message_stepandasync.tool_stepreportstatus eq finished, masked messagesthe values are <secret-hidden> and <secret-hidden>, and step durations under 10 seconds. - With a
LookupSecretresolved duringarun(), no secret-lookup HTTP request runs while the conversation state lock is held across the step, orupdate_secrets()no longer needs that lock: an event-loop-served lookup completes without waiting for a 30 s timeout (observable as tool-step duration well under the httpx timeout and noTransient error retrieving secretwarning from the stalled request). - When masking a tool observation resolves a
LookupSecretunderarun(), the value returned by that lookup does not appear in any emitted observation or message event visible to the model or the event log (checked throughconversation.state.events). - A genuinely failing lookup during tool-observation masking preserves the existing failure contract: no exception escapes masking, other secrets still mask, and the source is retried at most once per back-off window (existing behavior in
tests/sdk/conversation/test_secrets_manager.pyremains passing). - A regression test covering a lookup first triggered by masking a tool observation under
arun()is added totests/sdk/agent/test_async_secret_masking.pyand passes viauv run pytest tests/sdk/agent/test_async_secret_masking.py. - The known-failure note for
S13.mask-asyncin.agents/skills/verify-sdk/references/feature-map/S13-security-confirmation.mdis removed and the bullet no longer lists the tool-observation case as a failure. - No public Python API, serialized event, or persisted-conversation format changes; existing tests in
tests/sdk/continue to pass.
Activity