Skip to content

Commit 700535f

Browse files
committed
fix suggestions bug
1 parent e3b8a73 commit 700535f

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

apps/react/demo/src/app/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ function Chat() {
6969
{ id: "thread---c", label: "Thread C" },
7070
];
7171

72+
useConfigureSuggestions({
73+
instructions: "Suggest follow-up tasks based on the current page content",
74+
});
75+
7276
useAgentContext({ description: "The current Thread ID is:", value: selectedThreadId });
7377

7478
//useConfigureSuggestions({

apps/react/demo/src/app/single/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
CopilotKitProvider,
66
useFrontendTool,
77
defineToolCallRenderer,
8+
useConfigureSuggestions,
89
} from "@copilotkitnext/react";
910
import type { ToolsMenuItem } from "@copilotkitnext/react";
1011
import { z } from "zod";
@@ -69,6 +70,10 @@ function Chat() {
6970
},
7071
});
7172

73+
useConfigureSuggestions({
74+
instructions: "Suggest follow-up tasks based on the current page content",
75+
});
76+
7277
const toolsMenu = useMemo<(ToolsMenuItem | "-")[]>(
7378
() => [
7479
{
@@ -103,4 +108,3 @@ function Chat() {
103108

104109
return <CopilotChat inputProps={{ toolsMenu }} threadId="xyz" />;
105110
}
106-

packages/core/src/core/suggestion-engine.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export class SuggestionEngine {
124124
): Promise<void> {
125125
let agent: AbstractAgent | undefined = undefined;
126126
try {
127-
const suggestionsProviderAgent = (this.core as unknown as CopilotKitCoreFriendsAccess).getAgent(config.providerAgentId ?? "default");
127+
const suggestionsProviderAgent = (this.core as unknown as CopilotKitCoreFriendsAccess).getAgent(
128+
config.providerAgentId ?? "default",
129+
);
128130
if (!suggestionsProviderAgent) {
129131
throw new Error(`Suggestions provider agent not found: ${config.providerAgentId}`);
130132
}
@@ -135,7 +137,7 @@ export class SuggestionEngine {
135137

136138
const clonedAgent: AbstractAgent = suggestionsProviderAgent.clone();
137139
agent = clonedAgent;
138-
agent.agentId = suggestionId;
140+
//agent.agentId = suggestionId;
139141
agent.threadId = suggestionId;
140142
agent.messages = JSON.parse(JSON.stringify(suggestionsConsumerAgent.messages));
141143
agent.state = JSON.parse(JSON.stringify(suggestionsConsumerAgent.state));

0 commit comments

Comments
 (0)