fix(delegate-task): apply load_skills content to continuation prompts
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -11,7 +11,8 @@ export async function executeBackgroundContinuation(
|
|||||||
args: DelegateTaskArgs,
|
args: DelegateTaskArgs,
|
||||||
ctx: ToolContextWithMetadata,
|
ctx: ToolContextWithMetadata,
|
||||||
executorCtx: ExecutorContext,
|
executorCtx: ExecutorContext,
|
||||||
parentContext: ParentContext
|
parentContext: ParentContext,
|
||||||
|
systemContent?: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const { manager } = executorCtx
|
const { manager } = executorCtx
|
||||||
const taskID = getTaskID(args)
|
const taskID = getTaskID(args)
|
||||||
@@ -21,9 +22,13 @@ export async function executeBackgroundContinuation(
|
|||||||
throw new Error("task_id is required to continue a background task")
|
throw new Error("task_id is required to continue a background task")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const effectivePrompt = systemContent
|
||||||
|
? `${systemContent}\n\n${args.prompt}`
|
||||||
|
: args.prompt
|
||||||
|
|
||||||
const task = await manager.resume({
|
const task = await manager.resume({
|
||||||
sessionId: taskID,
|
sessionId: taskID,
|
||||||
prompt: args.prompt,
|
prompt: effectivePrompt,
|
||||||
parentSessionID: parentContext.sessionID,
|
parentSessionID: parentContext.sessionID,
|
||||||
parentMessageID: parentContext.messageID,
|
parentMessageID: parentContext.messageID,
|
||||||
parentModel: parentContext.model,
|
parentModel: parentContext.model,
|
||||||
@@ -70,12 +75,12 @@ ${buildTaskMetadataBlock({
|
|||||||
taskId: sessionId,
|
taskId: sessionId,
|
||||||
backgroundTaskId,
|
backgroundTaskId,
|
||||||
agent: task.agent,
|
agent: task.agent,
|
||||||
|
category: task.category,
|
||||||
})}`
|
})}`
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return formatDetailedError(error, {
|
return formatDetailedError(error, {
|
||||||
operation: "Continue background task",
|
operation: "Continue background task",
|
||||||
args,
|
args,
|
||||||
category: task.category,
|
|
||||||
sessionID: taskID,
|
sessionID: taskID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ export async function executeSyncContinuation(
|
|||||||
ctx: ToolContextWithMetadata,
|
ctx: ToolContextWithMetadata,
|
||||||
executorCtx: ExecutorContext,
|
executorCtx: ExecutorContext,
|
||||||
parentContext: ParentContext,
|
parentContext: ParentContext,
|
||||||
deps: SyncContinuationDeps = syncContinuationDeps
|
deps: SyncContinuationDeps = syncContinuationDeps,
|
||||||
|
systemContent?: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const { client, syncPollTimeoutMs, sisyphusAgentConfig } = executorCtx
|
const { client, syncPollTimeoutMs, sisyphusAgentConfig } = executorCtx
|
||||||
const toastManager = getTaskToastManager()
|
const toastManager = getTaskToastManager()
|
||||||
@@ -73,11 +74,11 @@ export async function executeSyncContinuation(
|
|||||||
resumeVariant = resumeMessageModel?.variant
|
resumeVariant = resumeMessageModel?.variant
|
||||||
}
|
}
|
||||||
|
|
||||||
const syncContMeta = {
|
|
||||||
const resumeModelForMetadata = resumeModel && resumeVariant !== undefined
|
const resumeModelForMetadata = resumeModel && resumeVariant !== undefined
|
||||||
? { ...resumeModel, variant: resumeVariant }
|
? { ...resumeModel, variant: resumeVariant }
|
||||||
: resumeModel
|
: resumeModel
|
||||||
|
|
||||||
|
const syncContMeta = {
|
||||||
title: `Continue: ${args.description}`,
|
title: `Continue: ${args.description}`,
|
||||||
metadata: {
|
metadata: {
|
||||||
prompt: args.prompt,
|
prompt: args.prompt,
|
||||||
@@ -113,6 +114,7 @@ export async function executeSyncContinuation(
|
|||||||
...(resumeAgent !== undefined ? { agent: resumeAgent } : {}),
|
...(resumeAgent !== undefined ? { agent: resumeAgent } : {}),
|
||||||
...(resumeModel !== undefined ? { model: resumeModel } : {}),
|
...(resumeModel !== undefined ? { model: resumeModel } : {}),
|
||||||
...(resumeVariant !== undefined ? { variant: resumeVariant } : {}),
|
...(resumeVariant !== undefined ? { variant: resumeVariant } : {}),
|
||||||
|
system: systemContent,
|
||||||
tools,
|
tools,
|
||||||
parts: [{ type: "text", text: effectivePrompt }],
|
parts: [{ type: "text", text: effectivePrompt }],
|
||||||
},
|
},
|
||||||
@@ -154,9 +156,9 @@ ${buildTaskMetadataBlock({
|
|||||||
sessionId: continuationID,
|
sessionId: continuationID,
|
||||||
taskId: continuationID,
|
taskId: continuationID,
|
||||||
agent: resumeAgent,
|
agent: resumeAgent,
|
||||||
|
category: args.category,
|
||||||
})}`
|
})}`
|
||||||
} finally {
|
} finally {
|
||||||
category: args.category,
|
|
||||||
if (toastManager) {
|
if (toastManager) {
|
||||||
toastManager.removeTask(taskId)
|
toastManager.removeTask(taskId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,13 +53,20 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
|
|||||||
return skillError
|
return skillError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const continuationSystemContent = buildSystemContent({
|
||||||
|
skillContent,
|
||||||
|
skillContents,
|
||||||
|
availableCategories,
|
||||||
|
availableSkills,
|
||||||
|
})
|
||||||
|
|
||||||
const parentContext = await resolveParentContext(ctx, options.client)
|
const parentContext = await resolveParentContext(ctx, options.client)
|
||||||
|
|
||||||
if (delegateTaskArgs.task_id) {
|
if (delegateTaskArgs.task_id) {
|
||||||
if (runInBackground) {
|
if (runInBackground) {
|
||||||
return executeBackgroundContinuation(delegateTaskArgs, ctx, options, parentContext)
|
return executeBackgroundContinuation(delegateTaskArgs, ctx, options, parentContext, continuationSystemContent)
|
||||||
}
|
}
|
||||||
return executeSyncContinuation(delegateTaskArgs, ctx, options, parentContext)
|
return executeSyncContinuation(delegateTaskArgs, ctx, options, parentContext, undefined, continuationSystemContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!delegateTaskArgs.category && !delegateTaskArgs.subagent_type) {
|
if (!delegateTaskArgs.category && !delegateTaskArgs.subagent_type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user