Repository navigation
Description
Feature Description
Pi (earendil-works/pi, formerly
badlogic/pi-mono) is a terminal coding agent. Cortex should support it as fully as Claude
Code, OpenCode, Codex and Bob: one agentop configure pi command to route it, its own row in
the Agents pane, its own sessions, correct tokens and cost, and a guide.
Today Pi can only run under agentop exec -- pi, which is the "any other agent" fallback.
Even there it does not work well. Read off Pi's source on main (latest release v1.3.0,
2026-10-15):
- Cortex does not recognise Pi. Pi's User-Agent is
pi (<platform> <release>; <arch>),
for examplepi (darwin 25.6.0; arm64)(packages/ai/src/utils/pi-user-agent.ts). It has
no/version, andcore/pipeline/client.gohas no entry for it, so Pi gets no agent row
and no version. - Pi on a Claude subscription looks like Claude Code. When Pi signs in to Anthropic with
OAuth (/loginwith a Pro or Max plan), it sendsuser-agent: claude-cli/<version>and
x-app: cli(packages/ai/src/api/anthropic-messages.ts). Cortex would then put Pi's
traffic and spend in Claude Code's row. Pi has to be told apart from real Claude Code by
some other signal. - Pi sends no session id by default. Pi has a session id (
PI_SESSION_ID, the id
/sessionshows), but it sends it only as a session-affinity header:x-session-idfor
OpenRouter, andx-session-affinity,x-client-request-idandsession_idin the
openaiformat. These go out only when the model'scompat.sendSessionAffinityHeaders
is set, which by default is true only for OpenRouter. With direct Anthropic or OpenAI,
Cortex has no session id and groups Pi's traffic by process instead of by conversation.
(Separately,core/session/idheader.go,core/config/config.goandcmd/cortex/local.go
say "Pi (Inflection AI)" sendsX-Session-Id. Inflection's Pi is a different product,
and this Pi sends that header only to OpenRouter. Fix those comments as part of this
issue.) - Some of Pi's wire formats are not parsed. Pi has an API module per provider:
anthropic-messages,openai-completions,openai-responses,openai-codex-responses,
azure-openai-responses,google-generative-ai,google-vertex,
bedrock-converse-stream,mistral-conversations, and its ownpi-messages. Cortex parses
the Anthropic Messages, OpenAI Chat Completions and Responses formats. With any other
provider, Pi's requests are proxied but not counted. - Nothing routes it. Pi reads
HTTP_PROXY/HTTPS_PROXY(undici's
EnvHttpProxyAgent). It also has anhttpProxysetting in~/.pi/agent/settings.json
that is applied as those variables at startup, and does not override them if they are
already set (commit9105085, for Support httpProxy in settings.json for EnvHttpProxyAgent earendil-works/pi#5790). Pi runs on Node 22.19+, so the
CA comes fromNODE_EXTRA_CA_CERTS, which Node reads only at process start, so a settings
file cannot supply it. Pi's agent directory is~/.pi/agent, orPI_CODING_AGENT_DIR.
Proposed Solution
The same checklist as OpenCode (#941) and Codex (#942):
- Detect an installed Pi and locate its settings (
PI_CODING_AGENT_DIR, else~/.pi/agent) -
agentop configure pi enable | disable | status: route Pi throughlocalhost:47600
and the Cortex CA. Ask before editing, refuse to overwrite a proxy someone else set,
and support revert. The CA needs a mechanism, becausehttpProxyalone cannot supply it - Recognise Pi's User-Agent as agent
pi, including in the OAuth case where it sends
claude-cli/…, so Pi's spend never lands in Claude Code's row - Group Pi's traffic by Pi's own session, not by process
- Traffic is parsed into typed events, not merely proxied, for the providers Pi is
commonly used with. Any provider that is not parsed is listed in the guide - Token counts and cost are correct for each parsed wire format
- Session and cost metrics aggregate alongside the other agents (
agentop cost --by agent,
the Agents pane, the inference-router's agent names) - A tool inventory for Pi, or an explicit statement that tool pruning is unsupported for it
- Pi is covered everywhere the other agents are:
agentop configurewith no arguments,
its status report, andagentop uninstall's unroute step - A row in the root README's Supported agents table
Required artifact: a doc for Pi
This issue does not close on code alone. The doc is a deliverable like the code: it
ships in the same PR, or in a linked PR merged before this issue closes. A PR description or
a comment here does not count.
It is docs/agents/pi.md in this repo, linked from the root README's Supported agents
table and from docs/README.md. It follows the outline of docs/agents/opencode.md and
docs/agents/codex.md:
- Enable and revert: the
agentop configure picommands, which file each one
writes, and how to undo it by hand - CA trust: what Pi needs to trust the Cortex CA, and the symptom when it does not
- What Cortex shows for it: which events are typed, which token and cost fields are
filled, which providers and wire formats are parsed, and what is partial or unsupported
(e.g. tool pruning) - Verified depth: the Pi versions, providers and platforms actually tested, and what
was not - Known issues specific to Pi
cmd/agentop/README.md can carry the command reference too; it does not replace this page.
Additional Context
Everything above was read from Pi's source and docs, not captured from a live Pi through
Cortex. The first step is to run Pi under agentop exec against Anthropic (API key and OAuth)
and OpenAI, and record its real User-Agents, headers and paths, the way the OpenCode and Codex
entries in core/pipeline/client.go were captured.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs: Add Pi support design (#1458)
feat: Support Pi as a coding agent (#1458)