Repository navigation
fix(auto-capture): read tool names from v2-shaped tool parts - #431
Open
Phototonic wants to merge 1 commit into
Open
Phototonic wants to merge 1 commit into
Phototonic wants to merge 1 commit into
Conversation
On OpenCode v2 hosts, session tool parts carry the tool name at part.name (v1 wire format used part.tool). extractAIContent only read tool.tool, so the auto-capture prompt's Tools Used section always listed unknown(). Read name first with the v1 field kept as a fallback, and cover both part shapes with extraction regression tests.
Contributor
Author
|
An independent pre-creation review round ran over the full diff (correctness, contract fidelity vs both SDK tool-part shapes, test coverage, export surface, input budget/truncation). Verdict: APPROVE — no blockers or majors. Only note: a truthy non-string |
Phototonic
marked this pull request as ready for review
October 23, 2026 10:54
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
On OpenCode v2 hosts, the auto-capture summarization prompt always listed tool calls as
unknown(...)in the## Tools Usedsection, degrading memory summaries and tags (#428).Root cause:
extractAIContentread the v1 wire-format fieldtool.tool. On v2 hosts the plugin's legacy adapter (src/v2/legacy-client.ts) passes v2 content parts through verbatim (...part), where the tool name lives atpart.name(v2SessionMessageAssistantToolshape; confirmed against@opencode-ai/sdkv2 gen types and a v2.1.x host's session storage). Tool inputs (state.input) have the same field in both formats, which is why only the name degraded.Fix: read
tool.namefirst, keepingtool.toolas a fallback for v1-wire-format hosts:Also exports
extractAIContentfor direct testing and adds regression tests covering v2-shaped parts, v1-shaped parts, and theunknownfallback.Fixes #428
Test plan
tests/auto-capture-context.test.ts: v2 part{type:"tool", name:"bash", state:{input:{command:"ls"}}}extractsbash(command: "ls"); v1 part withtool:"read"still extractsread; a part with neither field falls back tounknown(focused run: 9 pass / 0 fail)bun run typecheck,bun run check, andbun run buildpassbun test: 831 pass / 4 skip / 3 fail — all 3 failures also reproduce on pristinemain(1ddfdad) and are unrelated to this change (plugin bundle-boundarydiststate, user-profile-learning interval crossing, config defaults)legacyMessagerather than widening this fallbackChecklist
main(do not open PRs from commits already onmain)bun testpasses (or N/A) — remaining failures pre-exist onmain, see Test planbun run typecheckpasses (or N/A)bun run checkpasses (format + lint + typecheck; or N/A)