GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(auto-capture): read tool names from v2-shaped tool parts by Phototonic · Pull Request #431 · tickernelz/opencode-mem

Conversation

@Phototonic

@Phototonic Phototonic commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Summary

On OpenCode v2 hosts, the auto-capture summarization prompt always listed tool calls as unknown(...) in the ## Tools Used section, degrading memory summaries and tags (#428).

Root cause: extractAIContent read the v1 wire-format field tool.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 at part.name (v2 SessionMessageAssistantTool shape; confirmed against @opencode-ai/sdk v2 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.name first, keeping tool.tool as a fallback for v1-wire-format hosts:

const name = tool.name || tool.tool || "unknown";

Also exports extractAIContent for direct testing and adds regression tests covering v2-shaped parts, v1-shaped parts, and the unknown fallback.

Fixes #428

Test plan

  • Exercised the change locally (or N/A for docs/meta-only)
    • New regression tests in tests/auto-capture-context.test.ts: v2 part {type:"tool", name:"bash", state:{input:{command:"ls"}}} extracts bash(command: "ls"); v1 part with tool:"read" still extracts read; a part with neither field falls back to unknown (focused run: 9 pass / 0 fail)
    • bun run typecheck, bun run check, and bun run build pass
    • Full bun test: 831 pass / 4 skip / 3 fail — all 3 failures also reproduce on pristine main (1ddfdad) and are unrelated to this change (plugin bundle-boundary dist state, user-profile-learning interval crossing, config defaults)
  • Noted any follow-up or known limitations
    • The legacy adapter stays pass-through by design; if a future consumer needs a normalized v1 field layout, prefer normalizing in legacyMessage rather than widening this fallback

Checklist

  • Branch is based on main (do not open PRs from commits already on main)
  • bun test passes (or N/A) — remaining failures pre-exist on main, see Test plan
  • bun run typecheck passes (or N/A)
  • bun run check passes (format + lint + typecheck; or N/A)
  • Docs / README updated when behavior or contribution process changes (N/A — internal prompt-building fix, no documented behavior or config change)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Phototonic
fix(auto-capture): read tool names from v2-shaped tool parts
8c303ea
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.
@Phototonic

Phototonic commented Oct 23, 2026

Copy link
Copy Markdown
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 name on out-of-contract input is not validated; left as-is since it is not a demonstrated host scenario.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Phototonic
Phototonic marked this pull request as ready for review October 23, 2026 10:54
EyJunge1
EyJunge1 approved these changes Oct 24, 2026
View reviewed changes

@EyJunge1 EyJunge1 left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Root cause and fix check out against both SDK shapes:

  • v1 ToolPart: tool: string
  • v2 SessionMessageAssistantTool: name: string (legacy adapter passes parts through with ...part)

tool.name || tool.tool || "unknown" is the right consumer-side fallback. Inputs were already shared via state.input, which matches the #428 symptom (unknown(command: …)).

Regression tests cover v2, v1, and the fallback. Exporting extractAIContent for tests is fine (not in package exports). CI is green.

No code changes needed. Optional future nit (already noted by author): coerce with typeof === "string" if out-of-contract hosts ever appear — not a merge blocker.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@EyJunge1
EyJunge1 merged commit 6a795a8 into tickernelz:main Oct 24, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@EyJunge1 EyJunge1 mentioned this pull request Oct 24, 2026
chore(release): release v2.34.0 #434
Merged
2 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@EyJunge1 EyJunge1 EyJunge1 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Auto-capture prompt for tool used section always list unknown tool call

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Phototonic @EyJunge1
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.