@copilotkitnext/core 1.54.0-next.6 → 1.54.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +25 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +23 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +25 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +25 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -816,7 +816,8 @@ var RunHandler = class {
|
|
|
816
816
|
if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this._internal.headers };
|
|
817
817
|
const runAgentResult = await agent.connectAgent({
|
|
818
818
|
forwardedProps: this._internal.properties,
|
|
819
|
-
tools: this.buildFrontendTools(agent.agentId)
|
|
819
|
+
tools: this.buildFrontendTools(agent.agentId),
|
|
820
|
+
context: Object.values(this._internal.context)
|
|
820
821
|
}, this.createAgentErrorSubscriber(agent));
|
|
821
822
|
return this.processAgentResult({
|
|
822
823
|
runAgentResult,
|
|
@@ -891,7 +892,10 @@ var RunHandler = class {
|
|
|
891
892
|
}
|
|
892
893
|
}
|
|
893
894
|
}
|
|
894
|
-
if (needsFollowUp)
|
|
895
|
+
if (needsFollowUp) {
|
|
896
|
+
await this._internal.waitForPendingFrameworkUpdates();
|
|
897
|
+
return await this.runAgent({ agent });
|
|
898
|
+
}
|
|
895
899
|
this._internal.suggestionEngine.reloadSuggestions(agentId);
|
|
896
900
|
return runAgentResult;
|
|
897
901
|
}
|
|
@@ -1172,6 +1176,7 @@ var RunHandler = class {
|
|
|
1172
1176
|
};
|
|
1173
1177
|
agent.messages.push(userMessage);
|
|
1174
1178
|
}
|
|
1179
|
+
await this._internal.waitForPendingFrameworkUpdates();
|
|
1175
1180
|
await this.runAgent({ agent });
|
|
1176
1181
|
}
|
|
1177
1182
|
return {
|
|
@@ -1685,6 +1690,24 @@ var CopilotKitCore = class {
|
|
|
1685
1690
|
buildFrontendTools(agentId) {
|
|
1686
1691
|
return this.runHandler.buildFrontendTools(agentId);
|
|
1687
1692
|
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Called before each follow-up agent run (after tool execution).
|
|
1695
|
+
*
|
|
1696
|
+
* When a frontend tool handler calls framework state setters (e.g. React's
|
|
1697
|
+
* setState), those updates are batched and deferred — they do not take effect
|
|
1698
|
+
* until the framework's scheduler runs (React uses MessageChannel).
|
|
1699
|
+
* useAgentContext registers context via useLayoutEffect, which runs
|
|
1700
|
+
* synchronously after React commits that deferred batch.
|
|
1701
|
+
*
|
|
1702
|
+
* Without yielding here, the follow-up runAgent reads the context store
|
|
1703
|
+
* synchronously while the deferred updates are still pending, producing stale
|
|
1704
|
+
* context for the next agent turn.
|
|
1705
|
+
*
|
|
1706
|
+
* Override in framework-specific subclasses to yield to the framework
|
|
1707
|
+
* scheduler before the follow-up run. The base implementation is a no-op
|
|
1708
|
+
* because non-React environments have no deferred state to flush.
|
|
1709
|
+
*/
|
|
1710
|
+
async waitForPendingFrameworkUpdates() {}
|
|
1688
1711
|
};
|
|
1689
1712
|
|
|
1690
1713
|
//#endregion
|