#Query on agent and agentId params in copilotkit

1 messages · Page 1 of 1 (latest)

hasty peak
#

Do we need to mention the agent and agentId in CopilotKit and CopilotSidebar respectively? If so can we have separate agent names for each? Will that break anything?

inner hawkBOT
#

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 />): Optional agent prop sets the default agent for all descendants.
  • Components (<CopilotSidebar />, <CopilotChat />): agentId targets 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 agentId to 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 agentId values 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 same threadId; 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: