Skip to content

fix(opencode): surface and render session defect errors - #42516

Open
DatScreamer wants to merge 4 commits into
anomalyco:devfrom
DatScreamer:fix/concise-session-defect-errors
Open

fix(opencode): surface and render session defect errors#42516
DatScreamer wants to merge 4 commits into
anomalyco:devfrom
DatScreamer:fix/concise-session-defect-errors

Conversation

@DatScreamer

@DatScreamer DatScreamer commented Aug 14, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #42515

Related to #42259.

This is a stacked PR. Its first commit is the propagation work from #42253; the following commits complete the UI fix.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Unexpected session defects were previously lost when the run went idle. This PR contains the complete error path:

  • Publishes session.error from the run loop before the runner transitions to idle.
  • Persists the defect on the assistant message with finish: "error" so the timeline can render it.
  • Uses concise error-message formatting in the UI while retaining the full cause chain in server logs.

The branch also includes the warning propagation and rendering changes from #42253 for failed custom tool loads.

How did you verify your code works?

  • bun run --cwd packages/opencode typecheck
  • Reproduced a missing-workspace defect through the HTTP API.
  • Confirmed session.error arrives before idle.
  • Confirmed the assistant message has finish: "error" and a concise UnknownError message.
  • Confirmed the full cause remains in server logs.
  • Confirmed failed custom tools are skipped and surfaced as warning cards.

PR #39200 contains a broader related assistant-finalization approach based on an older dev state; maintainers can choose to port that approach instead.

Screenshots / recordings

Screenshot

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

agent-harnesses Bot and others added 3 commits August 13, 2026 06:38
…s in the UI

When a session run fails with an unexpected defect, no error reached the UI: the
session just went idle. The real session.error event was published only after the
session.status idle event, so clients that stop consuming on idle never rendered
it. Also, when a custom tool file fails to load, the registry previously died
the whole run instead of skipping it.

- session/prompt.ts: publish Session.Event.Error inside the run loop before the
  runner transitions to idle, so clients that stop on idle still receive the real
  error. Guards against double-publishing errors already surfaced at their source.
- server/httpapi/handlers/session.ts: promptAsync skips die causes (the loop
  publishes those), still publishing typed failures.
- cli/cmd/run.ts: finish() returns the loop's captured error; drain it before
  falling back to the masked body.
- session/tools.ts: surface skipped tools (from the registry) as a session.warning
  event and attach a warning to the assistant message.
- tool/registry.ts: expose a skipped() accessor for tools that failed to load.
- schema: add an optional warning field to Assistant messages and a session.warning
  event.
- app: render tool-load warnings as an inline warning card in the session timeline.

Depends on the registry skip behavior in the companion PR (anomalyco#42252) to populate
skipped().
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one highly relevant related PR:

Related PR:

The other search results show related error-handling PRs (#39200, #42176, #39877) that deal with session/message finalization, but they address different scopes of error handling and are not duplicates of the current PR.

Conclusion: No duplicate PRs found. PR #42516 is a targeted follow-up to #42253 with a specific focus on concise error message rendering for session defects.

@DatScreamer

DatScreamer commented Aug 14, 2026

Copy link
Copy Markdown
Author

PR #39200 overlaps the assistant-message finalization and concise-error portion of this PR through its broader finalizeAssistant implementation. It does not replace the propagation-before-idle or tool-warning work inherited from #42253. This PR remains open as the current-architecture stacked implementation while maintainers choose whether to port #39200's approach.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@DatScreamer DatScreamer changed the title fix(opencode): render concise session defect errors fix(opencode): surface and render session defect errors Aug 14, 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.

Session defect errors are not surfaced or rendered concisely

1 participant