feat(task): removed per-call model override from task tool

- Removes `model` field from task item/schema, TaskParams, and TaskItem types.
- Removes model selector validation, formatting, and approval display logic.
- Updates task tool priority docs to reflect that model is no longer per-call overridable.
- Updates eval agent() helper docs and prompt templates to remove model parameter.
- Updates tests to reflect removal of model override capability.
This commit is contained in:
can1357
2026-07-24 14:51:48 +02:00
parent 30994dafb2
commit 9f8aa87dbf
14 changed files with 27 additions and 124 deletions
+1 -34
View File
@@ -231,18 +231,6 @@ function validateShapeParams(batchEnabled: boolean, params: TaskParams): string
* policy later, in `spawnParamsFor`. Returns a problem description, or
* undefined when valid.
*/
function hasInvalidModelSelector(model: unknown): boolean {
if (model === undefined) return false;
const selectors = typeof model === "string" ? [model] : Array.isArray(model) ? model : undefined;
const materializedSelectors = selectors ? Array.from(selectors) : [];
return (
!selectors ||
materializedSelectors.length === 0 ||
materializedSelectors.some(
selector => typeof selector !== "string" || !selector.split(",").some(pattern => pattern.trim()),
)
);
}
function validateSpawnParams(params: TaskParams, batchEnabled: boolean): string | undefined {
const hasTask = typeof params.task === "string" && params.task.trim() !== "";
@@ -259,9 +247,6 @@ function validateSpawnParams(params: TaskParams, batchEnabled: boolean): string
if (!item || typeof item.task !== "string" || item.task.trim() === "") {
return `Task ${i + 1}${item?.name ? ` (\`${item.name}\`)` : ""} is missing \`task\`. Every task needs complete, self-contained instructions.`;
}
if (hasInvalidModelSelector(item.model)) {
return `Task ${i + 1}${item.name ? ` (\`${item.name}\`)` : ""} has an invalid \`model\`. Provide a non-empty selector or a non-empty array of non-empty selectors.`;
}
}
const seen = new Map<string, string>();
for (const item of tasks) {
@@ -284,9 +269,6 @@ function validateSpawnParams(params: TaskParams, batchEnabled: boolean): string
? "Missing `tasks`. Provide a `tasks` array (one subagent per item) with a shared `context`."
: "Missing `task`. Provide complete, self-contained instructions for the agent.";
}
if (hasInvalidModelSelector(params.model)) {
return "Invalid `model`. Provide a non-empty selector or a non-empty array of non-empty selectors.";
}
return undefined;
}
@@ -300,7 +282,7 @@ function resolveSpawnItems(params: TaskParams): TaskItem[] {
if (Array.isArray(params.tasks) && params.tasks.length > 0) {
return params.tasks;
}
const item: TaskItem = { name: params.name, agent: params.agent, task: params.task, model: params.model };
const item: TaskItem = { name: params.name, agent: params.agent, task: params.task };
if ("outputSchema" in params) item.outputSchema = params.outputSchema;
if ("schemaMode" in params) item.schemaMode = params.schemaMode;
if ("isolated" in params) item.isolated = params.isolated;
@@ -320,7 +302,6 @@ function spawnParamsFor(params: TaskParams, item: TaskItem, defaultAgent: string
const spawn: TaskParams = { agent: item.agent?.trim() || defaultAgent };
if (item.name !== undefined) spawn.name = item.name;
if (item.task !== undefined) spawn.task = item.task;
if (item.model !== undefined) spawn.model = item.model;
if (params.context !== undefined) spawn.context = params.context;
if ("outputSchema" in item) spawn.outputSchema = item.outputSchema;
if ("schemaMode" in item) spawn.schemaMode = item.schemaMode;
@@ -491,14 +472,6 @@ function discoverAgentsForCreate(cwd: string): Promise<DiscoveryResult> {
return pending;
}
function formatModelForApproval(model: unknown): string | undefined {
const selectors = typeof model === "string" ? [model] : Array.isArray(model) ? model : [];
const normalized = selectors.filter(
(selector): selector is string => typeof selector === "string" && !!selector.trim(),
);
return normalized.length > 0 ? truncateForPrompt(normalized.join(" → ")) : undefined;
}
// ═══════════════════════════════════════════════════════════════════════════
// Tool Class
// ═══════════════════════════════════════════════════════════════════════════
@@ -522,8 +495,6 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
if (typeof params.name === "string" && params.name.trim()) {
lines.push(`Name: ${truncateForPrompt(params.name)}`);
}
const model = formatModelForApproval(params.model);
if (model) lines.push(`Model: ${model}`);
if (typeof params.task === "string") {
lines.push(`Task:\n${truncateForPrompt(params.task)}`);
}
@@ -554,8 +525,6 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
lines.push(`Name: ${truncateForPrompt(firstTask.name)}`);
}
lines.push(`Agent: ${truncateForPrompt(effectiveAgent(firstTask))}`);
const itemModel = formatModelForApproval("model" in firstTask ? firstTask.model : undefined);
if (itemModel) lines.push(`Model: ${itemModel}`);
if ("task" in firstTask && typeof firstTask.task === "string") {
lines.push(`Task:\n${truncateForPrompt(firstTask.task)}`);
}
@@ -663,7 +632,6 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
assignment: (params.task ?? "").trim(),
context: this.#isBatchEnabled() ? params.context?.trim() || undefined : undefined,
agent: params.agent,
model: params.model,
...(Object.hasOwn(params, "outputSchema") ? { outputSchema: params.outputSchema } : {}),
...(Object.hasOwn(params, "schemaMode") ? { schemaMode: params.schemaMode } : {}),
...("isolated" in params ? { isolation: { requested: params.isolated } } : {}),
@@ -1419,7 +1387,6 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
assignment,
context,
agent: params.agent,
model: params.model,
...(Object.hasOwn(params, "outputSchema") ? { outputSchema: params.outputSchema } : {}),
...(Object.hasOwn(params, "schemaMode") ? { schemaMode: params.schemaMode } : {}),
identity: { id: preAllocatedId, label: params.name },