Skip to content

feat: error-interception-middleware (3/3) - #30

Closed
myk1yt wants to merge 11 commits into
pr/b02-error-runtime-v2from
pr/b03-error-integration-v2
Closed

feat: error-interception-middleware (3/3)#30
myk1yt wants to merge 11 commits into
pr/b02-error-runtime-v2from
pr/b03-error-integration-v2

Conversation

@myk1yt

@myk1yt myk1yt commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Stack Position

Description

Full Feature Description

  • Feature Branch: feat/error-interception-middleware
  • Feature Name: Error Interception Middleware
  • Purpose: Resolves the problem where errors occurring at tool, parser, validation, and provider boundaries are delivered only as unstructured strings, causing the model to repeat the same incorrect call or leaving users unable to determine the cause and recovery method. Classifies errors into stable categories, retry policies, and occurrence-aware recovery dispositions without losing the original error, converting them into structured recovery guidance.
  • Full Change Description: B01 defines the classification category, signal, result, pattern priority, and guidance payload contracts. B02 adds the interception runtime that validates and transforms classifier results and manages task-scoped occurrence/error state. B03 connects this runtime to assistant-message presentation exactly once, showing recoverable messages to both the user and the model.
  • Impact Scope: Affects all of src/core/tools/error-interception and the final integration point presentAssistantMessage.ts. Maintained as an internal middleware boundary without changing public provider/tool contracts.
  • Errors and Edge Cases: Unknown errors are treated as UNCLASSIFIED while preserving the original text and cause. On transformation or structural validation failure, falls back to the original error. If presentation itself fails, interception is not recursively invoked. Repeated occurrences of the same fingerprint escalate to correct_once, change_strategy, await_user, etc. based on occurrence count, without producing duplicate messages. Metadata does not include sensitive values such as commands, absolute paths, or raw arguments.
  • Testing Method: Run B01's category precedence, known/unknown classification, and redaction tests, B02's transformation/validation/state reset/recursion tests, and B03's one-time integration and legacy behavior regression tests. Manually trigger known tool errors and unclassified errors respectively, verifying that structured guidance is shown only once and that original technical information and the normal task error path are preserved.

Why Split Into 17 PRs

Instead of submitting this feature as a single unified PR, it was split into individual PRs because as code size grows, safely reviewing a PR becomes very difficult. The feature was broken into mutually exclusive individual PRs so that each can be reviewed independently.

What This PR Specifically Changes

Connects the interception runtime to presentAssistantMessage.ts. Generates a structured recovery message only once per error, preserving normal assistant content and the legacy error path.

Included Files

  • src/core/assistant-message/presentAssistantMessage.ts
  • src/core/assistant-message/__tests__/presentAssistantMessage.error-interception.spec.ts

Exclusion Scope

  • New classifier/runtime primitives
  • Duplicate changes to B01/B02 implementations
  • Unrelated rendering changes to normal assistant content
  • All items in the common removal rules

Comment thread src/core/assistant-message/presentAssistantMessage.ts Fixed
Comment thread src/core/assistant-message/presentAssistantMessage.ts Fixed
@myk1yt myk1yt changed the title B03: Error Integration v2 feat: error-interception-middleware (3/3) Aug 3, 2026
Zoo (VP) added 3 commits August 3, 2026 17:55
# Conflicts:
#	src/core/tools/error-interception/ToolErrorInterceptor.ts
…and is_error in tool error results

formatStructuredError hardcoded retryable/occurrence/disposition for every
error, telling the model that terminal failures (e.g.
TERMINAL/PROVIDER_SWITCH/003) were first-occurrence retryable errors and
encouraging retry loops.

- derive retryability from the error: terminal/shell/provider-switch
  machine codes, validation errors, and user rejections are non-retryable
- count per-task occurrences of identical failures via TaskErrorState and
  escalate disposition to change_strategy at the stuck-loop threshold
  (await_user for user rejections)
- mark handleError tool_results with is_error, matching the sibling error
  paths (validation, rejection, missing nativeArgs, unknown tool)
- emit slash-free dotted type strings and keep <error_details> JSON valid
  under byte-limit pressure instead of truncating mid-document
- show a concise human message in say("error") instead of the full JSON
  blob; the structured payload stays in the tool result only
@myk1yt
myk1yt force-pushed the pr/b02-error-runtime-v2 branch from 99ac95e to de697f4 Compare August 4, 2026 11:39
@myk1yt
myk1yt force-pushed the pr/b03-error-integration-v2 branch from 7d7b5a8 to 3d8aa5b Compare August 4, 2026 11:40
@myk1yt
myk1yt force-pushed the pr/b03-error-integration-v2 branch from 2ed042e to d679650 Compare August 6, 2026 19:59
@myk1yt
myk1yt force-pushed the pr/b02-error-runtime-v2 branch from b27c707 to 367d4b6 Compare August 6, 2026 20:02
Zoo (VP) and others added 3 commits August 7, 2026 10:03
* refactor(types): canonicalize provider settings identifiers

* refactor(cli): canonicalize provider identifiers

* refactor(cli): extract option resolution helpers

* test(cli): cover run option resolution

* fix(cli): resolve specialized provider model IDs
)

* refactor: reuse shared API test options

* chore: rerun CI

---------

Co-authored-by: Roomote <roomote@roomote.dev>
@myk1yt
myk1yt force-pushed the pr/b03-error-integration-v2 branch from eb6d4b4 to 9bd28d1 Compare August 7, 2026 04:11
@myk1yt
myk1yt deleted the branch pr/b02-error-runtime-v2 August 7, 2026 13:05
@myk1yt myk1yt closed this Aug 7, 2026
@myk1yt
myk1yt deleted the pr/b03-error-integration-v2 branch August 7, 2026 13:05
@myk1yt
myk1yt restored the pr/b03-error-integration-v2 branch August 7, 2026 13:32
@myk1yt myk1yt reopened this Aug 8, 2026
…gration test (PR Zoo-Code-Org#1128)

CI failure: Code QA Roo Code run 31224455758 failed @roo-code/vscode-e2e#lint
with 2 errors (@typescript-eslint/no-require-imports) and 2 warnings (unused
no-var-requires directives). Same legacy-rule-name issue as PR Zoo-Code-Org#1126.
Run: https://github.com/Zoo-Code-Org/Zoo-Code/actions/runs/31224455758
@myk1yt

myk1yt commented Aug 10, 2026

Copy link
Copy Markdown
Owner Author

Closing to recreate with main as target base branch. This PR had stale base branch references after fork sync.

@myk1yt myk1yt closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants