Skip to content

fix(session): set finish status on halted assistant message - #42176

Closed
vladislav-miroshnikov wants to merge 2 commits into
anomalyco:devfrom
vladislav-miroshnikov:compaction-error-finish
Closed

vladislav-miroshnikov wants to merge 2 commits into
anomalyco:devfrom
vladislav-miroshnikov:compaction-error-finish

Conversation

@vladislav-miroshnikov

@vladislav-miroshnikov vladislav-miroshnikov commented Aug 12, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #42070

Type of change

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

What does this PR do?

When the session processor halts due to an error that isn't a ContextOverflow (e.g. an API error from the model), the assistant message gets error set but finish stays undefined. The prompt loop checks finish to decide whether to exit — with it undefined, the loop never terminates and the session appears stuck in compaction.

The fix sets finish = "error" in the non-ContextOverflow branch of halt(), matching what the ContextOverflow branch already does. This is a one-line change in processor.ts.

How did you verify your code works?

Added expect(handle.message.finish).toBe("error") to the existing test "do not retry unknown json errors" which exercises the exact error-halt path. 15/15 tests pass in processor-effect.test.ts, typecheck clean.

Screenshots / recordings

N/A

Checklist

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

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

renekris added a commit to renekris/opencode-lowmem that referenced this pull request Aug 22, 2026
…co#42150 anomalyco#42176 anomalyco#43881 anomalyco#43607)

- O(N) text/reasoning delta accumulation instead of O(N^2) string
  concat (anomalyco#42150) — the lazy chunk buffer joins on read
- finish reason 'error' is set when a stream fails mid-flight (anomalyco#42176)
- clean-EOF empty provider streams retry like transient errors (anomalyco#43881),
  narrowed from the upstream patch: only an attempt that produced no
  text/reasoning delta and no tool call qualifies, so providers that
  stream content but omit usage/finish are not retried into duplicate
  output
- SSE comment heartbeats no longer reset the chunk timeout (anomalyco#43607);
  the streaming TextDecoder handles multi-byte characters split across
  reads (regression covered)
@vladislav-miroshnikov

Copy link
Copy Markdown
Author

Added a regression that saves the failed compaction message, appends a user message, and checks that the failed task isn't selected again. It fails when I remove the finish assignment; the context-overflow case remains retryable.

All 16 processor tests pass (82 assertions), and Prettier passes. Package typecheck reported 7 diagnostics in packages/core; I haven't compared those with the base branch yet.

The new head is 7d630a7. Could you approve its CI runs? Tests, typecheck and nix-eval are waiting for approval.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

[BUG ISSUE]: Agent remains stuck in compaction after usage limit resets

1 participant