Conversation
WalkthroughReplaces additionalTools mapping with a first-class toolsets array in the chat page and threads it through AgentProvider to the chat request. Updates AgentProvider’s prop types to accept Toolset[], imports Toolset, and forwards toolsets to experimental_prepareRequestBody. Other parameters and getPublicChatLink remain unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant C as Chats Component
participant P as AgentProvider
participant B as Chat Backend
U->>C: Open agent chat URL
C->>C: Parse parameters (threadId, workspaceId, toolsets[])
C->>P: Render AgentProvider(toolsets=[...])
note right of C: New: Pass Toolset[] instead of additionalTools
P->>P: Prepare request body
P->>B: chat({... , toolsets})
B-->>P: Response
P-->>C: Stream/Result
C-->>U: Display chat
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying chat with
|
| Latest commit: |
d52a75d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5fdc2461.chat-46r.pages.dev |
| Branch Preview URL: | https://tavano-fix-toolsets.chat-46r.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
apps/web/src/components/agent/provider.tsx (2)
68-70: DeprecateadditionalToolsand maketoolsetsread-only.Signal the migration path and prevent accidental mutation of the array.
children: React.ReactNode; - additionalTools?: Agent["tools_set"]; - toolsets?: Toolset[]; + /** @deprecated Use `toolsets` instead. */ + additionalTools?: Agent["tools_set"]; + toolsets?: readonly Toolset[];
287-306: Only sendtoolsetswhen non-empty to preserve server defaults.Sending an empty array may override server-side defaults. Omit the field if there are no toolsets.
- return { + const sanitizedToolsets = toolsets && toolsets.length > 0 ? toolsets : undefined; + return { metadata: { threadId: threadId ?? agentId }, args: [ [lastMessage], { model: mergedUiOptions.showModelSelector ? preferences.defaultModel : effectiveChatState.model, instructions: effectiveChatState.instructions, bypassOpenRouter, sendReasoning: preferences.sendReasoning ?? true, tools: effectiveChatState.tools_set, maxSteps: effectiveChatState.max_steps, pdfSummarization: preferences.pdfSummarization ?? true, - toolsets, + toolsets: sanitizedToolsets, smoothStream: preferences.smoothStream !== false ? { delayInMs: 25, chunk: "word" } : undefined, }, ], };apps/web/src/components/agent/chats.tsx (1)
114-115: Don’t pass an emptytoolsetsarray; preferundefined.Keeps semantics clear and avoids overriding backend defaults.
- toolsets={toolsets} + toolsets={toolsets.length ? toolsets : undefined}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/web/src/components/agent/chats.tsx(2 hunks)apps/web/src/components/agent/provider.tsx(4 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/data-flow.mdc)
**/*.{ts,tsx}: MCP tools must use Zod schemas for input and, when applicable, output validation
Register tools with server.registerTool providing description, inputSchema.shape, and optional outputSchema.shape
In every MCP tool handler, perform authorization checks first and then call context.resourceAccess.grant() before business logic
Name tools using the {RESOURCE}_{ACTION} pattern (e.g., AGENTS_CREATE, THREADS_LIST)
Group related tools into typed collections (e.g., GLOBAL_TOOLS, WORKSPACE_TOOLS) and export them as const
Always check workspace/team access before executing operations that touch workspace resources
Return proper authorization errors and handle forbidden operations explicitly
**/*.{ts,tsx}: Use functional and declarative programming patterns; avoid classes
Favor iteration and modularization to adhere to DRY and avoid duplication
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
Organize files so each file contains only related content (components, subcomponents, helpers, static content, types)
Favor named exports for functions
Prefer interfaces over types for object shapes
Avoid enums; use maps instead for better type safety and flexibility
Use the function keyword for pure functions to benefit from hoisting and clarity
Files:
apps/web/src/components/agent/provider.tsxapps/web/src/components/agent/chats.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/data-flow.mdc)
**/*.tsx: Use the shared KEYS object to construct consistent React Query keys
Use useSuspenseQuery for critical data fetching hooks
Implement optimistic updates for mutations and provide rollback on error via onMutate/onError
After successful mutations, update relevant caches with setQueryData (e.g., entity detail and list keys)
Leverage React Query’s built-in request deduplication instead of manual throttling
Use parallel queries where appropriate to reduce total load time
**/*.tsx: Use functional React components with TypeScript interfaces
Prefer using UI components from @deco/ui (packages/ui) instead of custom duplicates
Memoize expensive computations in components using useMemo
Memoize objects and arrays (e.g., defaultValues) to keep stable references
Use useDeferredValue for search inputs to keep typing responsive
Follow MCP data-access patterns (e.g., useAgents, useIntegrations) with proper loading/error states
Always use design-system form components from @deco/ui when building forms
Prefer react-hook-form with schema validation (e.g., zod) over useState for form state
Avoid prop drilling in forms; share via context/provider pattern
Apply Single Responsibility Principle: split monolithic components into focused subcomponents
Design for composability and reusability of UI components
In hooks’ dependency arrays, ensure stable references; avoid inline object/array/function literals
Memoize options/objects used in dependencies (e.g., via useMemo)
Handle loading, error, and empty states consistently for data-driven views
Extract complex conditional/rendering logic into components instead of IIFEs inside JSX
Files:
apps/web/src/components/agent/provider.tsxapps/web/src/components/agent/chats.tsx
apps/web/**
📄 CodeRabbit inference engine (.cursor/rules/structure.mdc)
Place the main application UI (Vite SPA) under /apps/web
Files:
apps/web/src/components/agent/provider.tsxapps/web/src/components/agent/chats.tsx
{apps/web,packages/ui}/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/structure.mdc)
Build UI components with React 19
Files:
apps/web/src/components/agent/provider.tsxapps/web/src/components/agent/chats.tsx
{apps/web,packages/ui}/**/*.{tsx,jsx,css}
📄 CodeRabbit inference engine (.cursor/rules/structure.mdc)
Use Tailwind CSS v4 for styling
Files:
apps/web/src/components/agent/provider.tsxapps/web/src/components/agent/chats.tsx
apps/web/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (apps/web/.cursor/rules/posthog-integration.mdc)
apps/web/**/*.{js,jsx,ts,tsx}: Use each feature flag in as few places as possible; if a flag must appear at multiple callsites, explicitly flag this for careful developer review
Gate any flag-dependent code behind checks that verify the flag’s values are valid and expected
If a custom person or event property is referenced in two or more files or at two or more callsites in the same file, centralize the keys in an enum (TS) or const object (JS)
Files:
apps/web/src/components/agent/provider.tsxapps/web/src/components/agent/chats.tsx
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/.cursor/rules/posthog-integration.mdc)
In TypeScript, store feature flag names in an enum with members written UPPERCASE_WITH_UNDERSCORE and use a consistent naming convention
Files:
apps/web/src/components/agent/provider.tsxapps/web/src/components/agent/chats.tsx
🧠 Learnings (2)
📚 Learning: 2025-09-03T18:47:09.806Z
Learnt from: CR
PR: deco-cx/chat#0
File: apps/deconfig/.cursor/rules/ai-usage.mdc:0-0
Timestamp: 2025-09-03T18:47:09.806Z
Learning: Applies to apps/deconfig/server/**/*.ts : Proxy external AI tools in the server by creating a tool (e.g., id: "AI_GENERATE_OBJECT") with zod-validated input/output and forwarding to env.DECO_CHAT_WORKSPACE_API.AI_GENERATE_OBJECT
Applied to files:
apps/web/src/components/agent/provider.tsxapps/web/src/components/agent/chats.tsx
📚 Learning: 2025-09-03T18:50:00.731Z
Learnt from: CR
PR: deco-cx/chat#0
File: apps/deconfig/.cursor/rules/tools.mdc:0-0
Timestamp: 2025-09-03T18:50:00.731Z
Learning: Applies to apps/deconfig/server/main.ts : Add new tool definitions in server/main.ts
Applied to files:
apps/web/src/components/agent/provider.tsx
| const toolsets = params.getAll("toolsets").map((toolset) => { | ||
| const [mcpUrl, connectionType = "HTTP"] = toolset.split(","); | ||
|
|
||
| return { | ||
| connection: { | ||
| type: connectionType as "HTTP" | "SSE", | ||
| url: mcpUrl, | ||
| }, | ||
| filters: [], | ||
| }; | ||
| }); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Harden parsing/validation of toolsets from URL params.
Comma-splitting is brittle (commas are valid in URLs) and unvalidated URLs/types can be abused. Normalize type, validate URL, and drop invalid entries.
- const toolsets = params.getAll("toolsets").map((toolset) => {
- const [mcpUrl, connectionType = "HTTP"] = toolset.split(",");
-
- return {
- connection: {
- type: connectionType as "HTTP" | "SSE",
- url: mcpUrl,
- },
- filters: [],
- };
- });
+ const toolsets = params
+ .getAll("toolsets")
+ .map((raw) => {
+ const [rawUrl, rawType = "HTTP"] = raw.split(",", 2);
+ try {
+ const url = new URL(rawUrl);
+ const type = rawType.toUpperCase() === "SSE" ? "SSE" : "HTTP";
+ if (url.protocol !== "https:" && url.protocol !== "http:") return null;
+ return {
+ connection: { type, url: url.href },
+ filters: [],
+ };
+ } catch {
+ return null;
+ }
+ })
+ .filter((v): v is { connection: { type: "HTTP" | "SSE"; url: string }; filters: string[] } => Boolean(v));🤖 Prompt for AI Agents
In apps/web/src/components/agent/chats.tsx around lines 63 to 73, the current
comma-split parsing of toolsets is brittle and unvalidated; update parsing to
split on the last comma (so commas in the URL are preserved), trim values,
normalize the connection type to uppercase and accept only "HTTP" or "SSE"
(default to "HTTP" if invalid), validate the URL by constructing a URL object
(or using a URL validation helper) and skip any entries with invalid URLs or
unsupported types, and ensure filters remains an empty array for dropped/invalid
entries so only well-formed toolset objects are returned.
| DECO_CHAT_API, | ||
| dispatchMessages, | ||
| getTraceDebugId, | ||
| Toolset, |
There was a problem hiding this comment.
Fix: import Toolset as a type to avoid runtime import errors.
Toolset is used only in type positions. Importing it as a value can emit a runtime import that @deco/sdk likely does not provide, causing bundling/runtime failures.
Apply:
- Toolset,
+ type Toolset,🤖 Prompt for AI Agents
In apps/web/src/components/agent/provider.tsx around line 8, the current import
brings in Toolset as a runtime value even though it is used only for typing,
which can cause bundling/runtime failures; change the import to a type-only
import (e.g., use the TypeScript "import type" form or otherwise mark Toolset as
a type-only import) so the compiler omits the runtime require and avoids
importing unavailable runtime exports from @deco/sdk.
Summary by CodeRabbit
New Features
Refactor