Skip to main content

shared_client

Function shared_client 

Source
pub fn shared_client() -> Result<Arc<dyn LLMClientDyn>>
Expand description

Process-wide shared Codex client (retry-wrapped), built once on first use.

The token store is inherently process-global — there is a single ~/.codex/auth.json and a single live token chain — so every Codex reviewer/aggregator must share ONE CodexClient. Per-client caches would each hold their own in-memory refresh token; after a rotation, one client’s fresh token would be invisible to the others, and a concurrent refresh on the stale disk token could fail. Sharing one instance gives a single token cache with working concurrent-refresh dedup.