Skip to content

Commit eedc57a

Browse files
committed
Apply PR CopilotKit#4430
1 parent 9a7ca02 commit eedc57a

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

docs/content/docs/(root)/programmatic-control.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ Programmatic control lets you run agents outside of a chat UI — trigger agent
3434
</Tab>
3535
</Tabs>
3636

37+
<Callout type="info">
38+
Note: If you are not using CopilotKit Cloud public access/license key, then you need to pass your agentId to useAgent() hook.
39+
```ts
40+
const { agent } = useAgent({agentId: "myAgent"})
41+
````
42+
43+
</Callout>
44+
3745
You can also execute individual tools programmaticallyno LLM turn needed:
3846

3947
<Tabs items={['tool-button.tsx']}>

docs/snippets/shared/basics/programmatic-control.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Use `copilotkit.runAgent()` to trigger your agent from any component — no chat
4141
```tsx title="page.tsx"
4242
import { useAgent } from "@copilotkit/react-core/v2";
4343
import { useCopilotKit } from "@copilotkit/react-core/v2";
44-
import { randomUUID } from "@copilotkit/shared/v2";
44+
import { randomUUID } from "@copilotkit/shared";
4545

4646
export function AgentTrigger() {
4747
const { agent } = useAgent();

docs/snippets/use-agent.mdx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
return (
2222
<div>
2323
{/* [!code highlight:4] */}
24-
<p>Agent ID: {agent.id}</p>
24+
<p>Agent ID: {agent.agentId}</p>
2525
<p>Thread ID: {agent.threadId}</p>
2626
<p>Status: {agent.isRunning ? "Running" : "Idle"}</p>
2727
<p>Messages: {agent.messages.length}</p>
@@ -30,6 +30,13 @@
3030
}
3131
```
3232

33+
<Callout type="info">
34+
Note: If you are not using CopilotKit Cloud public access/license key, then you need to pass your agentId to useAgent() hook.
35+
```ts
36+
const { agent } = useAgent({agentId: "myAgent"})
37+
```
38+
</Callout>
39+
3340
The hook will throw an error if no agent is configured, so you can safely use `agent` without null checks.
3441
</Step>
3542

@@ -91,7 +98,7 @@
9198
```tsx title="page.tsx"
9299
import { useAgent } from "@copilotkit/react-core/v2";
93100
import { useCopilotKit } from "@copilotkit/react-core/v2";
94-
import { randomUUID } from "@copilotkit/shared/v2";
101+
import { randomUUID } from "@copilotkit/shared";
95102

96103
export function RunAgent() {
97104
const { agent } = useAgent();
@@ -209,7 +216,7 @@ export function EventLogger() {
209216
// [!code highlight:2]
210217
const { unsubscribe } = agent.subscribe(subscriber);
211218
return () => unsubscribe();
212-
}, []);
219+
}, [agent]);
213220

214221
return null;
215222
}

0 commit comments

Comments
 (0)