Fix control_response request_id check — read from nested response (closes #975)#977
Merged
Conversation
…oses #975) Real claude-code (verified against 2.1.120) emits control_response with request_id nested under response, not at the top level: {"type": "control_response", "response": {"subtype": "success", "request_id": "..."}} Fido's _send_control_set_model checked obj.get("request_id") at the top level. That always returned None, the predicate never matched, and every switch_model call hung until the subprocess was killed. Verified by direct probing of the claude subprocess and by grepping fido.log: switch_model: now on model= (the post-success log line) appears zero times across the entire log; switch_model: ... (control_request) appears 9 times. Every one of those 9 calls hung. The 5-minute home gap at 15:40:23-15:45:23 in fido.log shows the hang concretely. Plus updates the existing test fixtures, which had the wrong shape too — tests passed against the broken code because both used top-level request_id. Adds a regression test that explicitly emits a malformed top-level shape and asserts it is NOT matched, then a correct nested shape and asserts it is.
rhencke
approved these changes
Apr 25, 2026
This was referenced Apr 25, 2026
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.
Fixes #975.
Real bug
Probed the actual claude-code subprocess (
claude --version→ 2.1.120). Itscontrol_responseshape is:{"type": "control_response", "response": {"subtype": "success", "request_id": "..."}}request_idis nested underresponse. Fido's_send_control_set_modelcheckedobj.get("request_id")at the top level. Always None. Predicate never matched. Everyswitch_modelcall hung until the subprocess was killed.Proof
Zero successful returns. Nine attempts. Every one hung. Concrete trace:
[home] switch_model: opus → haiku[home] worker started(fresh thread post-fido-restart)The session was wedged the entire window. Same shape across every
switch_modellog line in the file.Why fido seemed to work anyway
Many
switch_modelcalls are no-ops (target == current model) and return at line 1102 before sending the control_request — so sessions that didn't need an actual model change kept working. The 15:40:30 webhook test that succeeded landed on a freshly-booted confusio session that was already on opus from spawn — no switch needed. Bug only fires on real model changes.Fix
claude.py:1023-1028:
Test
Existing test fixtures had the wrong shape too — they put
request_idat the top level, matching fido's broken expectation. Both helpers (TestClaudeSessionSwitchModel._make_response_lineandTestClaudeSessionSendControlSetModel._make_response_line) updated to emit the real nested shape.New regression test
test_ignores_top_level_request_id_in_control_responseexplicitly emits a malformed top-level placement first, then the correct nested one — asserts the malformed one is skipped and the wait completes only on the nested response. This catches any future regression that re-introduces top-level lookup.All 264 claude tests pass.
Related