fix(ai): warn on unknown chat options - #1091
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthrough
ChangesUnknown chat option warnings
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change adds warnings for unknown chat options while preserving existing debug-category control; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant PlaywrightTest
participant UnknownChatOptionsRoute
participant ChatActivity
participant Logger
participant AnyTextAdapter
PlaywrightTest->>UnknownChatOptionsRoute: request unknown-chat-options endpoint
UnknownChatOptionsRoute->>ChatActivity: pass top-level providerOptions
ChatActivity->>Logger: emit unknown-option warning
ChatActivity->>AnyTextAdapter: execute chat stream
UnknownChatOptionsRoute->>UnknownChatOptionsRoute: drain stream and collect warnings
UnknownChatOptionsRoute-->>PlaywrightTest: return warnings as JSON
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/ai/src/activities/chat/index.ts (1)
505-548: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDefine the chat option schema with Zod.
Use a Zod object schema as the source of truth for recognized
chat()option keys. Derive the unknown-key check from that schema. Keep provider-specificmodelOptionsopaque. Declare Zod as a runtime peer dependency because this check runs in the published package.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ai/src/activities/chat/index.ts` around lines 505 - 548, Replace the manual CHAT_OPTION_KEYS set with a Zod object schema covering the recognized chat() options, while keeping modelOptions opaque and deriving warnOnUnknownChatOptions’ unknown-key detection from the schema’s keys. Add Zod as a runtime peer dependency for the published package and update any required package metadata or imports.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@testing/e2e/tests/unknown-chat-options.spec.ts`:
- Line 1: Add a file-header comment in unknown-chat-options.spec.ts explaining
that the test uses the local adapter and does not call an LLM provider, so
aimock is intentionally not configured.
---
Nitpick comments:
In `@packages/ai/src/activities/chat/index.ts`:
- Around line 505-548: Replace the manual CHAT_OPTION_KEYS set with a Zod object
schema covering the recognized chat() options, while keeping modelOptions opaque
and deriving warnOnUnknownChatOptions’ unknown-key detection from the schema’s
keys. Add Zod as a runtime peer dependency for the published package and update
any required package metadata or imports.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fd23aba3-027a-4c7b-b61d-f96b7a8b0098
📒 Files selected for processing (6)
.changeset/fix-unknown-chat-options.mdpackages/ai/src/activities/chat/index.tspackages/ai/tests/debug-logging-chat.test.tstesting/e2e/src/routeTree.gen.tstesting/e2e/src/routes/api.unknown-chat-options.tstesting/e2e/tests/unknown-chat-options.spec.ts
|
Thanks for the PR, @mikemikimike! 🙌 @jherr will take a look. Automated pre-review checks
Automated triage — a human review follows. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
64a51d9 to
2fc8385
Compare
|
Maintainer sweep: rebased onto |
|
View your CI Pipeline Execution ↗ for commit 020fdb0
☁️ Nx Cloud last updated this comment at |
2fc8385 to
020fdb0
Compare
|
Maintainer sweep: rebased onto |
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-mcp
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-sandbox
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-vercel
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
commit: |
020fdb0 to
eecaa9f
Compare
|
Maintainer sweep: rebased onto |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Summary
chat()receives unknown top-level optionsmodelOptionswhen the misplaced key isproviderOptionserrorsdebug categoryFixes #1073
Validation
pnpm test:lib --run tests/chat.test.ts tests/debug-logging-chat.test.ts tests/debug-logging-activities.test.ts— 90 passedpnpm --filter @tanstack/ai-e2e test:e2e -- tests/unknown-chat-options.spec.ts --project=chromium— 1 passedpnpm test:typesinpackages/ai— passedpnpm test:oxlintinpackages/ai— passed with existing warningspnpm --filter @tanstack/ai-e2e test:types— passedpnpm test:dts— passedgit diff --check— passedThe repository's
pnpm test:prran all React Native smoke checks and Nx targets successfully, but exited at the final Nx cleanup with WindowsEISDIR: illegal operation on a directory, lstat 'D:'.Summary by CodeRabbit
chat()now warns when it receives unrecognized top-level options instead of silently ignoring them.modelOptionswhenproviderOptionsis supplied incorrectly.