Skip to content

Provider-turn failures can leave assistant scaffolds unfinished #38431

Description

@iandraves

Description

The legacy prompt loop persists an empty assistant message before creating its processor. Existing cleanup handles interruption, but another failed Effect exit during processor creation or ordinary provider-turn setup and execution can propagate while leaving the committed message without an error or completion timestamp.

For an ordinary provider turn created by the current run, the failure boundary should begin at the persistence call. A failed exit should attempt to finalize that run's exact persisted assistant message, if present, without replacing the original failure. Cleanup should preserve any existing error and finish value.

This is process-local cleanup only. It does not scan existing history or recover process crashes, compaction turns, subtasks, cross-process work, or turns created by another run.

Plugins

None

OpenCode version

Current dev at 411eff73

Steps to reproduce

  1. Create a session and persist a user message.
  2. Run SessionPrompt.loop() with a SessionProcessor whose create() defects.
  3. The defect propagates, but the assistant scaffold remains persisted with no parts, error, finish, or time.completed.

Expected: the original defect still propagates, while the persisted scaffold records an error and completion timestamp. finish remains unchanged.

Screenshot and/or share link

Not applicable

Operating System

macOS

Terminal

zsh

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