can1357/oh-my-pi · error · ToolError
completion() received invalid arguments: ${parsed.summary}
Error message
completion() received invalid arguments: ${parsed.summary} What it means
The eval completion() bridge validates its arguments with completionArgsSchema (ArkType). Invalid args (wrong types, missing prompt, bad tier, invalid schema value) produce a ToolError containing ArkType's summary, mirroring the agent() bridge pattern.
Source
Thrown at packages/coding-agent/src/eval/completion-bridge.ts:113
function reasoningForTier(tier: CompletionTier, model: Model<Api>): Effort | undefined {
if (tier !== "slow" || !model.reasoning) return undefined;
const efforts = getSupportedEfforts(model);
if (efforts.length === 0) return undefined;
return efforts.includes(Effort.High) ? Effort.High : efforts[efforts.length - 1];
}
/**
* Run a single stateless completion on behalf of an eval cell's `completion()` call.
* Returns a `{ text, details }` value shaped like a {@link callSessionTool}
* result so the existing bridge transport carries it to either runtime.
*/
export async function runEvalCompletion(
args: unknown,
options: EvalCompletionBridgeOptions,
): Promise<EvalCompletionResult> {
const parsed = completionArgsSchema(args);
if (parsed instanceof type.errors) {
throw new ToolError(`completion() received invalid arguments: ${parsed.summary}`);
}
const { prompt, model: modelTier, system, schema } = parsed;
// Apply default value for model if not provided
const finalTier: CompletionTier = modelTier ?? "default";
const model = resolveTierModel(finalTier, options.session);
if (!model) {
throw new ToolError(
`completion() could not resolve a model for the "${finalTier}" tier. Configure modelRoles.${finalTier === "default" ? "default" : finalTier} or ensure a provider is available.`,
);
}
const registry = options.session.modelRegistry;
const apiKey = await registry?.getApiKey(model);
if (!registry || !apiKey) {
throw new ToolError(
`completion() has no API key for ${formatModelString(model)}. Configure credentials for this provider or choose another tier.`,
);View on GitHub (pinned to 9690622007)
Solutions
- Read parsed.summary for the exact failing field and expected type
- Correct argument names/values against completionArgsSchema
- Use a valid tier: 'default' if unsure
- Pre-validate args with the same schema in your eval harness
Example fix
// before
completion({ prompt: 'summarize', model: 'defalt', schema: 'not-a-schema' })
// after
completion({ prompt: 'summarize', model: 'default', schema: myArkTypeSchema }) Defensive patterns
Strategy: validation
Validate before calling
const res = completionArgsSchema(args); if (res instanceof type.errors) console.error(res.summary); else proceed(res);
Type guard
function isValidCompletionArgs(a: unknown): a is EvalCompletionArgs { return !(completionArgsSchema(a) instanceof type.errors); } Try / catch
try { await runEvalCompletion(args, opts) } catch (e) { if (/completion\(\) received invalid arguments/.test(e.message)) { fixArgsFromSummary(e.message); } else throw e } Prevention
- Use documented tier strings ('default' as fallback)
- Pass a real schema object, not a string
- Coerce frontmatter strings to expected types
- Re-check the schema after package upgrades
When it happens
Trigger: Calling completion() with a missing/empty prompt, an unknown model tier string, a system prompt of the wrong type, or a schema argument that fails the schema's constraints.
Common situations: Typo in the tier name (e.g. 'defalt' instead of 'default'); passing raw JSON where a schema object is required; upgrading the package changed allowed tier values; frontmatter values arrive as strings needing coercion.
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
- agent() received invalid arguments: ${result.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/7b92fe0f3067b5d9.
Report an issue: GitHub.