Repository navigation
feat(rpc): a thread call carries its chain count and meets the user's threads.chainCountLimit (S32, #5899) - #5923
Merged
Conversation
… threads.chainCountLimit (S32, #5899) RPC prompt, steer and follow_up accept chainCount, the hop count of a thread call from another session. It is admitted with admitChainCall() against the user's threads.chainCountLimit before admission records anything: unset means unlimited (no default cap, no cost limit); past the limit the input is refused with errorCode chain_count_limit and errorData { count, limit }. An admitted count reaches the input extension event as chainCount so the next thread call can carry one more. Fixes #5641 Fixes #5899
This was referenced Nov 5, 2026
…ng or admitting it (#5923 review) The chain count check moves into admitInputChain() (modes/rpc/chain-admission.ts) and runs first in connection-handler for prompt, steer and follow_up, so a run hold can no longer keep an over-limit thread call as a notice. A terminal's session-control endpoint cannot carry the hop count through its text-only admission and now refuses chainCount with unsupported_field instead of admitting it with no limit. The regression test runs every refusal through each entry; a mutant per entry fails only that entry's rows.
…e chain limit (#5935) The RPC boundary only shape-checks a command, so a chainCount of null, 0, -3, 1.5, "abc" or past the safe-integer range reached admitInputChain unvalidated, never compared above the user's limit, and was admitted onto the input event. admitInputChain now refuses anything but a positive safe integer with errorCode invalid_chain_count and errorData { chainCount } before the limit is read, at every entry (plain RPC, RPC under a hold; the terminal endpoint already refuses chainCount). RED rows per bad value through each entry; a mutant that drops the check fails all 13. Fixes #5935
5 tasks
… the re-head The re-head moved UNSERVED_INPUT_FIELDS into session-control-input-commands.ts, so the fragment's tracker block now names that file instead of the old one.
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 #5641
Fixes #5899
Stacked on #5882 (base
feat/s32-session-plane). Merge #5882 first, then this one. It wires the user-set thread chain count limit (decision K8) where chains are created, which is the part of S32's acceptance that #5882 left unread.What changes
prompt,steerandfollow_upacceptchainCount, a positive integer: the hop count of a thread call from another session. It is 1 for the first call of a chain and one more per hop, and a chain may come back to a session it already visited (A→B→A).handleClientInputadmits such an input withadmitChainCall()against the user'sthreads.chainCountLimit, read from the settings on every call, before admission records anything.errorCode: "chain_count_limit"anderrorData: { count, limit }, and nothing of it runs.inputextension event aschainCount, so a thread call that session sends next can carry one more. Input that is not a thread call has no count.docs/rpc.md(thread chains),docs/extensions.md(event.chainCount), and thedocs/settings.mdrow now says where the limit is read.chainCountis added to the reviewed field lists of the three commands. Their class (drive) is unchanged, because the field can only get an input refused.Tests
packages/coding-agent/test/suite/regressions/5899-thread-chain-count-limit.test.tsuses the real settings file through the RPC connection handler:chain_count_limitand{ count: 3, limit: 2 }forprompt,steerandfollow_up, and noinputevent fires.inputevent fails the 2 admission cases.bun run check, knip, changelog gate against the stack base, 79 tests passed across the new test and the RPC input suites (5776-*, client-message ledger, external admission, method-class table, session-plane).Summary by cubic
Makes thread calls from other sessions carry their hop count and enforces the user's
threads.chainCountLimitwhere chains are created (the RPC input admission), the part of S32 acceptance #5882 left unread.prompt,steer, andfollow_upnow acceptchainCount(1 for the first call, one more per hop, a chain may revisit a session).admitInputChain()checks the count against the setting read on every call before anything of the input is recorded or held: unset admits any length with no default cap, and past the limit the input is refused with the typed reasonchain_count_limitanderrorData: { count, limit }without any of it running. AchainCountthat is not a positive safe integer is refused first witherrorCode: "invalid_chain_count"anderrorData: { chainCount }, since the RPC boundary only shape-checks a command and a malformed count would never compare above the limit. The check runs before a run hold can keep an over-limit call as a notice, and a terminal's session-control endpoint refuseschainCountwithunsupported_fieldbecause its text-only admission cannot carry a hop count. An admitted count reaches the session'sinputevent aschainCount, so a thread call that session sends next carries one more; input that is not a thread call has no count. Includes a regression suite that exercises the real settings file through every entry — a plain RPC connection, a held run, and the terminal endpoint — plus updates todocs/rpc.md,docs/extensions.md,docs/settings.md, the method-class reviewed-field lists, and the changelog fragment.Written for commit 6ca0e99. Summary will update on new commits.