{{ message }}
Repository navigation
fix(claude): stop treating session slug as subagent marker; recover orphaned chains - #281
Open
agnitum2009 wants to merge 1 commit into
Open
agnitum2009 wants to merge 1 commit into
agnitum2009 wants to merge 1 commit into
Conversation
…rphaned chains Claude >= 2.1.x writes the session-name slug on every transcript entry of a named session. structured.py mapped entry.slug to event subagent_name, so is_top_level_user_prompt rejected the job's own anchor user prompt, anchor_seen/prompt_activated never flipped, the exact Stop-hook artifact stayed gated off by _prompt_completion_is_eligible, and the job zombie-ran after its terminal reply. The agent's active-task flag was never cleared, plain ask stayed refused (forced --chain/--silence), and --chain result continuations queued behind the zombie parent were never delivered. - parsing: drop slug from subagent markers; propagate entry.isSidechain as event is_sidechain and honor it in top-level-prompt and assistant identity checks - polling: add _orphaned_exact_hook fallback that accepts the exact hook artifact when session-log anchor tracking failed, gated on req_id match, event timestamp >= accepted_at, a 180s grace, hook/tracked session match, and an observably idle pane, so terminal replies still finalize the job and clear the active-task flag - callbacks/finalization: when a callback edge is already FAILED/TIMED_OUT at child completion, deliver the child result to the dispatching agent (edge.parent_agent) as a notice instead of dropping it silently
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.

Problem
Claude ≥ 2.1.x writes a session-name
slugon every transcript entry once a session gets named (auto or manual).comm_runtime/parsing_runtime/structured.pymapsentry.slug→ eventsubagent_name, so from that point on every main-chain event is mislabeled as subagent activity.Observed failure cascade (live incident, Claude 2.1.220):
is_top_level_user_promptrejects the job's own anchor user prompt →anchor_seen/prompt_activatednever flip in the poll state machine._prompt_completion_is_eligiblethen gates offpoll_exact_hookforever — the exact Stop-hook artifact (written by the provider hook with the job's ownreq_id) is never consumed.plain askrefused (forced--chain/--silence), and a--chainresult continuation queued behind the zombie parent is never delivered — the child result strands on disk.Reproduced deterministically by replaying the affected session transcript through
ClaudeLogReader.try_get_entries+_process_events: anchor missed before the patch,anchor_seen=Trueafter.Fix
slugfrom subagent markers in_event_record(it is the session name, not a subagent marker); propagateentry.isSidechainas eventis_sidechainand honor it inis_top_level_user_prompt/assistant_identityso real sidechain filtering still works via the reliable field._orphaned_exact_hookfallback — when session-log anchor tracking failed, accept the exact hook artifact only with independent proof:req_idmatch (already enforced byload_event), event timestamp ≥accepted_at, 180 s grace elapsed, hook session == tracked session, and an observably idle pane. This un-zombies stuck jobs and lets terminal replies clear the active-task flag.FAILED/TIMED_OUTat child completion,submit_callback_continuationused to return early and silently drop the child result. Newdeliver_orphaned_chain_resultdelivers it to the dispatching agent (edge.parent_agent) as a notice instead.Verification
_orphaned_exact_hookboundary cases (7/7): busy pane, fresh event (< grace), pre-submission event, session mismatch, no pane proof, prompt-not-sent all rejected.deliver_orphaned_chain_resultcases (8/8): notice recorded to dispatching agent with orphan diagnostics and full body; safe on missing bureau/parent.test_claude_comm_parsing,test_claude_hook_results,test_claude_queued_prompt_activation,test_claude_execution_polling,test_v2_ccbd_dispatcher,test_v2_message_bureau_dispatcher_integration— 171 passed.done, and all agents returned to zero open jobs.