Repository navigation
fix: keep fake-claude sessions running while they answer queued messages - #85
Merged
Merged
Conversation
fake-claude answers each user turn that arrives during another as a turn of its own, but its result didn't say any were waiting. fctl-agent keeps a session running while a result's queued_turn_count is above 0, as Claude Code sets it, so dev sessions showed idle while fake-claude answered a message sent during a turn. Each result now counts the user turns read from stdin that haven't started. A test drives the binary with three turns at once. Refs #63
kalaspuff
deleted the
fctl/41-can-you-fix-https-github-com-hyperstruct
branch
October 18, 2026 17:56
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.
In
cargo xtask dev, when a message reached fake-claude while it was on a turn, the session showed idle while fake-claude answered it. After aresult, fctl-agent keeps a session running whenqueued_turn_countis above 0; Claude Code sets it to the sends still waiting in its command queue. fake-claude answers each waiting message as a turn of its own, but itsresultdidn't carry the field, so the session went idle after the first answer and stayed idle through the next.Now every
resultfake-claude writes, errors included, carriesqueued_turn_count: the user turns it has read from stdin but not started. Its stdin thread counts a user turn before handing it to the main loop, and the main loop takes it off the count when the turn starts, so the count never drops below zero. The Claude Agent SDK has the field on bothSDKResultSuccessandSDKResultError. fake-claude's module docs anddocs/development.mddescribe it. fctl-agent already reads the field, so nothing that ships to hosts or the control plane changes.Verification
A new test,
crates/fake-claude/tests/stream_json.rs, runs the binary, writes three user turns at once and checks that the three results report 2, 1 and 0 turns waiting. Without the fix it fails ([Null, Null, Null]). It passed 60 runs out of 60, with six running at once on four CPUs.cargo xtask checkpasses.cargo xtask dev, both cases from the issue. These are fromfctl logs playground#N --json, with the stream events left out.A message during a
slowturn:A message during a
limitpause, which fctl-agent sends right after its own message when the limit resets:In the issue's transcript,
status idlecame between the two answers.I also sent an interrupt during a
slowturn while a message waited. The interrupted turn's result reported 1, fake-claude answered the message, and only then did the session go idle.Fixes #63
Session: https://app.fctl.sh/s/ses_01M5812AZVE1SRP1DD44H02EG8