feature: Pi support — detection, settings, parsed events, token and cost accounting
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 24/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go, node.js, typescript
- Área
- api, backend, devtools, documentation
Línea de trabajo
Start by running Pi under agentop exec against Anthropic with API key and OAuth, and OpenAI; record its User-Agents, headers, and paths. Then read core/pipeline/client.go, the session ID handling in core/session/idheader.go, core/config/config.go, and cmd/cortex/local.go, plus the existing OpenCode and Codex configuration and docs. Done means Pi routing, detection, session grouping, parsed events and accounting are covered, and docs/agents/pi.md is linked from both READMEs with verified support limits.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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 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.
- Lenguaje dominante
- Go
- Estrellas
- 18
- Forks
- 42
- Merge medio
- 12 h 31 min
- PR fusionados (30 d)
- 258
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rossoctl/cortex
-
UI shows costs for all sessions even when drilled into a sessionPosiblemente ocupada @esnible la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
rossoctl/cortex#1116 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
enhancement laptop
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
enhancement laptop
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
laptop
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
rossoctl/cortex#1437 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Support mTLS for Session APIAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 22/100
Los mantenedores suelen responder en 1 día
Todos los issues de rossoctl/cortex
Issues similares
-
automation models
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
mvanhorn/cli-printing-press#5146 ·
Los mantenedores suelen responder en 1 día
-
.jsonc files are skippedAbiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
alibaba/open-code-review#1800 ·
Los mantenedores suelen responder en 1 día
-
kind/engineering needs-triage pulumi/registry R2 S2 Task
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día