Investigate how pi passes context to Codex vs Anthropic
Session from pi-mono-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk
Click a segment to jump to that moment
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.
- +0Prompt · +0How is pi currently passing context to codex? Is it the same as with Anthropic? Do we have prompt caching?
- +0mAgent did · +0mSearched pi-coding-agent source and README for 'codex' and 'cache' references, found a note about prompt cache stored under ~/.pi/agent/cache/openai-codex/
- +0mAgent did · +0mTraced 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
- +1mAgent did · +1mRead 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
- +1mOutcome · +1mExplained 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.