[Conformance] Claude Code host: the shim stops waiting for the Guardian at 300 s, whatever timeout was negotiated

Open Beginner friendly
#614 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bun, typescript
Domain
backend, security

Research direction

Start in the Claude Code shim's refimpl/claude-code-read/hosts/claude-code/guardian-client.ts: the fetch at lines 199-206 is bounded only by AbortSignal.timeout(timeoutMs), so Bun's 5-minute socket idle default fires first, and the message at line 218 reports the requested timeout rather than elapsed time. Read instrument §6.4 and hosts/claude-code/settings.json, then reproduce with a stub Guardian that advertises default_ms: 900000 and answers at 360 s. Done means the late-but-in-window decision is honored under both postures and the audit entry states the time actually waited; a unit test that does not need a 360 s wall clock is worth adding.

Written by the indexing model from the issue text.

Description

priority:P1 status:needs-triage type:conformance
What you ran

Claude Code 2.1.325 (claude-opus-5-5, -p, default permission mode) with the Claude Code shim from PR #597 (refimpl/claude-code-read at 201ddb3, on integration d3323ba), Bun 1.3.11 and the shipped hosts/claude-code/settings.json. In place of the reference Guardian I used a stub that answers handshake/hello with timeout_config.default_ms: 900000 and sends each decision 360 s after the request, well inside the negotiated window. The agent reads a file holding the AWS documentation example key. I ran 3 runs per case, with a fresh stub and session each time, and read what reached the model from the API requests that Claude Code records in the session transcript.

What you expected

Instrument §6.4 says the Observed Agent "MUST wait for the Guardian's decision, up to the negotiated timeout", and "When a decision does arrive within the timeout, the agent MUST honor it regardless of the posture." With 900 s negotiated, a decision at 360 s should be applied.

What happened

The shim stops waiting at 300 s and applies the failure posture.

Under deny, with a Guardian that would answer allow, PreToolUse returns a block at 300.05 s and the Read never runs (3/3). The Guardian would have allowed the call.

Under proceed, with a Guardian that would answer deny, PreToolUse returns at 300.05 s with no decision and the Read runs 60 s before the deny arrives (3/3). PostToolUse then gives up at 300.06 s as well and proceeds, so the key is in the next request to the model. The Guardian would have denied the call.

In both cases every audit entry records timeout with "guardianClient.post: no response within 900000ms". That is the negotiated value, not the 300 s the shim actually waited. The message comes from guardian-client.ts:218, which reports the timeout it was given rather than the time that passed.

The 300 s come from Bun's fetch, not from the shim's own timer:

  • guardian-client.ts:199-206 bounds the call with AbortSignal.timeout(timeoutMs) and nothing else;
  • the Bun reference for BunFetchRequestInit.timeout says it controls "the socket idle timeout for this request", with a default of 5 minutes, and "This is not a whole-request deadline; use AbortSignal.timeout(ms) for that";
  • in a standalone Bun 1.3.11 test against a server that never answers, AbortSignal.timeout(900000) alone fails with TimeoutError at 300.0 s, and adding timeout: false lets the call run until a 420 s abort, at 420.0 s (4 runs, 3 of them as separate processes).

The 300 s also run from the handshake's request, not from the step's own start. When a handshake/hello is answered after 4.5 s and the next request on that connection gets no answer, that request fails 295.5 s after it starts, 300.0 s after the hello started (3 pairs, each with its own server, in one process). The Bun reference says the timer "is reset on every byte sent or received", but on 1.3.11 the hello's response and the next request did not reset it. Through the shim, a PostToolUse that has to renegotiate first (session store not writable) still ends at 300.05 s (3/3).

With the default 5000 ms the shim waits the negotiated time. In a replay against a stub that never answers, the hook ends at about 5.07 s and the audit says no response within 5000ms. The gap opens only when a Guardian negotiates more than 300 s. The reference Guardian does not, since it advertises a fixed DEFAULT_TIMEOUT_MS = 5000 (packages/guardian/src/handshake.ts:82) with no setting to change it. Another Guardian can, because handshake.json gives default_ms a minimum of 1 and no maximum.

Related: #434 lists "A timeout or a late response under Claude Code" among the scenarios no run has covered, and these runs cover the timeout half. #435 is about a decision that arrives after the negotiated timeout, while here it arrives inside it. #269 is about the Guardian's OPA deadline, which is a different timer.

Current Priority Scope

Feeds conformance evidence

Dominant language
TypeScript
Stars
183
Forks
56
Avg merge
3d 1h
Merged PRs (30d)
67

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GenAI-Security-Project/agent-control-standard

All issues in GenAI-Security-Project/agent-control-standard

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.