Skip to content

fix: set meaningful tool titles via tool.execute.after hook#17

Merged
kuitos merged 3 commits intomainfrom
fix/memory-tool-unknown-title
Apr 18, 2026
Merged

fix: set meaningful tool titles via tool.execute.after hook#17
kuitos merged 3 commits intomainfrom
fix/memory-tool-unknown-title

Conversation

@kuitos
Copy link
Copy Markdown
Owner

@kuitos kuitos commented Apr 18, 2026

Problem

All memory tools displayed Unknown in the OpenCode TUI/CLI. For example:

βš™ memory_list Unknown
βš™ memory_search Unknown

Root Cause

Three-layer issue in OpenCode internals:

  1. registry.ts hardcodes title: "" β€” the plugin wrapper that wraps every plugin tool always returns title: "", regardless of what the tool itself does.
  2. ctx.metadata({ title }) only affects running state β€” calling this in execute() writes to the in-progress part, but the completed state is overwritten by value.output.title from the wrapper's hardcoded "".
  3. CLI fallback β€” when title is empty and args are empty (e.g. memory_list takes no args), OpenCode falls back to the string "Unknown".

Fix

Use the tool.execute.after hook, which receives the final output object by reference before it is written to the session part. Mutating output.title there persists into the completed state, bypassing the registry wrapper's hardcoded "".

Changes

  • buildMemoryToolTitle() β€” derives a human-readable title from tool args and per-call result counts
  • memoryListCountByCallID / memorySearchCountByCallID β€” Maps keyed by callID to carry result counts from execute() to the after hook (since memory_list/memory_search need to report how many results were found)
  • getCallID() β€” safely extracts callID from the opaque ctx object
  • tool.execute.after hook β€” sets output.title for all memory_* tools

Verified Titles (end-to-end with openai/gpt-5.4-mini-fast)

Tool Before After
memory_list Unknown 1 memory / 3 memories
memory_search Unknown "parallel" Β· 1 match
memory_save Unknown reference: Title Verification Test
memory_read Unknown test_title_verification.md
memory_delete Unknown test_title_verification.md

Tests

113 pass / 0 fail

kuitos and others added 3 commits April 18, 2026 18:16
Memory tools displayed 'Unknown' in the OpenCode TUI because the plugin
wrapper in registry.ts hardcodes title: "" on every plugin tool result, and
ctx.metadata({ title }) only updates the running-state title which gets
overwritten when the tool completes.

The tool.execute.after hook receives the final output object by reference
before it is written to the session part, so mutating output.title there
persists into the completed state.

- Add buildMemoryToolTitle() to derive a human-readable title from tool
  args and per-call result counts (memory_list / memory_search)
- Add memoryListCountByCallID / memorySearchCountByCallID Maps keyed by
  callID to carry result counts from execute() to the after hook
- Add getCallID() helper to safely extract callID from the opaque ctx
- Register tool.execute.after hook that sets output.title for all
  memory_* tools

Verified end-to-end with openai/gpt-5.4-mini-fast:
  memory_list     -> '1 memory'
  memory_search   -> '"parallel" Β· 1 match'
  memory_save     -> 'reference: Title Verification Test'
  memory_read     -> 'test_title_verification.md'
  memory_delete   -> 'test_title_verification.md'

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@kuitos kuitos merged commit 6310f24 into main Apr 18, 2026
1 check passed
@kuitos kuitos deleted the fix/memory-tool-unknown-title branch April 18, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant