Skip to content

fix(core): preserve the first terminal failure#37705

Merged
kitlangton merged 1 commit into
v2from
simplify-malformed-tool-recovery
Jul 19, 2026
Merged

fix(core): preserve the first terminal failure#37705
kitlangton merged 1 commit into
v2from
simplify-malformed-tool-recovery

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Preserve the first causal assistant failure while concurrent tool fibers settle, and remove malformed-input event fields that no production consumer reads.

Before / After

Before: A provider failure could be recorded first, then overwritten by a later tool-output persistence failure because every terminal cleanup path forced failAssistant(..., true). Durable history reported the cleanup error instead of the provider error that ended the step.

After: failAssistant is write-once. Later interruption, persistence, or missing-hosted-result cleanup still settles tools, but cannot replace the first terminal assistant failure.

How

  • packages/core/src/session/runner/llm.ts stops forcing replacement from terminal cleanup paths.
  • packages/core/src/session/runner/publish-llm-event.ts removes the replacement parameter and keeps the first stepFailure.
  • packages/core/test/session-runner.test.ts covers a provider failure racing with local tool-output persistence failure.
  • packages/ai and the AI SDK adapter remove unused ToolInputError.message and providerMetadata fields while retaining the authoritative raw malformed input.
  • to-llm-message.ts reuses the existing provider-metadata predicate instead of spelling the same condition twice.

Scope

  • Provider-executed malformed calls remain terminal.
  • Local malformed calls remain ordinary failed, unexecuted tool results and continue through the normal agent Step policy.
  • Failed-Step snapshot and file authority remains intact for revert planning.
  • This does not add a separate malformed-call retry budget.

Testing

  • bun run test in packages/ai: 343 passed, 29 skipped.
  • bun run test -- test/session-runner.test.ts test/session-runner-message.test.ts test/session-runner-tool-events.test.ts test/aisdk.test.ts in packages/core: 169 passed.
  • bun turbo typecheck --concurrency=3: 32 tasks passed; the push hook repeated this successfully.
  • bun run lint: completed with existing repository warnings and no new errors.
  • Full Core run: 1,347 passed and 6 skipped. Three unrelated environment/timing cases failed: configured execute, user-level cmux plugins, and the existing location flush timing test.
  • git diff --check: passed.

Flow

flowchart TD
  P[Provider failure] --> F[failAssistant]
  F --> S{stepFailure set?}
  S -- no --> R[Record provider failure]
  T[Concurrent tool settlement failure] --> F
  S -- yes --> K[Keep first failure]
  R --> E[Publish failed Step]
  K --> E
Loading

@kitlangton
kitlangton merged commit ba0bbda into v2 Jul 19, 2026
13 of 14 checks passed
@kitlangton
kitlangton deleted the simplify-malformed-tool-recovery branch July 19, 2026 04:00
github-actions Bot pushed a commit to ReStranger/opencode that referenced this pull request Jul 19, 2026
* upstream/v2:
  mini: fix shell tool output display (anomalyco#37711)
  fix(core): detach disposed MCP registrations from root scope (anomalyco#37660)
  fix(core): preserve the first terminal failure (anomalyco#37705)
  fix(core): continue after malformed tool input (anomalyco#37701)
  fix(core): safely recover malformed tool input (anomalyco#37698)
  fix(simulation): render screenshot symbol glyphs (anomalyco#37691)
  fix(core): authorize relative external paths (anomalyco#37689)
  fix(tui): auto-approve permissions in auto mode
  feat(core): allow MCP Code Mode opt-out (anomalyco#37681)
  fix(codemode): stop leaking undefined into tool arguments (anomalyco#37652)
  fix(tui): style interrupted compaction neutrally (anomalyco#37655)
  fix(cli): harden managed service election (anomalyco#37645)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant