{{ message }}
Conversation
Contributor
Contributor
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
…ConfigurationProvider returns a clone, not the registry singleton useAgent is documented to preserve the original singleton behavior when no threadId is passed, but `threadId ??= chatConfig?.threadId` silently pulls a threadId from any surrounding CopilotChatConfigurationProvider (which <CopilotChat> always installs), routing the caller onto the clone path. The `if (!threadId) return existing` branch becomes dead code in that tree. Adds one failing test that pins the identity break and one passing test confirming that callers under the same provider at least converge on the same clone via the module-level globalThreadCloneMap. The failing test is intentional — committed with --no-verify so the failure is preserved as a tracked regression until the no-threadId singleton path is restored.
43de9f1 to
6e0ed79
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
use-agent-thread-isolation.test.tsx. One is intentionally failing — it pins a real regression and must not be resolved by editing the test. Committed with--no-verifyto preserve the failure.What broke
useAgent({ agentId })used to return the registry singleton — one object shared across the entire app for a givenagentId. The hook still advertises that behavior when nothreadIdis passed:But a few lines earlier the hook silently adopts a
threadIdfrom any surroundingCopilotChatConfigurationProvider:<CopilotChat>always installs that provider for its children (and auto-mints a UUID when nothreadIdprop is given). So anywhere inside a chat tree, auseAgent({ agentId })call:if (!threadId) return existingbranch,copilotkit.getAgent(agentId)or with auseAgent({ agentId })call rendered outside the provider.Net effect: the documented "original behavior" branch is effectively dead code in real apps, and state mutations made through the registry agent (or through a
useAgentcall outside the chat tree) are invisible to callers inside it.What the tests prove
BROKEN: useAgent({ agentId }) under CopilotChatConfigurationProvider returns a clone, not the registry singleton— failing. Renders two trackers, one inside aCopilotChatConfigurationProviderand one outside, both callinguseAgent({ agentId })with nothreadId. Asserts:registeredAgent✓registeredAgent✗ (fails — it's a clone withthreadId: "conversation-1")two useAgent({ agentId }) calls under the same provider share one clone— passing. Confirms identity is consistent inside a single provider: both callers resolve to the same clone via the module-levelglobalThreadCloneMap. This rules out "multiple clones per provider" as an explanation for the break in test (1) and isolates the regression to the provider boundary itself.Repro
pnpm --filter @copilotkit/react-core exec vitest run \ src/v2/hooks/__tests__/use-agent-thread-isolation.test.tsxExpected output: 11 tests, 1 failed. Diff on the failing assertion:
Test plan