Repository navigation
V14: Reject unknown createAgent and defineTool options - #688
Merged
Merged
Conversation
createAgent() and defineTool() now throw LOUSHO_CONFIG_INVALID for an option key they do not know, with a "did you mean" that covers typos and other SDKs' names (requireApproval -> needsApproval, maxOutputTokens -> modelSettings.maxTokens, system -> instructions). The allowlists are typed with `satisfies Record<keyof Options, true>` so they cannot drift. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LinuxDevil
force-pushed
the
v14-reject-unknown-options
branch
from
October 19, 2026 23:12
ffaaaec to
07f66c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes audit finding DX-8 (Vercel competitor audit, 2026-10-19).
What was wrong
From JavaScript, YAML-built configs or
as any, unknown top-level keys were silently ignored:createAgent({ maxOutputTokens: 100 })built an agent with no token cap, anddefineTool({ ..., requireApproval: true })built a tool that runs without approval. Only TypeScript object literals caught it (TS2353).modelSettingsalready rejected unknown keys; the top level did not.What changed
Behavior change:
createAgent()anddefineTool()now throwLOUSHO_CONFIG_INVALIDfor an option key they do not know (a key whose value isundefinedis still ignored).src/utils/knownOptionKeys.ts:unknownOptionKey()finds the first unknown key and builds the message, reusingclosestMatch()(edit distance) plus an alias map.src/createAgentKeys.ts: the createAgent allowlist, typedsatisfies Record<keyof CreateAgentConfig, true>so it cannot drift from the type. Aliases:system/systemPrompt->instructions,stopWhen/maxIterations/maxTurns->maxSteps, everymodelSettingskey and its synonyms (maxOutputTokens,max_tokens,temperature, ...) ->modelSettings.<key>. Themanifestkey of a spreadclaudeProject()result is accepted (typed againstClaudeProject), sincecreateAgent({ provider, ...project })is the documented pattern.defineTool(): allowlist typedsatisfies Record<keyof DefineToolOptions, true>. Aliases:requireApproval/requiresApproval/needApproval->needsApproval,inputSchema/parameters/schema/args->input,handler/run/invoke->execute,title->displayName,timeout->timeoutMs. Re-defining a tool by spreading it back in (defineTool({ ...tool, execute }), used in the test suite) still works: a defined tool's extra keys (inputSchema,tool,metadata) are accepted wheninputSchemais the same schema asinput.SETTING_SYNONYMSinsrc/execution/modelSettings.tsis now exported (internal module) so the createAgent aliases reuse it.docs/configuration.md(createAgent options) anddocs/tools.md(defineTool options) describe the new error;llms.txt/llms-full.txtregenerated.Tests
src/createAgent.test.ts"unknown options":maxOutputTokensandmax_tokensthrowdid you mean 'modelSettings.maxTokens'?;temperature->modelSettings.temperature;system/systemPrompt->instructions; typosmaxStep/permisions-> nearest key; a key with no match lists the allowed options; anundefinedvalue is ignored. Confirmed failing before the fix.src/tools/defineTool.test.ts:requireApproval: truethrowsdid you mean 'needsApproval'?(plusneedApproval,inputSchema,parameters,handler,deferLoad); no-match lists allowed options;undefinedignored; a spread defined tool is accepted while a strayinputSchemais rejected.npx tsc --noEmit,npm run typecheck:tests,npm run lint,npm run api:check,npm run docs:llms:check: pass.npm run test:coverage: 407 files / 6037 tests pass;npm run fallow: exit 0. (A first full run had two timing-only flakes under load -upstreamFailurestimeout andmcp/connectoptional server - which pass in isolation and on rerun.)Changelog:
createAgent()anddefineTool()now reject unknown option keys with a "did you mean" (e.g.requireApproval->needsApproval,maxOutputTokens->modelSettings.maxTokens) instead of silently ignoring them.🤖 Generated with Claude Code