@copilotkitnext/core 1.54.0-next.6 → 1.54.0-next.7
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 +23 -1
- 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 +23 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +23 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -891,7 +891,10 @@ var RunHandler = class {
|
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
|
-
if (needsFollowUp)
|
|
894
|
+
if (needsFollowUp) {
|
|
895
|
+
await this._internal.waitForPendingFrameworkUpdates();
|
|
896
|
+
return await this.runAgent({ agent });
|
|
897
|
+
}
|
|
895
898
|
this._internal.suggestionEngine.reloadSuggestions(agentId);
|
|
896
899
|
return runAgentResult;
|
|
897
900
|
}
|
|
@@ -1172,6 +1175,7 @@ var RunHandler = class {
|
|
|
1172
1175
|
};
|
|
1173
1176
|
agent.messages.push(userMessage);
|
|
1174
1177
|
}
|
|
1178
|
+
await this._internal.waitForPendingFrameworkUpdates();
|
|
1175
1179
|
await this.runAgent({ agent });
|
|
1176
1180
|
}
|
|
1177
1181
|
return {
|
|
@@ -1685,6 +1689,24 @@ var CopilotKitCore = class {
|
|
|
1685
1689
|
buildFrontendTools(agentId) {
|
|
1686
1690
|
return this.runHandler.buildFrontendTools(agentId);
|
|
1687
1691
|
}
|
|
1692
|
+
/**
|
|
1693
|
+
* Called before each follow-up agent run (after tool execution).
|
|
1694
|
+
*
|
|
1695
|
+
* When a frontend tool handler calls framework state setters (e.g. React's
|
|
1696
|
+
* setState), those updates are batched and deferred — they do not take effect
|
|
1697
|
+
* until the framework's scheduler runs (React uses MessageChannel).
|
|
1698
|
+
* useAgentContext registers context via useLayoutEffect, which runs
|
|
1699
|
+
* synchronously after React commits that deferred batch.
|
|
1700
|
+
*
|
|
1701
|
+
* Without yielding here, the follow-up runAgent reads the context store
|
|
1702
|
+
* synchronously while the deferred updates are still pending, producing stale
|
|
1703
|
+
* context for the next agent turn.
|
|
1704
|
+
*
|
|
1705
|
+
* Override in framework-specific subclasses to yield to the framework
|
|
1706
|
+
* scheduler before the follow-up run. The base implementation is a no-op
|
|
1707
|
+
* because non-React environments have no deferred state to flush.
|
|
1708
|
+
*/
|
|
1709
|
+
async waitForPendingFrameworkUpdates() {}
|
|
1688
1710
|
};
|
|
1689
1711
|
|
|
1690
1712
|
//#endregion
|