#Query on agent and agentId params in copilotkit
1 messages · Page 1 of 1 (latest)
This solution has been AI generated
Yes—you can set a default agent on the provider and/or specify agentId on each UI component. Using different agent names per component is supported and won’t break anything as long as those IDs exist in your runtime.
How agent and agentId work
- Provider (
<CopilotKit />): Optionalagentprop sets the default agent for all descendants. - Components (
<CopilotSidebar />,<CopilotChat />):agentIdtargets a specific backend agent. If omitted, they inherit from the provider; if none is set, they default to"default". - Recommendation: When using multiple agents (e.g., LangGraph/CoAgents), explicitly pass
agentIdto ensure each UI binds to the intended agent.
Can they be different per component?
Yes. You can point different components to different agents, enabling multi‑agent UIs.
<CopilotKit runtimeUrl="/api/copilotkit" agent="default">
<CopilotSidebar agentId="support-agent">
<YourApp />
</CopilotSidebar>
<CopilotChat agentId="research-agent" />
</CopilotKit>
Will that break anything?
- No, provided the frontend
agentIdvalues exactly match the agent names registered in your Copilot Runtime backend. - Thread behavior: Different
agentIds are independent by default. If you want shared history, pass the samethreadId; otherwise, each agent maintains its own conversation state.
Quick reference
<CopilotKit />agent: global default (defaults to"default").<CopilotSidebar />/<CopilotChat />agentId: per‑component override.
Was this helpful?
If this solution worked for you, please click on the appropriate option below to help us improve: