feature: Pi support — detection, settings, parsed events, token and cost accounting
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 24/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- go, node.js, typescript
- 領域
- api, backend, devtools, documentation
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Go
- スター
- 18
- フォーク
- 42
- 平均マージ
- 12時間 31分
- マージ済み PR(30日)
- 258
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rossoctl/cortex のほかの issue
-
UI shows costs for all sessions even when drilled into a session対応中かも @esnible が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
rossoctl/cortex#1116 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
enhancement laptop
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
enhancement laptop
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
laptop
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
rossoctl/cortex#1437 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 22/100
メンテナーはふだん 1 日以内に返信
rossoctl/cortex の issue をすべて見る
似ている issue
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
kube-tarian/sigrun#202 ·
-
question raised-by:verifier
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
medici-finance/assay#4013 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
tsukumogami/tsuku#2775 ·
メンテナーはふだん 1 日以内に返信
-
automation models
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
メンテナーはふだん 1 日以内に返信