fix(orchestration): clarify agent delegation and scheduling

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex committed 2026-07-22 14:05:56 +02:00
1 parent 4fcf27f426
commit f30673fea7
15 files changed
+324 -45

No files matched your search

+66 -13
View File
@@ -31,9 +31,35 @@ import {
} from "./model.ts";
import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
const OrchestratorMcpPrompt = TrimmedNonEmptyString.check(Schema.isMaxLength(120_000));
const OrchestratorMcpTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512));
const OrchestratorMcpClientRequestId = TrimmedNonEmptyString.check(Schema.isMaxLength(256));
const OrchestratorMcpPrompt = TrimmedNonEmptyString.check(Schema.isMaxLength(120_000)).annotate({
description: "Complete task or message text for the target agent.",
});
const OrchestratorMcpTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512)).annotate({
description: "Optional concise display title.",
});
const OrchestratorMcpClientRequestId = TrimmedNonEmptyString.check(
Schema.isMaxLength(256),
).annotate({ description: "Stable idempotency key to reuse when retrying this mutation." });
/**
* OpenCode 1.15 has been observed serializing nested MCP union objects as JSON
* strings. Keep the structured object as the documented form while accepting
* that compatibility shape at the tool boundary and decoding it immediately.
*/
const OrchestratorMcpScheduleFromJsonString = Schema.fromJsonString(ScheduledTaskSchedule).annotate(
{
description:
"Compatibility-only JSON encoding of the schedule object. Prefer a structured object.",
},
);
const OrchestratorMcpSchedule = Schema.Union([
ScheduledTaskSchedule,
OrchestratorMcpScheduleFromJsonString,
]).annotate({
description:
"Recurring schedule object: {type:'interval', everyMs} or {type:'fixed_time', timeOfDay, weekdays?}. Never stringify it unless the provider requires the compatibility form.",
});
/**
* Shorthand `{ id: value }` record form for target model options. Unlike the
@@ -65,9 +91,21 @@ export const OrchestratorMcpTargetOptions = Schema.Union([
export type OrchestratorMcpTargetOptions = typeof OrchestratorMcpTargetOptions.Type;
export const OrchestratorMcpTarget = Schema.Struct({
providerInstanceId: Schema.optional(ProviderInstanceId),
driverKind: Schema.optional(ProviderDriverKind),
model: Schema.optional(TrimmedNonEmptyString),
providerInstanceId: Schema.optional(
ProviderInstanceId.annotate({
description: "Configured provider instance id from orchestrator_capabilities.",
}),
),
driverKind: Schema.optional(
ProviderDriverKind.annotate({
description: "Provider driver kind; prefer providerInstanceId when available.",
}),
),
model: Schema.optional(
TrimmedNonEmptyString.annotate({
description: "Model id advertised for the selected provider instance.",
}),
),
/**
* Model option selections for the child (for example reasoning effort).
* Accepts the canonical `[{ id, value }]` array or the shorthand
@@ -75,7 +113,11 @@ export const OrchestratorMcpTarget = Schema.Struct({
* advertised by orchestrator_capabilities. When omitted, options inherit
* from the parent only when the child runs the parent's provider and model.
*/
options: Schema.optional(OrchestratorMcpTargetOptions),
options: Schema.optional(
OrchestratorMcpTargetOptions.annotate({
description: "Model option selections advertised by orchestrator_capabilities.",
}),
),
});
export type OrchestratorMcpTarget = typeof OrchestratorMcpTarget.Type;
@@ -110,7 +152,9 @@ export const OrchestratorMcpDelegatedTaskStatus = Schema.Literals([
export type OrchestratorMcpDelegatedTaskStatus = typeof OrchestratorMcpDelegatedTaskStatus.Type;
export const OrchestratorMcpDelegateTaskInput = Schema.Struct({
task: OrchestratorMcpPrompt,
task: OrchestratorMcpPrompt.annotate({
description: "Self-contained task for one delegated child agent/subagent.",
}),
target: Schema.optional(OrchestratorMcpTarget),
title: Schema.optional(OrchestratorMcpTitle),
role: Schema.optional(OrchestratorMcpTaskRole),
@@ -418,16 +462,25 @@ export const OrchestratorMcpCapabilitiesResult = Schema.Struct({
export type OrchestratorMcpCapabilitiesResult = typeof OrchestratorMcpCapabilitiesResult.Type;
export const OrchestratorMcpScheduleTaskInput = Schema.Struct({
prompt: OrchestratorMcpPrompt,
schedule: ScheduledTaskSchedule,
prompt: OrchestratorMcpPrompt.annotate({
description: "Prompt executed on every scheduled run.",
}),
schedule: OrchestratorMcpSchedule,
title: Schema.optional(OrchestratorMcpTitle),
enabled: Schema.optional(Schema.Boolean),
enabled: Schema.optional(
Schema.Boolean.annotate({ description: "Whether the schedule starts enabled; defaults true." }),
),
/**
* When true (the default), the scheduled task fires into the calling thread
* on each run instead of launching a fresh thread. This is the recurring
* "wake up in this thread" behaviour reserved for agent-created tasks.
*/
bindToCurrentThread: Schema.optional(Schema.Boolean),
bindToCurrentThread: Schema.optional(
Schema.Boolean.annotate({
description:
"True (default) posts each run into this thread; false creates a fresh top-level thread per run.",
}),
),
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
});
export type OrchestratorMcpScheduleTaskInput = typeof OrchestratorMcpScheduleTaskInput.Type;
@@ -459,7 +512,7 @@ export const OrchestratorMcpUpdateScheduledTaskInput = Schema.Struct({
scheduledTaskId: ScheduledTaskId,
prompt: Schema.optional(OrchestratorMcpPrompt),
title: Schema.optional(OrchestratorMcpTitle),
schedule: Schema.optional(ScheduledTaskSchedule),
schedule: Schema.optional(OrchestratorMcpSchedule),
enabled: Schema.optional(Schema.Boolean),
bindToCurrentThread: Schema.optional(Schema.Boolean),
});
+27 -6
View File
@@ -18,21 +18,42 @@ import {
import { ProviderInteractionMode, RuntimeMode } from "./providerPolicy.ts";
/** 24-hour "HH:MM" wall-clock time. Mirrors `parseTimeOfDay` on the server. */
const TimeOfDay = TrimmedNonEmptyString.check(Schema.isPattern(/^([01]?\d|2[0-3]):([0-5]\d)$/));
const TimeOfDay = TrimmedNonEmptyString.check(
Schema.isPattern(/^([01]?\d|2[0-3]):([0-5]\d)$/),
).annotate({ description: "Local wall-clock time in 24-hour HH:MM form, such as 09:30." });
export const ScheduledTaskSchedule = Schema.Union([
Schema.Struct({
type: Schema.Literal("interval"),
everyMs: PositiveInt,
type: Schema.Literal("interval").annotate({
description: "Select interval scheduling.",
}),
everyMs: PositiveInt.annotate({
description: "Positive interval in milliseconds; 3600000 means every hour.",
}),
}).annotate({
description: "Run repeatedly after a fixed number of milliseconds.",
}),
Schema.Struct({
type: Schema.Literal("fixed_time"),
type: Schema.Literal("fixed_time").annotate({
description: "Select a fixed local wall-clock time.",
}),
timeOfDay: TimeOfDay,
weekdays: Schema.optional(
Schema.Array(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 6 }))),
Schema.Array(
Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 6 })).annotate({
description: "Weekday number where 0 is Sunday and 6 is Saturday.",
}),
).annotate({
description: "Optional weekdays; omit to run every day.",
}),
),
}).annotate({
description: "Run at a fixed local wall-clock time on selected weekdays.",
}),
]);
]).annotate({
description:
"Structured recurring schedule. Pass an object with type 'interval' or 'fixed_time'.",
});
export type ScheduledTaskSchedule = typeof ScheduledTaskSchedule.Type;
export const ScheduledTaskRunStatus = Schema.Literals(["never", "running", "succeeded", "failed"]);