React use-agent re-applies headers on header value changes instead of the headers generation
Author: BenTaylorDevCreated Sep 29, 2026Updated Sep 29, 2026
Labelshygiene
packages/react-core/src/v2/hooks/use-agent.tsx (around lines 369 and 442) re-runs applyHeadersToAgent when JSON.stringify(copilotkit.headers) changes.
After #7510, a new token from a headers builder updates that snapshot, so these effects re-run after token rotations. This is harmless, because the call only applies a snapshot and never calls the builder. But it breaks the rule used everywhere else in #7510: key header-driven work on copilotkit.ɵheadersGeneration, which changes only on setHeaders() or a new source.
Fix: switch both dependencies to copilotkit.ɵheadersGeneration.
Source: CopilotKit/CopilotKit