Skip to content
PidocsCLI & tooling

Investigate how pi passes context to Codex vs Anthropic

Session from pi-mono-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk

1msession
0interventions
GOAL

Understand how the pi coding agent passes context to OpenAI Codex, whether it matches the Anthropic integration, and whether prompt caching is used.

  1. Prompt · +0
    How is pi currently passing context to codex? Is it the same as with Anthropic? Do we have prompt caching?
  2. Agent did · +0m
    Searched pi-coding-agent source and README for 'codex' and 'cache' references, found a note about prompt cache stored under ~/.pi/agent/cache/openai-codex/
  3. Agent did · +0m
    Traced the openai-codex and openai-codex-responses provider modules in pi-ai's dist folder, looking for prompt_cache_key usage and comparing to the Anthropic streaming implementation
  4. Agent did · +1m
    Read pi's agent-session.ts and sdk.ts source to see how session history and message content (including image filtering) are converted into context for the model
  5. Outcome · +1m
    Explained that pi builds a generic Context and transforms it into OpenAI Responses format for Codex, using function_call/reasoning items and downloading/caching official Codex instructions locally under ~/.pi/agent/cache/openai-codex/, contrasting with the Anthropic messages path
VERDICT

Next time I'd start by asking directly for the diff between the Anthropic and Codex provider adapters in pi-ai instead of grepping blindly through node_modules. The useful thread was tracing prompt_cache_key and the local cache directory reference in the README, which confirmed Codex has its own caching scheme separate from Anthropic's.

I tried this · 0

Discussion · 0

How Builds work