7acadae
CopilotKitDocs
  • Docs
  • Integrations
  • Reference
Get Started
QuickstartCoding Agents
Concepts
ArchitectureGenerative UI OverviewOSS vs Enterprise
Agentic Protocols
OverviewAG-UIAG-UI MiddlewareMCPA2A
Build Chat UIs
Prebuilt Components
CopilotChatCopilotSidebarCopilotPopup
Custom Look and Feel
CSS CustomizationSlots (Subcomponents)Fully Headless UIReasoning Messages
Multimodal AttachmentsVoice
Build Generative UI
Controlled
Tool-based Generative UITool RenderingState RenderingReasoning
Your Components
Display ComponentsInteractive Components
Declarative
A2UIDynamic Schema A2UIFixed Schema A2UI
Open-Ended
MCP Apps
Adding Agent Powers
Frontend ToolsShared State
Human-in-the-Loop
HITL OverviewPausing the Agent for InputHeadless Interrupts
Sub-AgentsAgent ConfigProgrammatic Control
Agents & Backends
Built-in Agent
Backend
Copilot RuntimeFactory ModeAG-UI
Runtime Server AdapterAuthentication
Built-in Agent (TanStack AI)
Advanced ConfigurationMCP ServersModel SelectionServer Tools
Observe & Operate
InspectorVS Code Extension
Troubleshooting
Common Copilot IssuesError Debugging & ObservabilityDebug ModeAG-UI Event InspectorHook ExplorerError Observability Connectors
Enterprise
CopilotKit PremiumHow the Enterprise Intelligence Platform WorksHow Threads & Persistence WorkObservabilitySelf-Hosting IntelligenceThreads
Deploy
AWS AgentCore
What's New
Full MCP Apps SupportLangGraph Deep Agents in CopilotKitA2UI Launches with full AG-UI SupportCopilotKit v1.50Generative UI Spec SupportA2A and MCP Handshake
Migrate
Migrate to V2Migrate to 1.8.2
Other
Contributing
Code ContributionsDocumentation Contributions
Anonymous Telemetry
Built-in Agent (TanStack AI)Advanced Configuration

Advanced Configuration

Fine-tune your Built-in Agent's behavior with advanced options.

The BuiltInAgent accepts a full set of configuration options to control model behavior, tool calling, and more.

Multi-step tool calling#

By default, the agent performs a single generation step. Set maxSteps to allow the agent to call tools and then continue reasoning:

src/copilotkit.ts
typescript
const agent = new BuiltInAgent({
  model: "openai:gpt-5.4-mini",
  maxSteps: 5, // [!code highlight]
  tools: [searchDocs, createTicket],
});

With maxSteps: 5, the agent can call a tool, process the result, call another tool, and so on — up to 5 iterations. This is essential for workflows where the agent needs to chain multiple tool calls.

Tool choice#

Control how the agent selects tools:

const agent = new BuiltInAgent({
  model: "openai:gpt-5.4-mini",
  toolChoice: "auto",       // Let the model decide (default)
  // toolChoice: "required", // Force the model to call a tool
  // toolChoice: "none",     // Disable tool calling
  // toolChoice: { type: "tool", toolName: "searchDocs" }, // Force a specific tool
});

System prompt#

Customize the agent's system prompt:

const agent = new BuiltInAgent({
  model: "openai:gpt-5.4-mini",
  prompt: "You are a customer support agent for Acme Corp. Be concise and helpful. Always check the knowledge base before answering.", // [!code highlight]
});

Generation parameters#

Fine-tune the model's output:

const agent = new BuiltInAgent({
  model: "openai:gpt-5.4-mini",
  temperature: 0.7,        // Creativity (0 = deterministic, 1+ = creative)
  topP: 0.9,               // Nucleus sampling
  topK: 40,                // Top-K sampling (provider-dependent)
  maxOutputTokens: 4096,   // Maximum tokens in the response
  presencePenalty: 0.1,    // Penalize repeated topics
  frequencyPenalty: 0.1,   // Penalize repeated tokens
  stopSequences: ["END"],  // Stop generation at these sequences
  seed: 42,                // Deterministic output (provider-dependent)
  maxRetries: 3,           // Retry on transient failures
});
Info

Not all parameters are supported by every provider. For example, topK is supported by Google but not OpenAI. Unsupported parameters are ignored.

Provider-specific options#

Pass options specific to a model provider using providerOptions:

// OpenAI reasoning models (o3, o4-mini) with reasoning effort
const agent = new BuiltInAgent({
  model: "openai:o3",
  providerOptions: { // [!code highlight:3]
    openai: { reasoningEffort: "high" },
  },
});
// Anthropic with extended thinking
const agent = new BuiltInAgent({
  model: "anthropic:claude-sonnet-4-5",
  providerOptions: { // [!code highlight:3]
    anthropic: { thinking: { type: "enabled", budgetTokens: 10000 } },
  },
});

Overridable properties#

Allow the frontend to override specific configuration at runtime. This is useful when you want users to switch models or adjust behavior without redeploying:

const agent = new BuiltInAgent({
  model: "openai:gpt-5.4-mini",
  temperature: 0.5,
  overridableProperties: ["model", "temperature", "prompt"], // [!code highlight]
});

The full list of overridable properties: model, toolChoice, maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, stopSequences, seed, maxRetries, prompt, providerOptions

Message forwarding#

Control whether system and developer messages from the conversation are forwarded to the LLM:

const agent = new BuiltInAgent({
  model: "openai:gpt-5.4-mini",
  forwardSystemMessages: true,    // Forward system-role messages
  forwardDeveloperMessages: true, // Forward developer-role messages (as system messages)
});

Full configuration reference#

PropertyTypeDefaultDescription
modelstring | LanguageModel—Model specifier or AI SDK instance
apiKeystringenv varAPI key for the provider
maxStepsnumber1Max tool-calling iterations
toolChoice"auto" | "required" | "none" | { type: "tool", toolName: string }"auto"How tools are selected
maxOutputTokensnumber—Max tokens in response
temperaturenumber—Sampling temperature
topPnumber—Nucleus sampling
topKnumber—Top-K sampling
presencePenaltynumber—Presence penalty
frequencyPenaltynumber—Frequency penalty
stopSequencesstring[]—Stop sequences
seednumber—Random seed
maxRetriesnumber—Retry count
promptstring—System prompt
toolsToolDefinition[][]Server-side tools
mcpServersMCPClientConfig[][]MCP server connections (agent-managed, per-request)
mcpClientsMCPClientProvider[][]User-managed MCP clients (persistent, user controls lifecycle)
overridablePropertiesstring[][]Properties the frontend can override
providerOptionsRecord<string, any>—Provider-specific options
forwardSystemMessagesbooleanfalseForward system messages
forwardDeveloperMessagesbooleanfalseForward developer messages
Need even more control?

If BuiltInAgent's configuration options don't cover your needs — for example, if you want to use TanStack AI, a custom LLM backend, or async initialization — see Custom Agent.

On this page
Multi-step tool callingTool choiceSystem promptGeneration parametersProvider-specific optionsOverridable propertiesMessage forwardingFull configuration reference