# prime-agent

fork of [PrimeIntellect-ai/prime-agent](https://github.com/PrimeIntellect-ai/prime-agent)
for changes that are not upstreamable (and some fixes). rebased onto upstream 0.9.3.
this fork lives at [next.tangled.org/ptr.pet/prime-agent](https://next.tangled.org/ptr.pet/prime-agent).

## what's different

### how the agent runs

- extensions can read and change messages sent between agents, and can tell apart
  "the human asked" from "the agent woke itself up"
- a python api to list, watch, message, stop, and restart running sessions from
  outside the agent
- the agent's python can move to another machine over ssh: it sets itself up there,
  caches what it needs, copies your skills over, and can run subagents on that machine
- the bash tool pushes work toward python: it refuses git/jj/grep/find/ls and shell
  pipes (there are skills and plain python for that), and it can feed a running
  command input while it runs
- ssh and scp to other machines skip the local repo safety checks; huge command
  output is saved to a file instead of flooding the screen
- background commands report when they finish, even if they were killed or the
  machine ran out of memory, without spamming the chat
- `.` keeps working on the last task; python cells show a short useful preview
  instead of a wall of code
- useful python skills ship with the agent: git, jj, nix, repo, search,
  ssh, atproto, tangled, display, websearch, edit
- queued messages go out as one batch: ten messages typed while the agent works
  land in a single turn instead of ten turns with the model thinking in between.
  `steeringMode` and `followUpMode` in settings bring back the one-at-a-time
  behavior

### subagents

- discover available categorized models with `await rlm.models()`, which returns
  a dict-like object (e.g. `rlm.models().scouts[idx]`, `rlm.models().coders`)
- categories and model lists live in `~/.prime/agent/rlm-models.toml`, loaded as-is
- calling `await rlm.models()` at least once per compaction window is required before
  calling `await rlm.spawn(prompt, name="...", model="...")`
- `model=` specifies the child's model; optional `thinking=` sets reasoning level;
  optional `host=` routes execution to a remote host via SSH control master

### accounts and providers

- stay logged into several accounts per provider: requests rotate between them, a
  session can stick to one account, and a failed login or rate limit quietly moves
  to the next account. `/logout` lists each account, `/usage` shows what you spent
- `/usage` reports each provider's real quota from a per-provider feed, and `prime-agent
  usage --json` prints the same report for anything else to read: one file per provider,
  and a provider without a feed is named instead of looking unlimited
- that query is pure — a request shape in, a report out, no socket or clock — so the same
  rules run outside javascript: the zig core lives in its own repository
  (`usage-core`, checked out at `native/usage/` as a submodule) behind a C ABI for native
  hosts (a macOS app links it and keeps NSURLSession for the request). a parity test
  computes both implementations from the same recorded bodies, so neither drifts quietly

### models

- the model list refreshes itself from models.dev about once an hour; `/reload
  models` forces it. refresh errors no longer wreck the screen
- you can ask a model for json that matches a schema — works on google and
  openai-style providers
- fixed tool results getting lost when a user message interrupts a turn
- every tool call shows how long it took, and the model sees that too

### remote work

- `--remote-python-host` runs the agent's python and its subagents on another
  machine; the banner, tray, and agents view show which one
- remote skills mirror the local ones (`rem.bash`, `rem.os`, ...)
- the ssh skill can pipe text into commands and reconnects itself when its master
  connection dies

### looks and speed

- context and cache numbers update live while the model works; the tray and agents
  view show a cache timer and how much of the context is cached
- the agents view and session switching got much faster: parallel disk scans,
  cached tool paths, reused ui services
- pin sessions to keep them on top (`ctrl+u`)
- diffs in the ui are syntax highlighted; the display skill shows rich output
  (markdown, diffs, tables)
- a failed update now says it failed instead of claiming success

## extensions

separate repos that plug into prime agent:

- [prime-antigravity](https://next.tangled.org/ptr.pet/prime-antigravity) — sign in
  with google antigravity: oauth login and streaming for google's cloud code assist,
  ported from oh-my-pi
- [prime-commitment-observer](https://next.tangled.org/ptr.pet/prime-commitment-observer) —
  remembers unfinished requests across turns; a small model files each one as open,
  active, waiting, blocked, or done
- [prime-snapcompact](https://tangled.org/ptr.pet/prime-snapcompact) — compaction
  that keeps a plaintext and image archive of old turns instead of squashing them
  to text, so code and tool output survive
- [prime-meat](https://tangled.org/ptr.pet/prime-meat) — turns big diffs into short
  readable summaries
- [prime-narrate-jjk](https://tangled.org/ptr.pet/prime-narrate-jjk) — narrates
  agent turns in jujutsu kaisen narrator voice
- [vibecoding-quota-tray](https://next.tangled.org/ptr.pet/vibecoding-quota-tray) —
  provider quota awareness in the tray
- [omp-codex-bridge](https://tangled.org/ptr.pet/omp-codex-bridge) — presents omp
  as codex for use with chatgpt remote

## install

stable release (upstream builds):

```bash
curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh
```

from source (this fork):

```bash
npm install        # from the repo root
./prime-agent.sh   # run via tsx, or ./prime-agent.sh --dist for the built bundle
```

`npm run build` builds all packages. start in a project directory, `/login` on
first launch.

> [!WARNING]
> prime agent executes model-generated python and project commands with your user
> permissions. its worker and kernel processes improve lifecycle isolation and
> recovery; they are not a security sandbox. review changes and use trusted
> repositories, instructions, skills, and extensions only.
