feat: auto-escalate stalled sessions with structured metadata#1209
Merged
corvid-agent merged 4 commits intomainfrom Mar 18, 2026
Merged
feat: auto-escalate stalled sessions with structured metadata#1209corvid-agent merged 4 commits intomainfrom
corvid-agent merged 4 commits intomainfrom
Conversation
…endpoint When a direct-process session terminates abnormally (stall_repeat, stall_same_tool, max_iterations, or excessive low-quality responses), the result event now includes structured EscalationInfo with the original prompt, completed tool call log, stall reason, and suggested next model tier. Adds POST /api/sessions/:id/escalate endpoint that creates a work task from a stalled session, retrying the original prompt at a higher tier. - Add EscalationInfo type to process/types.ts - Build escalation metadata in direct-process.ts on abnormal termination - Track tool call log for escalation context (capped at 20 entries) - Add escalate endpoint to session routes with stall validation - 12 tests covering all termination reasons, tier inference, and edge cases Refs #1020 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Document EscalationInfo, BuildEscalationInput, buildEscalationInfo in process specs to fix spec:check --strict warnings - Add escalate endpoint to routes spec - Add 6 tests for POST /api/sessions/:id/escalate covering 503, 404, 400, 201, and 500 paths to satisfy codecov/patch - Check off manual test items in PR description Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add c8 ignore comments for integration-level process loop internals in direct-process.ts that cannot be unit tested (tool call logging, escalation info wiring inside startDirectProcess). Add test for escalate endpoint with empty body to cover the default modelTier fallback path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract inline integration code into testable helpers (trackToolCall, buildResultEvent) and add unit tests. Reduces uncovered new lines in the codecov/patch check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
EscalationInfoto the result event when direct-process sessions terminate abnormally (stall_repeat, stall_same_tool, max_iterations, or excessive low-quality responses)POST /api/sessions/:id/escalateendpoint to create a work task from a stalled session at a higher model tierTest plan
buildEscalationInfocovering all termination reasons, tier inference, prompt truncation, and edge casesbun x tsc --noEmit --skipLibCheck)POST /api/sessions/:id/escalateon a stalled session and verify work task creationRefs #1020
🤖 Generated with Claude Code