docsp0ssess documentation

p0ssess: design

p0ssess lets Claude Code hand work to other models through OpenRouter while Claude stays in charge: it plans, routes, reviews, and answers. Its core is the Predictive Model Engine (PME), which decides when another model is the better choice.

On this page

Status: design agreed and researched; built as a Claude Code plugin. Where the build departs from this page, ENGINE.md, RELAY.md and MEDIA.md describe what shipped.

Principles

  • Every model is a candidate, Claude included. No preference for Claude; it is chosen when the numbers say so.
  • Quiet. p0ssess augments Claude Code rather than adding steps. "Watch this video" goes: the user asked for video, p0ssess is set up, the job is under the cap, do it. No plan read aloud, no confirmation, one hand-off to the p0ssess agent; the answer comes back with "(model, cost)" and nothing else.
  • Claude reviews what comes back. Nothing a delegated model writes lands without the right level of review.
  • Private by default. Prompts and files go only to the model doing the work. The engine service that ranks routes gets a task description Claude writes and plain counts, never content. Learning data stays on the user's machine; anonymous outcome records, sent when a session ends, are on by default and one setting turns them off (README, Privacy). Usage counts (nine milestone counts per ISO week under a random id, no token) are off unless the user says yes in the tour or in plain words.
  • Only clean data. Benchmarks and usage data are used only where their license clearly allows it, and every number carries its source and date.

How a request is routed

  1. A UserPromptSubmit hook adds a one-line hint only when it matters: an attached media file, work a user or team rule sends to a model, a Claude usage limit that is close, a task that looks cheap and bulky, or a route the user's history favors. Otherwise it adds nothing.

  2. Claude can ask the engine for a ranked list of options for the task at hand.

  3. Claude rates the task's stakes (see below), and the engine scores every candidate that fits the task (modalities, context size, tool use) by its expected cost per accepted result:

    cost(model, task) = cash                          OpenRouter spend (0 for Claude)
                      + λ(pressure) × claude_price    Claude's cost; λ rises as the user's limit nears
                      + overhead + review             delegation and checking turns
                      + p_fail(model, task) × (redo + harm(stakes))
    
    • p_fail is the chance the result is not accepted, from benchmark evidence and the user's history.
    • harm(stakes) is the cost of a bad result beyond redoing it; small at stakes 1, steep at each level above.
    • Stakes also gates: a model qualifies only if its p_fail is below the ceiling for that level.
    • On API-key plans λ is 1 and claude_price is the list price. On subscriptions λ(pressure) follows the projected end-of-window usage (the worse of the 5-hour and weekly windows); its shape is a user preset.
    • The lowest total wins. Delegation that cannot save anything (overhead and review above the work's own cost) is never offered.
  4. Claude makes the final call and may override the ranking with a stated reason.

  5. Claude routes on its own when the work needs a capability it lacks (video, audio, image generation) or is cheap and within the per-task budget. For media the p0ssess agent calls the direct tool once without naming a model; the tool asks the engine and picks one. It asks the user first only when the job's estimate is above the per-task limit, the monthly cap would be passed, a rule says to ask, or the stakes are 4. Asking before a model's first run or before agent edits is opt-in (ask.first_use, ask.code_edits); an edit always comes back as a diff Claude reviews.

Stakes

Claude rates each task on four levels from signals it can see: how reversible it is (read-only, an edit in a worktree, a production change), its blast radius, sensitive areas (auth, secrets, firewalls, infrastructure, payments), whether the result ships or reaches other people, how cheaply Claude can check it, the user's own words ("quick draft", "this matters"), and the user's rules.

Stakes Typical work
1 Trivial renames, log summaries, captions; easy to undo, errors are obvious
2 Routine test drafts, transcripts, bulk edits Claude reviews
3 Important features that ship, security write-ups, migration plans
4 Critical auth, firewall and infrastructure changes, production, money, anything sent to other people
  • The rating is shown only when it changes the routing ("important: keeping this on Claude"). The user can correct it in plain language, and corrections feed the history.
  • Stakes 4 stays on Claude unless a global or session allow rule names the model with max_stakes = 4, and even then Claude reviews the result. The tools enforce it: a call that does not state its stakes takes the use case's catalog stakes, or 3.
  • A cheap model plus a Claude check can take an important task when checking costs much less than doing.

Generated files

When another model makes a file (an image from the direct tool, or an image or document an agent run writes in its worktree), the tool result carries a short structured list, files: [{"path", "kind"}], with kinds image, video, audio and document. Claude presents them by default:

  • It always prints each absolute path in its reply.
  • When the session has Claude Code's SendUserFile tool (a Remote Control client such as the Claude mobile app is connected, or it is a cloud session), Claude sends the files with it: rendered for image, video and audio, attached for documents.
  • In a plain terminal session there is no such tool; the path is the presentation. kitty and most terminals let you open it from there. Claude starts no viewer and runs no extra commands.

Agent-run files are listed only when they are regular files inside the run's own worktree; a symlink a model planted to point outside it is left out.

Two ways to run delegated work

  • Direct: a single model call for one-shot jobs (transcribe, summarize, caption, translate, describe a video).
  • Agent: a sandboxed OpenCode session for multi-step work on files.

The engine picks the path per use case. Audio and video always take the direct path.

Agents: the possession

Routed work never runs in the main conversation. The p0ssess agent (Haiku, background) takes it over for the moment, the way a ghost possesses a body, and hands back only the result. That is where the name comes from.

  • Main Claude starts the agent with one Agent call and a one-sentence prompt (the request and absolute file paths). The agent makes every p0ssess call: direct for media, run and wait for sandboxed agent sessions, recommend to price a route. It replies with the other model's answer, any files: line, a diff: path with a one-line summary (never the diff), and one via: line with the model, cost and run id.
  • So the main model never reads raw tool results, transcripts, diffs or engine tables. Each routed call costs it one short prompt and one short result; the bulk is billed at Haiku's price, a few tenths of a cent.
  • Enforcement, beyond instructions: a PreToolUse hook denies direct, run, wait, abort, answer_permission, recommend and models when the call comes from the main conversation (Claude Code sets agent_id in hook input only inside a subagent), with a reason that sends Claude to the agent. When the user's latest prompt explicitly asks for p0ssess in the main session ("call direct yourself in the main session"), the prompt hook records that for the session and the next calls pass; the next ordinary prompt clears it. This keeps a habit, not an adversary, out: the spending limits are what stop a misbehaving model.
  • A PostToolUse hook on the Agent call tells main Claude to end its turn without writing, and to relay the result with nothing around it but "(model, cost)".
  • Named shortcuts (for example p0ssess-gemini-3-8-flash-media) are the same agent with a fixed model, created only when usage shows they are worth having, capped at 12.

Review

Delegated work Review
Code edits Always reviewed by Claude as a diff from a separate git worktree before anything lands
Factual or analytical answers Claude spot-checks claims it can verify
Pure transformations (transcripts, summaries, captions) Passed through, labeled with the model that made them

When Claude has to redo a model's work, that counts against the model's score for that kind of task.

Budget

~/.config/p0ssess/budget.toml:

  • monthly OpenRouter cap (default $10)
  • per-task auto-approve limit (default $0.02), compared with each job's estimate; above it, Claude asks unless a standing approval covers the task (see Rules)
  • daily soft limit
  • optional "save Claude" mode that lowers the bar for routing as Claude limits near
  • model and provider allow and deny lists

These are enforced where money is spent, not only advised. Before the direct tool or a relay run sends anything, it applies the rules, the allow and deny lists, the stakes gate, privacy mode, .p0ssess-private, and the per-task, daily and monthly limits on its own, whatever recommend said, and fails closed when the budget, rules or ledger cannot be read. It then reserves the call's maximum cost in the ledger under a file lock, so concurrent calls cannot each pass the same headroom; the measured cost settles the reservation afterwards. Whether to ask is decided from the call's estimate; the reserved maximum stays the hard ceiling, enforced at spend time (the direct call is priced against it before sending, and the relay interrupts a run that reaches it). A default ceiling, such as the relay's max_run_cost_usd, is lowered to the room left under the daily and monthly limits and to a covering standing approval's per-run limit, when the estimate still fits. A call whose estimate is above the per-task limit, with no standing approval, is refused as "needs approval" and Claude asks the user. A cost that is never reported is recorded at the reserved maximum, marked estimated, until OpenRouter reports it.

/p0ssess-me prints a few lines in the terminal (spend today and this month against the cap, the limits, running jobs, how to change them) and opens a local page in the plugin's design language (served on localhost, works offline): today and the month against the envelope, the envelope's three limits editable in place, running jobs, recent runs with their receipts (model, cost, saving, result), the notices feed (retries, limit warnings, why a model was picked, provisional scores), limits and rules, the team budget and a link to the team page for Team seats, with the other settings one click away.

Rules and standing approvals

Every setting, rule, budget and stakes rating can be changed in plain language as well as in /p0ssess-me. Users set rules that gate what the engine may do, either in /p0ssess-me or in plain language ("no Claude agents for this", "only use gemini-3.8-flash for video", "mix deepseek and glm for bulk edits", "no OpenCode", "stop using model X"). Claude turns a plain-language request into a rule, shows the rule it wrote in one line, and saves it once the user confirms.

Rule kinds:

  • Who may run work: allow or forbid Claude agents, a specific model, a set of models (a mix, with optional weights), or the OpenCode agent path.
  • Standing approvals: pre-approve spend for a kind of task up to a per-run price, with an optional count or total ("auto-approve 10-minute video edits up to $0.20 each", "up to $5 today"). Within a standing approval, runs go through without asking and are announced in one line as usual.
  • Ask first: always ask before matching work ("always ask before using grok", "ask first for video"), even within every limit. Only a yes for that run (a one-run session approval) lifts it.
  • Budget overrides: raise or lower the per-task limit, daily limit, or monthly cap, for the session or permanently.

Scope: each rule applies to the session, a project (.p0ssess/rules.toml in the repository), or globally (~/.config/p0ssess/rules.toml). A rule that forbids something always beats one that allows it. Session and global rules are the user's own and have full power; between them the session wins. A project file arrives with whatever repository the user clones, so project scope only tightens: it may forbid models, providers, Claude agents, OpenCode or all delegation, narrow the user's only/mix choice, and lower the per-task, daily or monthly limit. Anything that would loosen (allow rules, standing approvals, lifting the stakes-4 gate, raising or turning off a limit) is ignored and reported once per session: "project rules tried to loosen …; ignored — add it yourself if you want it". Rules can expire ("for the next hour").

Rules are never inferred silently: the engine may suggest one from the user's history ("you've approved 8 video edits at about $0.15; make that a standing approval?"), but only the user creates it. /p0ssess-me lists every active rule with its scope and lets the user edit or remove it.

Learning

A local history file records each delegation: kind of task, model offered and chosen, cost, whether the user accepted, overrode, or declined, and whether Claude had to redo the work. A finished run that nobody reports on counts as accepted, so Claude reports only what it did not use (a redo, a decline, another route) and a successful hand-off costs no extra tool call. From it the engine learns tendencies (for example "always accepts Gemini for media", "declines cheap models for Swift edits") and adjusts its offers. Planned, not built: reading the user's Claude Code memory files for stated preferences (never writing them), and an opt-in evaluation set (a few real tasks per family of use cases, on a small capped budget) to measure routing quality and publish aggregate results.

Claude usage signal

Claude Code reports 5-hour and weekly usage to status line scripts on Pro and Max plans. p0ssess wraps the user's status line, saves those readings with their timestamp to a local file, and the engine and hook read that file. With no reading (before the first message of a session, or on a pay-as-you-go plan) the signal is "unknown" and only the budget settings apply. p0ssess never reads, stores, or relays the user's Claude credentials.

Status line

A segment after the user's own status line: today's spend against the daily limit, then what runs.

calm                        ghost p0ssess $0.42/$1
working                     ghost p0ssess $0.42/$1 · 1 running (kimi-k3.1-pro)   (the model drops first when narrow)
no daily limit              ghost p0ssess $0.14 today
Team seat with a budget     ghost p0ssess $0.42/$1 · team $41.20/$50
near or over the daily      ghost p0ssess $0.91/$1                               (amber)
monthly cap reached         ghost p0ssess month cap $10.00/$10 · paid runs stopped   (red)
team budget used up         ghost p0ssess team budget $50.00/$50 · paid runs stopped (red)
older server this session   ghost p0ssess $0.42/$1 · restart to update           (marker in amber)

Muted when calm, slightly brighter while running, amber near the daily limit or a cap, red only when paid runs are stopped. Never animated. It reads local files only: the ledger part is cached in statusline.json in the cache directory until the ledger, budget, team policy or account changes (30 s at most), so a refresh takes a few milliseconds whatever the history's length.

First run

The first plain message of the first interactive Claude Code session after install starts a short tour (/p0ssess:tour, p0ssess tour): what p0ssess does; the envelope with the new-install defaults ($1 a day, $10 a month, up to $0.25 a task without asking), changed with one answer; one live route on a tiny sample task capped at one cent; where spend shows (status line, the p0ssess page, /p0ssess:team). It starts once (tour.json in the state directory), never in print mode, the SDK, CI or child sessions, and /p0ssess:tour runs it again. An install that already used p0ssess gets one line offering it instead. P0SSESS_TOUR=off turns it off.

Background agent status summaries

Claude Code asks for a one-line status summary of each running background agent about every 30 seconds. Relay agents are long-running background agents, so these requests can eat into what routing saves.

  • Planned, not built: measuring how many summary requests relay jobs cause and what they cost, next to the delegation itself.
  • p0ssess setup summaries (offered by /p0ssess-me) sets Claude Code's own switch, CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIES=1 (Claude Code 2.1.318 and later, currently undocumented), written to the env block of the user's settings only with their consent, labeled as undocumented, and reversible with one command. The trade-off is stated: it turns status lines off for all background agents, and after a context compaction Claude no longer sees progress lines for running agents.
  • p0ssess never patches, preloads into, or otherwise modifies Claude Code at runtime.

Privacy

  • Only providers that do not train on prompts are used by default; the user can loosen this.
  • A .p0ssess-private file in a repository blocks all delegation from it and from every directory below it, including prompt-only calls; the tools refuse, not only the advice.
  • Zero-retention mode (privacy.mode = "zdr") is enforced at the call: the direct tool sends provider.zdr = true and refuses models with no zero-retention endpoint, and the relay's key proxy adds zdr = true to every request.
  • The ledger holds no prompt content, but the relay keeps each run's task and output transcript under ~/.local/state/p0ssess/relay/runs/<session>/, and nothing prunes it yet.
  • Files that look like secrets (.env, keys) are never attached.

Sandbox for the agent path

OpenCode runs in a rootless container, and every relay session gets its own: created for the session's first run, kept while the session can still be continued, and removed when it ends or idles out, so no two sessions share a server, a database or a worktree. Only the repository (read-only) and the session's own git worktree are mounted, no credentials or SSH keys are present, the server may reach the internet but not local networks, VPN ranges or the host, and hard deny rules cover privilege escalation, remote shells, pushes, container and service control, and edits to .git, .env, and .ssh. Jails left by a crashed process are removed at the next start. Every command the model runs goes through a shell wrapper that scrubs the environment and puts the command in fresh user, network, mount and pid namespaces, so it has no network at all (the API, the key proxy, the LAN and the internet are unreachable), cannot read the server's environment or /state, and — for a read-only task — has nothing writable. A user can turn on internet for shell commands per project, in their own settings only: the commands then reach public addresses on ports 80 and 443 through an egress proxy that refuses every local, private and VPN address, and nothing else changes. formatter and lsp are off so repository-controlled programs never run in the server. The full confinement is in docs/RELAY.md. Questions OpenCode would ask the user are rejected on read-only tasks and returned to Claude on edit tasks; "always allow" is never answered. A reply or interruption the relay did not issue aborts the session as tampered.

Data sources

Used, with attribution and the date of each value:

  • OpenRouter public model list: prices, context, modalities, supported parameters, uptime
  • OpenRouter Data API (CC BY 4.0): model rankings, top apps by category, task-type shares, OpenRouter's own evaluations; filtered to the referenced models and attributed, never a full mirror
  • Epoch AI benchmarks that Epoch runs itself (CC BY)
  • LMArena's published leaderboard dataset (CC BY 4.0)
  • Aider's leaderboard data (Apache-2.0): checked, but no referenced model appears in it, so it contributes no values (the file ships as an empty header)
  • models.dev (MIT) as a cross-check

Not used: any source whose terms restrict republishing or commercial use, or whose license is unclear.

The engine service holds this data and refreshes it; the plugin keeps a signed table of the engine's default answers, fetched at most once a day.

Research deliverables

  1. A cited report: how OpenRouter is used, which apps and tools drive the most tokens, the model and benchmark landscape.
  2. catalog/usecases.yaml: at least 100 distinct, evidence-backed use cases, about half grounded in OpenRouter usage data and half in Claude Code gaps. Each entry: description and evidence, recommended model plus alternatives (Claude included), expected cost per run, budget sensitivity, and whether Claude verifies the output.
  3. registry/: a first snapshot of models with prices, capabilities, and benchmark scores, each value with its source and date.

This page is generated from docs/DESIGN.md.