diff --git a/docs/subsystems/claude-subscription-bridge.md b/docs/subsystems/claude-subscription-bridge.md index 0bba11287..29d118c39 100644 --- a/docs/subsystems/claude-subscription-bridge.md +++ b/docs/subsystems/claude-subscription-bridge.md @@ -121,7 +121,8 @@ answered: on a real account, 4 runs of 8 wrote it after its MCP call returned. The call can only be answered by the client, which hasn't been told of it. So in an interactive run, `mcpCall` hands each call to the reader (`run.onCall`). Not shown from the transcript within `callFirst` -(1s), the call is a reply of its own: a message with that one `tool_use` +(500ms; a message written before its call is read 118 to 162ms after +it), the call is a reply of its own: a message with that one `tool_use` (Claude Code makes its MCP calls one at a time, a message's parallel calls too). The first message written after such a call is the one that made it. Its rows are left out (`lateID`), and its usage is told with the diff --git a/internal/gateway/claude_subscription.go b/internal/gateway/claude_subscription.go index 0a1370f65..c7041a63e 100644 --- a/internal/gateway/claude_subscription.go +++ b/internal/gateway/claude_subscription.go @@ -2847,8 +2847,11 @@ var unstreamedQuiet = 300 * time.Millisecond // callFirst is how long a call of a client's tool in Claude Code's // interactive mode waits for its message in the transcript before the call -// tells the client itself (readOutput). -var callFirst = time.Second +// tells the client itself (readOutput). A message written before its call +// was read 118 to 162ms after the call came in (8 calls on a real account), +// so half a second leaves it room and makes a late message cost half as +// long as it did at 1s. +var callFirst = 500 * time.Millisecond type cliUsage struct { Input int `json:"input_tokens"`