This repository was archived by the owner on Apr 26, 2026. It is now read-only.
Fix Claude stream finish handling and add effort passthrough#6
Open
simonseo wants to merge 2 commits into
Open
Fix Claude stream finish handling and add effort passthrough#6simonseo wants to merge 2 commits into
simonseo wants to merge 2 commits into
Conversation
pm0u
pushed a commit
to pm0u/opencode-claude-code-plugin
that referenced
this pull request
Apr 7, 2026
Cherry-pick useful parts from unixfox#6: - Pass OpenCode effort/reasoning variants through to Claude CLI via --effort - Scope session keys by effort level so different variants get separate sessions - Include cache tokens (read + creation) in inputTokens and populate cachedInputTokens for accurate token reporting via buildUsage helper Omits the PR's finishReason/usage restructuring which emits non-standard shapes incompatible with OpenCode's AI SDK consumer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pm0u
pushed a commit
to pm0u/opencode-claude-code-plugin
that referenced
this pull request
Apr 7, 2026
OpenCode uses @ai-sdk/provider v3, which changed finishReason from a
plain string ("stop") to an object ({ unified: "stop", raw: undefined })
and usage from a flat structure to nested inputTokens/outputTokens
objects. With v2 shapes, OpenCode never saw a valid finishReason on
assistant messages, so its agentic loop never broke — causing infinite
empty turns after every response.
- Upgrade @ai-sdk/provider to v3.0.8, @ai-sdk/provider-utils to v4.0.23
- Emit v3-compatible finishReason and usage in all stream/generate paths
- Filter empty text blocks from outgoing messages (defensive measure for
anthropics/claude-code#41729)
- Return early with finished stream when no user content is present
Partially based on unixfox#6 which
correctly identified the v3 shape requirements.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pm0u
pushed a commit
to pm0u/opencode-claude-code-plugin
that referenced
this pull request
Apr 7, 2026
Emit cacheCreationInputTokens under providerMetadata.anthropic so OpenCode can display cache write tokens in its cost/token UI. Also restructures providerMetadata on finish events to use buildProviderMetadata helper for consistent formatting. Completes the remaining piece from unixfox#6. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--effortVerification
npm run buildnpm run typecheckopencode run --pure -m claude-code/opus --variant low hi --print-logs --log-level INFOshowed--effort lowin Claude CLI args and completed in one turn