mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
164b53ebcb
Keeps the isolation fix and removes the concurrency mechanism, which two landings on main superseded while this branch was open. Isolation (kept, narrowed): - Clone the result of an `agent: (threadId) => ...` factory as well as the singleton config. #6256 already isolated the singleton path; a factory returning a shared instance was still handed to every turn un-isolated, carrying the previous turn's messages and lifecycle flags and serializing those turns behind one identity key in DeliveryAdapter.acquireAgent. - Reset `isRunning` / `abortController` on the clone as hygiene. Documented as such: `runAgent` reassigns `abortController` before every run, so an inherited aborted controller cannot by itself kill a follow-up turn. - Drop the `activeRunDetach$` / `activeRunCompletionPromise` resets. `clone()` copies a fixed field list that excludes both, so they were always undefined. - Document that `AbstractAgent.prototype.clone()` drops subclass-declared fields silently, and correct the clone() error text: a factory no longer bypasses cloning, so it is not an escape hatch. Concurrency mechanism (removed): - Restore `runner.run/stop({ threadId: canonicalThreadId })`. IntelligenceAgentRunner does not use this as a local map key; it sends it as `thread_id` when joining `ingestion:<runId>`, and the gateway resolves it against `cpki.threads`, so a `<threadId>::<runId>` value fails the join with `thread_not_found`. Added a regression guard asserting the canonical id. - Restore the unprefixed product thread lock. The gateway derives this same key in four places and reads its value as "which run is active on this thread". It is also the only mutual exclusion spanning runtime replicas, since DeliveryTransport's per-thread admission gate (#6257) is instance state. Also: - Forward `lockKeyPrefix` on cleanup in both the channel path and handlers/intelligence/run.ts, so a configured prefix releases the key it acquired instead of leaking it. - Collapse the four copy-pasted clone-patching test scaffolds into one `patchAgentAndClones` helper.