Skip to content

feat(runner): add Pi and Oh My Pi unattended presets - #421

Merged
croffasia merged 4 commits into
croffasia:mainfrom
sinmingx:feat/runner-pi-omp
Sep 23, 2026
Merged

croffasia merged 4 commits into
croffasia:mainfrom
sinmingx:feat/runner-pi-omp

Conversation

@sinmingx

Copy link
Copy Markdown
Contributor

What

Add pi and omp presets to @itsaplan/runner. A fresh run is pi -p --mode json or omp -p --mode json --auto-approve, with --append-system-prompt for the run context. pi resumes with --session-id. omp resumes with --resume. Both streams are read as pi-json: text deltas, tool calls, and the session id from the opening session line.

Why

The other coding CLIs already have a preset that sets the unattended flags and the session resume. Pi and Oh My Pi did not, so a run used a custom command. That command does not resume a session and does not parse the JSON stream, so the chat only sees the final text.

Related to #289. The issue asks for pi only. omp is in the same pull request because both CLIs write the same --mode json stream, so one pi-json reader serves both; a separate pull request for omp would add two flags and nothing else. pi resumes with --session-id <id> (exact project session id) rather than the --session <id> the issue names; both flags exist in pi 0.85.1, and --session-id does not do a partial-id lookup.

@henry2man wrote in #289 that they were working on an MVP. If that is further along, I am happy to close this in favour of it or fold the pi-json reader into theirs.

How to test

  1. From packages/runner:

    bun test src/__tests__/presets.test.ts src/__tests__/agui.test.ts

    39 pass, 0 fail (bun 1.4.2, 2026-09-22). The whole packages/runner suite (bun test) is 46 pass, 0 fail.

  2. The preset tests pin the argv:

    • pi, no session: starts -p --mode json, includes --append-system-prompt, task last, no --session-id.
    • pi, session sess-9: -p --mode json --session-id sess-9, then the task.
    • omp, no session: includes --auto-approve, no --resume.
    • omp, session 01a0c317: -p --mode json --auto-approve --resume 01a0c317, plus --append-system-prompt, task last.
  3. The stream test feeds a pi-json session line, text deltas, a tool call, and message_end. It expects session id sess-9, text Looking it over., and tool result hello from alpha. A message_end with no delta is used as the answer.

  4. Flags checked against the installed CLIs: pi 0.85.1 has --session-id <id>, --append-system-prompt, --mode json; omp 18.2.8 has --resume=<value> (id prefix), --auto-approve, --append-system-prompt, --mode json.

  5. With the CLIs installed, set "agent": "pi" or "agent": "omp" in itsaplan-runner.json and send two chat messages. The second message should resume the session named on the first line of the first stream. This was not run here.

Checklist

  • bun run typecheck passes
  • bun run lint and bun run format:check pass
  • Tests added or updated for the changed behaviour (packages/runner preset and pi-json tests, 39 pass)
  • Database schema changed: migration generated with bun run db:generate and committed
  • New environment variables documented in .env.example
  • Docs updated (docs/runner.md, packages/runner/README.md)

Screenshots

N/A. No UI change.

Add runner presets for `pi` and `omp` (Oh My Pi): print-mode JSON streams, session resume, and --auto-approve on omp so unattended issue runs do not wait for a person.
@sinmingx
sinmingx requested a review from croffasia as a code owner September 22, 2026 08:20
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sinmingx

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Sep 22, 2026
@henry2man

Copy link
Copy Markdown
Contributor

@sinmingx I have a draft, but I haven’t had time to test it before opening the PR. I’m going to do a cross-check between this and what I have, and I’ll give you feedback as soon as possible 🙏🏻

@henry2man

Copy link
Copy Markdown
Contributor

@sinmingx As I said, I had a local draft of the same pi preset and never got as far as opening it, so please carry on with this one. I'll discard mine.

A few things I had tried, in case they are useful:

  • The task on stdin, same as Claude and Codex. pi -p reads it, and a chat without a session can be long. Passing it as an argument also worked.
  • Resume with --session, because --resume opens the picker. --session-id is the better flag: the id on the session line is exact, and --session also matches a prefix.
  • Only an assistant message_end as the fallback. In the runs I captured, Pi emits the user message_end before any text delta, so a reader that takes the first message_end prints the prompt and then the answer.
  • Usage from the last message_update that is not all zeros, with cacheRead and cacheWrite on the input and reasoning on the output. The early deltas report zeros.
  • I did not run Oh My Pi. Sharing one pi-json reader for both is a good call 👍🏻

Pi emits a message_end for the user turn before any text delta, carrying the prompt. The reader took the first message_end as the answer, so the chat printed the prompt ahead of the reply.
@sinmingx

Copy link
Copy Markdown
Contributor Author

Thanks, and thanks for letting this one go ahead 🙏

The message_end thing was a real bug. I ran pi 0.85.1 to see the order, and it emits the user message_end (which is just the prompt) before any text delta, then the assistant one. So the reader was printing the prompt and then the answer. It now only falls back to a message_end with role assistant, and I added a test that feeds that order. Pushed in a3c8f7b.

Agreed on --session-id, and glad the shared pi-json reader makes sense to you too. I'll keep the task as an argument for now since that's how the other presets do it, but stdin is a good option if a chat ever outgrows an argument. Usage already keeps the last message_update and adds cacheRead to the input, so that lines up with what you saw.

@croffasia

Copy link
Copy Markdown
Owner

@sinmingx Great work! I've pushed minor fixes to the instructions and bumped the version. Thanks!

@croffasia
croffasia merged commit 1956a14 into croffasia:main Sep 23, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants