fix(code-mode): validate tool input/output against schemas#794
fix(code-mode): validate tool input/output against schemas#794anatolzak wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
ChangesCode Mode Tool Schema Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 8873b33
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-client
@tanstack/ai-code-mode
@tanstack/ai-code-mode-skills
@tanstack/ai-devtools-core
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-mcp
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-openrouter
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-utils
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
commit: |
🎯 Changes
Tools used inside code mode never validated their inputSchema/outputSchema. The normal agent-loop path validates args before execute and the result after (parseWithStandardSchema in activities/chat/tools/tool-calls.ts), but ai-code-mode's toolToBinding only used the schema to build the prompt and forwarded the sandbox's raw args straight through:
const execute = (args, context) => Promise.resolve(toolExecute(args, context))
So external_* tools received unvalidated, un-coerced input and their output went unchecked — a provided schema was effectively just documentation.
This change runs the same Standard Schema validation in toolToBinding's execute: defaults/coercions now apply, and invalid input/output throws an agent-readable error (Input/Output validation failed for tool : …) that surfaces back into the sandbox so the model can self-correct. Added unit tests covering input rejection, coercion/defaults, and output validation.
closes #793
Note: code mode has no existing E2E harness (no driver/route/page in testing/e2e). I've added unit coverage but flagging since CONTRIBUTING lists E2E as required.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit