Third-Party Harnesses
Claude Code and Codex write every session to files on this computer. OpenProgram reads those files and shows the sessions, tokens and estimated cost, plus the Codex plan quota its app-server last reported.
Reading changes no harness's configuration, sits in no request path and sends nothing anywhere. Running a harness on OpenProgram's models is the Model Gateway.
| Part | Where |
|---|---|
| Readers | openprogram/models/usage/harnesses/claude_code.py, codex.py |
| Incremental reading | openprogram/state/store/appended_lines.py |
| Index | openprogram/models/usage/harnesses/store.py, <state>/harnesses.db |
| Prices | openprogram/models/usage/harnesses/pricing.py |
| Report | openprogram/models/usage/harnesses/report.py, GET /api/usage/harnesses |
| Page | apps/web/components/settings/third-party-harnesses/ |
Decisions and the peers they come from
magpie (yetone/magpie) reads the same files beside its gateway; Paseo (getpaseo/paseo) lists them to import sessions and shows plan quota; T3 Code (pingdotgg/t3code) does both and prices every call.
| Question | magpie | Paseo | T3 Code | OpenProgram |
|---|---|---|---|---|
| Subagent files | Read, counted toward the parent | Skipped | Read | Read, counted toward the parent |
| Resuming a file | Offset, checked by 16 sampled windows | No offsets | Offset, checked by the 64 bytes before it | T3 Code's check: a rewrite anywhere before the offset is caught |
| Counting a call once | Inside one file, in a window of about a thousand messages | Not counted | One key across all files | One key across all files, oldest file first |
| Price source | models.dev | None | LiteLLM | models.dev, the catalogue OpenProgram already uses |
| Long-context tier | Ignored | — | Applied | Applied |
| Deleted transcripts | Dropped | — | Kept | Kept, 92 days |
| Codex quota | Live endpoint | Live endpoint | Live endpoint | What Codex reports: its app-server's account/rateLimits/read at start, then account/rateLimits/updated, or its rollout files' rate_limits, whichever is newer |
| Claude quota | Live endpoint | Claude Code's sign-in | Claude Code's sign-in | Not shown |
| When it reads | Polls every 10–15 s | On request | On request | At Worker start, then when the page asks |
| Which app started a session | Not shown | Not shown | Not shown | Shown |
Claude quota is not shown because reading it means using Claude Code's sign-in against Anthropic's usage endpoint; OpenProgram reaches Anthropic only through the official API with an API key.
Which files
| Harness | Read |
|---|---|
| Claude Code | $CLAUDE_CONFIG_DIR or ~/.claude: projects/<folder>/<session>.jsonl, and every *.jsonl under <session>/subagents/ except a workflow's journal.jsonl |
| Codex | $CODEX_HOME or ~/.codex: rollout-*.jsonl and rollout-*.jsonl.zst under sessions/ and archived_sessions/; names from session_index.jsonl |
The first scan skips files last changed more than 92 days ago. A home reached twice through a link is read once.
Reading only what was appended
- Mark
- Per file: size, modification time, the offset after its last complete line, and a hash of the 64 bytes before that offset.
- Resume
- A file that grew and whose 64 bytes still match is read from the offset; one that shrank or changed is read from the start.
- Partial line
- A last line without its newline waits for the next scan.
- Archive
- A zstd archive is read whole, and again only when its size or time changes.
- Markers
- A line is parsed only when it holds a marker (
"usage",token_count, a title record), so tool output and images are skipped as bytes. - Timing
- The Worker scans at start, in the background, and again when the page asks and the last scan is older than 5 seconds; one scan at a time. The open page asks every 10 seconds.
On this computer the first scan, 8.6 GB of Claude Code files and 4.7 GB of Codex rollouts, took 37 seconds; the next took 0.04 seconds, and a 30-day report 0.2 seconds.
Counting each call once
| Harness | One call is |
|---|---|
| Claude Code | An assistant line with message.usage, keyed message.id + requestId. Claude Code repeats the usage on each content block and copies lines into resumed and forked sessions; copies keep the largest value of each token kind and the earliest time. Model <synthetic> is not a call. |
| Codex | A token_usage_record, keyed by its response_id. A file without them counts each token_count's last_token_usage, skipping one whose running total did not move, keyed by its time and size so a fork's copied history counts once. |
- Tokens
- Input without cache, cache read, cache write (5-minute and 1-hour apart for Claude), output. Codex input is
input − cached − cache_write; reasoning is inside output. - Model
- Claude
message.model; Codexturn_context.model. - Speed
- Claude
usage.speed; Codexservice_tierpriorityorfast. - App
- Claude
entrypoint(cli,claude-desktop,sdk-ts, …); Codexsession_meta.originator. It tells sessions a person ran from sessions another app drove through an SDK.
Sessions
| Field | From |
|---|---|
| Title | Claude: the last custom-title. Codex: the newest name in session_index.jsonl. Else the first prompt, cut to 160 characters, skipping meta, sidechain, tool results and Codex's preamble (Paseo's rules). |
| Place | Working folder and git branch |
| Time | First and last call |
| Continue | cd <folder> && claude --resume <id> or codex resume <id>, copied (magpie) |
Calls stay after their file is deleted, since Claude Code deletes its own transcripts after 30 days, and are removed after 92 days.
Price
The cost is the calls at API list prices, labelled an API estimate: it is not the subscription bill. Prices are applied when the page asks, grouped in SQL by model, speed and tier, so a catalogue update reprices history without a rescan.
| Rule | Price |
|---|---|
| Base | Input, output, cache read, cache write per million tokens |
| 1-hour cache write | Twice the input price, Anthropic models only (magpie once leaked this rule onto OpenAI models) |
| Long context | A prompt (input + cache read + cache write) over the model's tier prices all its tokens at the tier |
| Fast | The model's fast price |
| Unknown model | Tokens count, cost does not; the total reads $12.40+. Never priced from a similar name. |
The page
Settings → Third-Party Harnesses (/settings/harnesses), beside Token Usage and apart from it, so a harness's cost never enters OpenProgram's own totals or budgets. It was chosen over a source switch on Token Usage because it puts the harnesses side by side.
| Part | Shows |
|---|---|
| A card per harness | Sessions, tokens, output and the API estimate for 30 days; for Codex each plan window as a meter with its reset, credits and when the app-server reported it |
| Daily tokens | Stacked bars, one colour per harness |
| Sessions | Filtered by harness and search: title; folder, branch, models, app, last activity; tokens and calls; estimate; a copy button for the continue command. 20 shown, then all. |
| By model, Started from | Tables with the harness on each row |
| Reading | The usage.third_party_harnesses switch, on by default; magpie asks per harness instead |
Implementation status
Claude Code and Codex are read. Gemini CLI (~/.gemini/tmp/*/chats/), OpenCode (its SQLite store, read only) and Pi are next with the same reader shape. Importing a harness session into a conversation and driving the harnesses (Claude Agent SDK, codex app-server, ACP for the rest) are separate steps.