Files
alzeo/docs/pi.md
T
Hasan BasbunarandClaude Opus 5.5 6dc9f530c1 pi-gen: the tokens a compaction keeps are read from OpenCode 2's key too
On an OpenCode 2 box, the default since v1.56.0, the artifact says them in
compaction.keep.tokens; pi-gen read preserve_recent_tokens alone, 1.x's, so
pi's settings held none and pi kept its own 20,000 tokens, where the reference
box's 27B keeps 212,000 (2026-11-30).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 09:33:19 +01:00

10 KiB
Raw Blame History

pi and omp integration

What pi-gen.py generates for pi and omp (oh-my-pi), the coding agents that read no opencode.json. Companion to docs/opencode.md: same engines, same key, same limits, from one source.

Generated artifacts, user-copied

pi (~/.pi/agent) and omp (~/.omp/agent) keep their default model, provider names and limits as plain values in their own files. pi-gen.py writes the agents' side of this box's facts as ready files next to ~/.config/qwen38/opencode.json, the artifact install.sh fits, ./switch-model.sh re-points and oc-fit-limits.py re-fits:

~/.config/qwen38/pi/models.json      ~/.config/qwen38/pi/settings.json
~/.config/qwen38/omp/models.yml      ~/.config/qwen38/omp/config.yml

