Skip to content

Commit fdd83b4

Browse files
committed
Fix tool_result recording for call_omo_agent to include output in transcripts (#177)
- Check if metadata is empty before using it - Wrap output.output in structured object when metadata is missing - Ensures plugin tools (call_omo_agent, background_task, task) that return strings are properly recorded in transcripts instead of empty {} 🤖 Generated with assistance of OhMyOpenCode
1 parent 83c1b8d commit fdd83b4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/hooks/claude-code-hooks/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ export function createClaudeCodeHooksHook(ctx: PluginInput, config: PluginConfig
184184

185185
const cachedInput = getToolInput(input.sessionID, input.tool, input.callID) || {}
186186

187-
recordToolResult(input.sessionID, input.tool, cachedInput, (output.metadata as Record<string, unknown>) || {})
187+
// Use metadata if available and non-empty, otherwise wrap output.output in a structured object
188+
// This ensures plugin tools (call_omo_agent, background_task, task) that return strings
189+
// get their results properly recorded in transcripts instead of empty {}
190+
const metadata = output.metadata as Record<string, unknown> | undefined
191+
const hasMetadata = metadata && typeof metadata === "object" && Object.keys(metadata).length > 0
192+
const toolOutput = hasMetadata ? metadata : { output: output.output }
193+
recordToolResult(input.sessionID, input.tool, cachedInput, toolOutput)
188194

189195
if (!isHookDisabled(config, "PostToolUse")) {
190196
const postClient: PostToolUseClient = {

0 commit comments

Comments
 (0)