mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
27827adee2
Writing a per-hook threadId onto an agent resolved by agentId alone mutates a shared singleton, so two useAgent calls that share an agentId clobber each other's thread (review feedback from @mme). Require runtimeAgentId when threadId is provided: the hook then registers a private proxied agent (agentId -> runtimeAgentId via CopilotKitCore.registerProxiedAgent) and scopes the threadId to that instance instead of a shared one. Register/unregister run as one balanced, StrictMode-safe effect, exposing the proxy via state so the hook swaps from the provisional stand-in deterministically. Passing threadId without runtimeAgentId now throws. Updates the React Native demo to the new API. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>