fix: Improve handling for streams that end without a finish reason - #47079
fix: Improve handling for streams that end without a finish reason#47079amelvil2-ford wants to merge 2 commits into
Conversation
Added plugin hook finish.chunk so that plugins that e.g. add providers can add custom handling if needed.
|
The following comment was made by an LLM, it may be inaccurate: Based on the search results, I found several potentially related PRs that address similar stream handling issues:
These PRs appear to address related concerns around stream termination and finish reason handling. PRs #43881 and #40965 are particularly relevant as they directly deal with streams ending without finish reasons. You may want to review these to ensure the new approach in PR #47079 doesn't duplicate existing logic or conflict with previous fixes. |
Issue for this PR
Closes #45315
Type of change
What does this PR do?
With this change, opencode will no longer end up in a loop when a stream ends without a finish reason
I also added a plugin hook
finish.chunkso that plugins that e.g. add providers can add custom handling if needed.How did you verify your code works?
I tested it with my chaos testing openai compatible API that emits a stream that ends without a finish reason.
Checklist
If you do not follow this template your PR will be automatically rejected.
Sample plugin code
To try this out, add this to
.opencode/plugins/main.tsE.g. if you are running opencode in
~/someDirectory, this goes insomeDirectory/.opencode/plugins/main.ts