fix(delegate-task): align metadata with opencode core task tool

Match opencode core 'task' tool behavior for metadata consistency:

1. Model fallback: When categoryModel/task.model/resumeModel is undefined,

   fall back to parentContext.model so subagent metadata always includes

   model info. Thread parentContext into executeSyncContinuation for parity.

2. Task ID consistency: unstable-agent-task was missing taskId and

   backgroundTaskId in metadata. background_output used inconsistent

   snake_case 'task_id' vs camelCase 'taskId' elsewhere. Standardize on

   camelCase: taskId = sessionID (resume id), backgroundTaskId = bg task id.

Update text output blocks to use buildTaskMetadataBlock helper.

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-17 14:42:38 +09:00
parent 3a656136b6
commit 2892ca4adf
11 changed files with 445 additions and 30 deletions
@@ -59,7 +59,7 @@ describe("createBackgroundOutput metadata", () => {
agent: "test-agent",
category: undefined,
description: "background task",
task_id: "task-1",
backgroundTaskId: "task-1",
},
})
@@ -66,11 +66,11 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client:
const meta = {
title: formatResolvedTitle(task),
metadata: {
task_id: task.id,
backgroundTaskId: task.id,
agent: task.agent,
category: task.category,
description: task.description,
...(task.sessionID ? { sessionId: task.sessionID } : {}),
...(task.sessionID ? { sessionId: task.sessionID, taskId: task.sessionID } : {}),
} as Record<string, unknown>,
}
await publishToolMetadata(ctx, meta)