fix: set meaningful tool titles via tool.execute.after hook#17
Merged
Conversation
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>
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.
Problem
All memory tools displayed
Unknownin the OpenCode TUI/CLI. For example:Root Cause
Three-layer issue in OpenCode internals:
registry.tshardcodestitle: ""β the plugin wrapper that wraps every plugin tool always returnstitle: "", regardless of what the tool itself does.ctx.metadata({ title })only affects running state β calling this inexecute()writes to the in-progress part, but the completed state is overwritten byvalue.output.titlefrom the wrapper's hardcoded"".titleis empty and args are empty (e.g.memory_listtakes no args), OpenCode falls back to the string"Unknown".Fix
Use the
tool.execute.afterhook, which receives the finaloutputobject by reference before it is written to the session part. Mutatingoutput.titlethere 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 countsmemoryListCountByCallID/memorySearchCountByCallIDβ Maps keyed bycallIDto carry result counts fromexecute()to the after hook (sincememory_list/memory_searchneed to report how many results were found)getCallID()β safely extractscallIDfrom the opaquectxobjecttool.execute.afterhook β setsoutput.titlefor allmemory_*toolsVerified Titles (end-to-end with
openai/gpt-5.4-mini-fast)memory_listUnknown1 memory/3 memoriesmemory_searchUnknown"parallel" Β· 1 matchmemory_saveUnknownreference: Title Verification Testmemory_readUnknowntest_title_verification.mdmemory_deleteUnknowntest_title_verification.mdTests