Skip to content

Interrupted assistant messages retain non-error finish value (orphan tool-input-start abort) #33687

Description

@chenhaipeng

Bug

When an LLM stream is interrupted after tool-input-start but before tool-call or step-finish arrives, the assistant message is left in an inconsistent state:

  • assistantMessage.error is set correctly
  • Tool parts are correctly marked error / Tool execution aborted / interrupted
  • But assistantMessage.finish is never updated — it retains whatever value it had before the interruption (often undefined in real sessions, or the initial fixture value)

This causes downstream consumers (continuation loops, session exports, UI) to misinterpret the aborted message — either treating it as still in-progress (no finish) or as successfully completed (stale finish value).

Root cause

In packages/opencode/src/session/processor.ts, the halt() function handles terminal errors. The ContextOverflowError + non-auto-compaction branch already sets finish = "error" (line 929), but the general terminal branch that handles all other errors (abort, provider failure, etc.) only sets error without setting finish.

Expected behavior

An assistant message that terminates via halt() should always have finish set to "error", consistent with the existing ContextOverflowError path.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions