← Back to Pull requests

fix(cli): preserve Runtime outcomes and explicit JSON errors #6171

Closed
unknown closed this pull request without merging on Oct 21, 2026 06:11 UTC
View on GitHub
unknown unknown commented on Oct 19, 2026 11:51 UTC
Author

Summary

After a rejected sandbox expansion, the model can continue within existing permissions or explain the blocker. Previously Session status reported the Runtime's completed, but wait/result overrode it with a generic sandbox failure and discarded the final answer. CLI now preserves the Runtime terminal outcome and original errors; tool failures alone do not change the exit code. The obsolete Session tool-retry matcher is removed. A legacy surface that cannot service an approval still denies it and reports that unsupported operation.

Errors are brief text on stderr by default. Explicit --json returns an error on stdout and preserves the original Host message and code when available. Operation failures do not invent a Session status; terminal task failures retain status: "failed". JSON errors are no longer duplicated on stderr. Successful status/receipts and pending-interaction JSON are unchanged. No cause classification, automatic retries, model switching, or permission changes are added.

Refs #6168. Depends on #6170 (which depends on #6169); base is refactor/cli-run-interface.

Verification

  • Review follow-up 82a7c11c4c: blocking stream errors now retain the created Session ID; the recap child-process harness preserves strict stderr assertions on Node 22.19.0 by disabling runtime ExperimentalWarning only in the test process. Both regressions fail with their prior behavior. 84 affected tests, the real Host integration on Node 22.19.0 and Node 26.12.0, full build/typecheck/lint/format, Desktop/UI Knip, ASF headers and Windows inventory pass. The changelog documents the error-output compatibility change.
  • Real OpenAI official gpt-6-luna follow-up: two Maka Sessions performed parent-coordinated review and cross-review, AskUser, approval/denial, recoverable tool errors, and explicit resume after a real insufficient-credit failure on another route. Deliberate step exhaustion exposed a generic-message fallback hiding an existing Runtime class; follow-up 008bb67dd3 preserves errorClass when no original message exists. 67 targeted outcome/adapter/activation tests and CLI build/typecheck/lint/format passed; direct result now reports tool_step_cap_reached.

  • A separate native AskUser stop/drain issue was reproduced and recorded in #6168. Runtime/Host/storage are unchanged in this stack; this PR preserves the resulting original Host errors and does not attempt to repair Runtime stop ordering.
  • 82 affected tests passed: CLI output/parser, real Host cross-process AskUser/approval, native streaming/recap, Runtime outcome extraction, and live/durable/Graph adapters. Denial assertions now verify the final answer and agreement with status; real provider failures still exit 1.

  • Two regression checks fail against the parent implementation and pass with this change: explicit JSON operation errors and a completed blocking Turn containing a failed tool.

  • Re-read the previous real-model denied-approval Session with the new CLI: both status and result returned completed; result preserved the model's explanation that approval was denied and no file was written. No new model call was needed. A real Host configuration error returned text by default and {sessionId,error,code:"operation_unavailable"} with --json, both exit 1.

  • Full build/typecheck, lint, format, both contribution-guide knip checks, ASF headers, Windows test inventory, skill validation and git diff --check passed.

  • Full repository tests and Electron were not run. CI is dispatched separately because PR CI targets main.
  • AI use

  • No generative tool made a substantive contribution

  • Generative tooling made a substantive contribution
  • Tool(s) and scope: Codex implemented, tested and self-reviewed the CLI, documentation and skill reference at the contributor's request. This does not replace independent human review. Commit includes Generated-by: Codex.

    Checklist

  • Tests cover the change and fail without it

  • Lint, format, typecheck and the affected suites pass locally
  • Does this PR entail a change in behavior?

  • Yes — described under Summary above

  • No
  • Diff: 518 lines (+388 / -130) across 6 files Reviewer: me2seeks Review duration: 2540m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 518 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6171"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.9% · Safe to merge
    18.9%
    Repository