Run ./pi-gen.py once to create them. From then on an update (./install.sh, since v1.31), ./switch-model.sh (block 4f) and a fit (oc-fit-limits.py, the cockpit's button) regenerate them; a box that never ran it gets no such files. python3 pi-gen.py --dry-run shows what a regeneration would change.

The repo never writes into ~/.pi or ~/.omp; installing is your copy. On an agent with no config of its own yet:

mkdir -p ~/.pi/agent && cp -n ~/.config/qwen38/pi/*.json ~/.pi/agent/
mkdir -p ~/.omp/agent && cp -n ~/.config/qwen38/omp/*.yml ~/.omp/agent/

cp -n copies nothing over a file that exists: if you already have a models.json or models.yml with other providers, merge the providers of the generated file into it by hand (it carries one per installed lane, for example qwen38 for the 27B and flashnext for the flash lane; each agent reads one such file), and likewise the default model and compaction settings. Copy again after a switch or a fit, and the agent carries the new lane.

One build, two serializations

The pi pair is canonical; the omp pair is converted from it: same models array, thinking block added, pi's inputLimits and compat dropped (no room for them in omp's schema, and a schema error makes omp disable the whole file), default provider and bare model id into modelRoles.default. Same values, different files, built once: they cannot disagree. The artifact's {file:...} key becomes both agents' !cat <path> form, which they run in a shell at request time: no secret in their files, and a rotated key is read on the next request.

Reasoning effort, the system prompt, images, compaction

The patched template reads reasoning_effort: lean is its default (xhigh on a box installed with LEAN_DEFAULT=0), max and high read as xhigh, minimal as low. SGLang takes the effort from chat_template_kwargs.reasoning_effort or from a top-level reasoning_effort (the first when both are there), and validates the top-level one against none, minimal, low, medium, high, xhigh and max: sent to the engine, a top-level lean is a 400. The proxy moves such a level into chat_template_kwargs (v6.18) and drops it when chat_template_kwargs names a level already (v6.30), so through :30001 neither is refused.

  • pi. modelThinkingLevels is off for our models: no effort field, so the template's default, lean (what "no variant" means for opencode), or xhigh on a box installed with LEAN_DEFAULT=0 and on the Qwen3.8 Flash-Next FP4-Local lane installed with FLASH_LOCAL_EFFORT=xhigh, its model card's default. A level picked in pi goes out as the top-level field: minimal reads as low, and high as xhigh (pi sends high for xhigh and max too). Each model also carries compat.supportsDeveloperRole: false: pi sends its system prompt as the developer role to a reasoning model on a provider it does not know, and the served template refuses that role (every request was a 400 "Unexpected message role." without it).
  • Kolibri. Its template reads none, low, medium or high, and vLLM hands it the top-level field: pi sends it, with thinkingLevelMap taking off to none (with no field Kolibri reasons at high), minimal to low and xhigh to high, and its level starts at high, what Kolibri does unasked. omp offers none as minimal (reasoningEffortMap), and starts at high too.
  • Nemotron (Bolt, and Super VL, whose template reads the same two). Its template reads enable_thinking and medium_effort, and no effort level: pi sends the top-level field as for Kolibri (thinkingLevelMap taking off to none, minimal to low and xhigh to high), its level starts at high, Bolt's full reasoning, and the proxy says each level in the template's words (v6.40): none and minimal turn the reasoning off, low and medium ask its shorter one, high its default. omp sends its pick in chat_template_kwargs.reasoning_effort, which the proxy translates the same way.
  • Ornith 1.5 122B. Its template reads enable_thinking alone, and no effort level: pi sends the top-level field, thinkingLevelMap taking off to none and its other levels as they are, its level starts at high, the full reasoning Ornith does unasked, and the proxy says each level in the template's words (v6.45): none and minimal turn the reasoning off, every other level keeps it whole. omp offers high and minimal, its minimal sent as none (reasoningEffortMap), starts at high, and sends its pick in chat_template_kwargs.reasoning_effort, which the proxy translates the same way.
  • Liquid AI LFM3. Its template reads enable_thinking alone (true by default), and no effort level, as Ornith's does: pi offers off and high alone, the two states the model holds (thinkingLevelMap taking off to none and every other level to null, which pi hides), sends the top-level field, its level starts at high, the reasoning LFM3 does unasked, and the proxy says each level in the template's words as on Ornith (v6.61): none and minimal turn the reasoning off, every other level keeps it. omp offers high and minimal, its minimal sent as none (reasoningEffortMap), starts at high, and sends its pick in chat_template_kwargs.reasoning_effort, which the proxy translates the same way. Liquid AI's other lane, LFM2.5 24B-A2B, reasons before every answer, and its template reads no switch and no level: pi offers high alone, starts there and sends no effort field (supportsReasoningEffort: false), and omp gets high as its one effort and its default, though omp 18.4.9 offers off and auto beside a reasoning model's efforts whatever its file says. What pi shows on these two lanes was read in pi 1.2.0's source (getSupportedThinkingLevels). No pi or omp session has run on either lane yet.
  • Inkling 2 Mini. Its template reads reasoning_effort by the names pi sends (none 0.0, minimal 0.1, low 0.2, medium 0.7, high 0.9, xhigh and max 0.99), and reasons at high unasked: pi sends the top-level field, thinkingLevelMap taking off to none and its other levels as they are, and its level starts at high. The proxy relays none as it came on this lane (v6.62), where a Qwen lane gets enable_thinking false instead. The model's card says its lowest effort does not turn the reasoning off. omp offers high, minimal, low, medium and xhigh, its minimal sent as none (reasoningEffortMap), starts at high, and sends its pick in chat_template_kwargs.reasoning_effort. Both take images there. No pi or omp session has run on the lane yet.
  • omp. Its picker goes through the same enum, and compat.reasoningEffortMap translates the pick for the provider: the generator gives it efforts: [minimal, low, medium, xhigh] with minimal mapped to lean, and as its default the installed template's own: minimal (lean), or xhigh on a box installed with LEAN_DEFAULT=0 and on the Qwen3.8 Flash-Next FP4-Local lane installed with FLASH_LOCAL_EFFORT=xhigh (pi-gen.py reads the template beside the configs it writes and, for that lane, the choice its installer keeps there; omp sends its default level on every request), the same ladder (lean/low/medium/xhigh) the artifact's variants declare; off lands on lean, and a level the list does not hold on the nearest one below it (high on medium, max on xhigh). compat.qwenTemplateReasoningEffort routes the mapped level onto chat_template_kwargs.reasoning_effort (it ships on by default for Qwen 3.8+ ids on LM Studio, llama.cpp discovery and vLLM only, none of them this proxy's provider id: without it the picker moved and nothing was sent), and compat.thinkingFormat: qwen-chat-template, omp's dialect for vLLM and SGLang, sends it there alone: omp's default dialect also sent a top-level lean, a 400 on every request at the default level until the proxy dropped that copy (v6.30, v1.22.1; checked with omp in its default dialect, a 400 through v6.29 and an answer through v6.30).

images.autoResize (on) plus a generated 1568×1568 / 512 KiB per-model resize cap keep an attachment from blowing the prompt past the lane. Compaction follows the artifact: keepRecentTokens = opencode's compaction.keep.tokens (OpenCode 2) or preserve_recent_tokens (1.x), and each lane's reserveTokens = that lane's output cap.

Verified on 2026-10-01 with pi 0.99.2 (@earendil-works/pi-coding-agent) and omp 18.4.9 (@oh-my-pi/pi-coding-agent, which needs Bun 1.3.14 or later), through the proxy to the flash lane: a reply at every thinking level of both agents, and a tool call (read) in each. Both lanes' images validate the effort the same way.

What still differs

pi lifts no hidden output cap (none exists) and retries transient errors itself; the auto-continue plugin's stuck-after-compaction case is still opencode's edge. Nothing pins pi or omp versions (opencode's pin exists because repo behaviour was read out of its binary): a release of either that changes these fields can need a regeneration. omp's roles, fallback chains and path-scoped models stay yours: the artifact sets only the two providers and the default role's model. The cockpit's Agent view stays opencode-only.

Back to the README