can1357/oh-my-pi · error · ToolError
agent() received invalid arguments: ${result.summary}
Error message
agent() received invalid arguments: ${result.summary} What it means
The eval agent() bridge validates its arguments with an ArkType schema (agentArgsSchema). When the supplied args fail validation, the schema's error summary is wrapped in a ToolError naming the agent() call so eval authors know which tool rejected their input.
Source
Thrown at packages/coding-agent/src/eval/agent-bridge.ts:78
id: string;
model?: string | string[];
structured: boolean;
schemaSource?: "caller" | "agent" | "session";
schemaMode?: StructuredSubagentSchemaMode;
schemaStatus?: "valid" | "invalid";
isolated?: boolean;
patchPath?: string;
branchName?: string;
nestedPatches?: NestedRepoPatch[];
changesApplied?: boolean | null;
isolationSummary?: string;
};
}
function parseAgentArgs(args: unknown): EvalAgentArgs {
const result = agentArgsSchema(args);
if (result instanceof type.errors) {
throw new ToolError(`agent() received invalid arguments: ${result.summary}`);
}
return result;
}
function trimToUndefined(value: string | undefined): string | undefined {
const trimmed = value?.trim();
return trimmed ? trimmed : undefined;
}
function emitProgressStatus(emitStatus: ((event: JsStatusEvent) => void) | undefined, progress: AgentProgress): void {
if (!emitStatus) return;
const preview = (progress.assignment ?? progress.task ?? "").split("\n")[0]?.slice(0, 120);
emitStatus({
op: "agent",
id: progress.id,
agent: progress.agent,
status: progress.status,
lastIntent: progress.lastIntent,View on GitHub (pinned to 9690622007)
Solutions
- Read result.summary in the message to see each failing field and expected type
- Fix the argument names/types to match agentArgsSchema
- Check the current package version's schema for renamed/added required args
- Validate args with the schema before the call in a test harness
Example fix
// before
agent({ promt: 'do the thing', isolated: 'yes' })
// after
agent({ prompt: 'do the thing', isolated: true }) Defensive patterns
Strategy: validation
Validate before calling
const res = agentArgsSchema(args); if (res instanceof type.errors) console.error(res.summary); else proceed(res);
Type guard
function isValidAgentArgs(a: unknown): a is EvalAgentArgs { return !(agentArgsSchema(a) instanceof type.errors); } Try / catch
try { await runEvalAgent(args, opts) } catch (e) { if (/agent\(\) received invalid arguments/.test(e.message)) { fixArgsFromSummary(e.message); } else throw e } Prevention
- Check arg names against the schema (prompt vs promt typos)
- Use booleans not strings for flags like isolated
- Pin package version and re-check schema after upgrades
- Write a schema round-trip test for eval cells
When it happens
Trigger: Calling agent() in an eval cell with missing required fields, wrong types (e.g. prompt as number), unknown properties, or malformed isolation flags (isolated/apply/merge) that the schema rejects.
Common situations: Typo'd argument names in eval frontmatter/cells; passing an object where a string is expected; schema evolution after a version upgrade added a required field; JSON-derived args with null where undefined was expected.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- completion() received invalid arguments: ${parsed.summary}
- anthropic-messages: ${data.summary}
- Schema contains a circular object graph — cannot enforce str
- Schema node has no type, combinator, or $ref — cannot enforc
- Validation failed for tool "${toolCall.name}":\n${errors}\n\
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/8933d63c0ea3781b.
Report an issue: GitHub.