{"record":{"id":"7b92fe0f3067b5d9","repo":"can1357/oh-my-pi","slug":"completion-received-invalid-arguments-parsed","errorCode":null,"errorMessage":"completion() received invalid arguments: ${parsed.summary}","messagePattern":"completion\\(\\) received invalid arguments: (.+?)","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/eval/completion-bridge.ts","lineNumber":113,"sourceCode":"function reasoningForTier(tier: CompletionTier, model: Model<Api>): Effort | undefined {\n\tif (tier !== \"slow\" || !model.reasoning) return undefined;\n\tconst efforts = getSupportedEfforts(model);\n\tif (efforts.length === 0) return undefined;\n\treturn efforts.includes(Effort.High) ? Effort.High : efforts[efforts.length - 1];\n}\n\n/**\n * Run a single stateless completion on behalf of an eval cell's `completion()` call.\n * Returns a `{ text, details }` value shaped like a {@link callSessionTool}\n * result so the existing bridge transport carries it to either runtime.\n */\nexport async function runEvalCompletion(\n\targs: unknown,\n\toptions: EvalCompletionBridgeOptions,\n): Promise<EvalCompletionResult> {\n\tconst parsed = completionArgsSchema(args);\n\tif (parsed instanceof type.errors) {\n\t\tthrow new ToolError(`completion() received invalid arguments: ${parsed.summary}`);\n\t}\n\tconst { prompt, model: modelTier, system, schema } = parsed;\n\t// Apply default value for model if not provided\n\tconst finalTier: CompletionTier = modelTier ?? \"default\";\n\n\tconst model = resolveTierModel(finalTier, options.session);\n\tif (!model) {\n\t\tthrow new ToolError(\n\t\t\t`completion() could not resolve a model for the \"${finalTier}\" tier. Configure modelRoles.${finalTier === \"default\" ? \"default\" : finalTier} or ensure a provider is available.`,\n\t\t);\n\t}\n\n\tconst registry = options.session.modelRegistry;\n\tconst apiKey = await registry?.getApiKey(model);\n\tif (!registry || !apiKey) {\n\t\tthrow new ToolError(\n\t\t\t`completion() has no API key for ${formatModelString(model)}. Configure credentials for this provider or choose another tier.`,\n\t\t);","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/completion-bridge.ts#L95-L131","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncompletion({ prompt: 'summarize', model: 'defalt', schema: 'not-a-schema' })\n// after\ncompletion({ prompt: 'summarize', model: 'default', schema: myArkTypeSchema })","handlingStrategy":"validation","validationCode":"const res = completionArgsSchema(args);\nif (res instanceof type.errors) console.error(res.summary); else proceed(res);","typeGuard":"function isValidCompletionArgs(a: unknown): a is EvalCompletionArgs { return !(completionArgsSchema(a) instanceof type.errors); }","tryCatchPattern":"try { await runEvalCompletion(args, opts) } catch (e) { if (/completion\\(\\) received invalid arguments/.test(e.message)) { fixArgsFromSummary(e.message); } else throw e }","preventionTips":["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"],"tags":["validation","arktype","eval","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}