omp-dynamic-reasoning
Opt-in, model-aware reasoning effort routing with OpenRouter Jev for Pi and Oh My Pi
Package details
Install omp-dynamic-reasoning from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:omp-dynamic-reasoning- Package
omp-dynamic-reasoning- Version
0.3.0- Published
- Sep 23, 2026
- Downloads
- 256/mo · 256/wk
- Author
- subwayp
- License
- MIT
- Types
- extension
- Size
- 40.1 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/pi.js"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
Dynamic Reasoning for Pi and Oh My Pi
An opt-in extension that uses OpenRouter's typesafe/jev-1.13 classifier to choose a supported reasoning effort before each new agent run. It changes session effort, not your model, system prompt, main-model authentication, or saved thinking default. It does not reclassify every tool-loop step.
Important: recommended model and prompt caching
GPT-6 Astra (gpt-6-astra) works best for dynamic reasoning because switching reasoning levels does not reset the prompt cache on compatible Responses transports. Your host/provider must support Astra's configuration_update behavior. Other models or transports may invalidate the cache when reasoning effort changes. Cache hits and cost savings are not guaranteed.
This disclaimer is displayed during setup, before you accept it. The extension does not implement or force provider-side caching; the host and provider do that.
Install
This repository is a package; no build step or separate server is needed. To install a local checkout, use its absolute path:
# Pi
pi install /absolute/path/to/dynamic-reasoning
# Oh My Pi
omp plugin install /absolute/path/to/dynamic-reasoning
Restart your host after installing. To try it for one invocation without installing:
pi -e /absolute/path/to/dynamic-reasoning
omp -e /absolute/path/to/dynamic-reasoning
Or install the npm release:
pi install npm:omp-dynamic-reasoning@0.3.0
omp plugin install omp-dynamic-reasoning@0.3.0
The package contains separate pi and omp entry points. Pi supplies the optional @earendil-works/pi-ai peer; OMP does not need that package installed separately. Do not load src/index.js directly; it is the shared implementation, not a host entry point.
Setup
- Start Pi or OMP and run
/dynamic-reasoning setup. - Read the model/cache disclaimer and the privacy/cost notice, then explicitly confirm.
- If no key is configured, setup opens the host's built-in text editor. Paste only your OpenRouter API key, then use the editor's submit shortcut. No environment variable or host restart is needed.
The classifier runs Jev through OpenRouter; a direct Jev/TypeSafe API key is not supported. Your main model keeps its existing login. An existing saved key or nonempty OPENROUTER_API_KEY is reused without opening the editor. Cancelling or submitting an empty editor saves neither a new key nor new consent.
The key is visible while editing and saved in plaintext, separately from settings, at ~/.config/dynamic-reasoning/config.json.key. Setup requests owner-only permissions on POSIX; Windows uses inherited account permissions. Protect this file and its backups. Editor input is not submitted as a chat message, and the extension does not include keys in notifications or status output.
Optional environment key
OPENROUTER_API_KEY still overrides the saved key. For example, in PowerShell:
$env:OPENROUTER_API_KEY = 'your-openrouter-key'
pi # or omp
In a POSIX shell:
export OPENROUTER_API_KEY='your-openrouter-key'
pi # or omp
You can keep using your preferred secret manager or shell configuration instead of local credential storage. Do not put credentials in chat, the package directory, or the JSON settings file. The extension does not read a package-local .env. A runtime may independently load environment files; that is not extension behavior.
Headless setup
From a checkout or unpacked package, first display the notice:
node scripts/setup.js
After reviewing it, explicitly accept:
node scripts/setup.js --accept-disclaimer
An npm installation also exposes the dynamic-reasoning executable with the same flag. Headless setup does not open an editor; it uses a saved key or OPENROUTER_API_KEY. /dynamic-reasoning setup --accept-disclaimer is available through the extension command interface too, and still opens the editor in an interactive host if a key is missing. Restart an already-running host, or run /dynamic-reasoning auto, to load externally saved consent.
Credentials alone never opt you in. Missing consent or credentials leaves the current host reasoning behavior untouched and sends no classifier request. Setup can save consent before a key is present, but routing cannot start until a key is available.
Privacy and cost
After consent, each eligible run sends a bounded copy of the current prompt plus recent visible user/assistant text and session summaries to OpenRouter's Jev classifier:
- Current prompt: at most 16,000 characters.
- History: at most six entries, 12,000 characters total, 4,000 characters per entry; stops at a compaction/branch summary.
- Excluded: hidden thinking, raw tool outputs, system prompt, and image bytes.
- Included text and summaries can still contain sensitive information, including information previously derived from tools. Only enable this if you may share that content with OpenRouter and the classifier provider.
Classifier requests introduce additional latency and charges under your OpenRouter account. There is no promise of lower total cost or better answers. The client currently uses OpenRouter's alpha decisions endpoint; upstream API changes can interrupt classification. Transport errors, invalid responses, and deadlines retain the current effort rather than blocking the main model indefinitely. Errors never display upstream response bodies or credentials.
Commands
| Command | Behavior |
|---|---|
/dynamic-reasoning setup |
Show disclosure, confirm, open a key editor if needed, and persist consent. |
/dynamic-reasoning status |
Show routing status, target, credential availability, and settings path. |
/dynamic-reasoning auto |
Reload settings and enable routing if consent exists. Cannot bypass setup. |
/dynamic-reasoning off |
Cancel pending classification and disable routing for this extension instance; retain current effort. |
/dynamic-reasoning low |
Set an explicitly supported effort and disable automatic routing for this extension instance. |
Manual effort commands accept minimal, low, medium, high, xhigh, or max, subject to the active model's capabilities. Routing never chooses off. A model must expose at least two supported non-off levels for automatic routing. Unknown or nonreasoning models are left untouched.
Low-confidence decisions, truncated current prompts, and unseen images prevent cheap downgrades: the policy retains at least the current effort or high, within the model's supported levels. Manual overrides, model changes, session boundaries, and interactive interruption invalidate pending decisions.
In OMP, applying a successful decision takes ownership from built-in automatic thinking. /dynamic-reasoning off retains the last effort; it does not restore OMP's native automatic mode. Re-enable that mode with OMP's own thinking controls if desired.
Persistent configuration
Settings and consent live outside the package at ~/.config/dynamic-reasoning/config.json on every platform, including Windows. Both hosts share this file by default. Set DYNAMIC_REASONING_CONFIG to a different file to isolate profiles or hosts. Relative override paths resolve against the launch working directory; absolute paths are recommended.
The optional saved credential lives at <configuration path>.key, so a custom DYNAMIC_REASONING_CONFIG also isolates its credential. To replace a saved key, delete that .key file and rerun /dynamic-reasoning setup; remove any environment override first. To stop using a saved key, delete the file and run /dynamic-reasoning auto or restart. Removing a credential does not revoke consent.
Optional JSON settings (setup preserves them):
{
"target": null,
"timeoutMs": 2000,
"confidence": 0.6
}
Setup adds a versioned consent record. Leave that record intact when editing options. To revoke persistent consent, remove that record and restart the host or run /dynamic-reasoning auto; use /dynamic-reasoning off to stop an active instance immediately. A future notice version requires acceptance again.
| Environment variable | Meaning |
|---|---|
OPENROUTER_API_KEY |
Optional classifier credential; overrides the locally saved key. |
DYNAMIC_REASONING_CONFIG |
Configuration file location. |
DYNAMIC_REASONING_MODEL |
Optional exact provider/model target, such as openai-codex/gpt-6-astra. Otherwise use the active supported model. |
DYNAMIC_REASONING_TIMEOUT_MS |
Integer deadline, 100–10,000 ms; default 2,000. |
DYNAMIC_REASONING_CONFIDENCE |
Confidence threshold, 0–1; default 0.6. |
Nonempty environment settings override corresponding JSON options. Malformed configuration disables routing with a configuration error. Setup writes nonsecret settings and consent to JSON, and an entered API key to the separate .key file.
Compatibility and verification
- Pi 0.84.2: public
getSupportedThinkingLevelscapability helper, including provider defaults andthinkingLevelMapexclusions. Optional peer range:^0.84.2. - Oh My Pi 18.2.8: explicit
model.thinking.effortsmetadata. - Node.js 22.19 or newer for Pi and standalone setup; OMP supplies its own runtime.
- Other versions are not yet runtime-verified. Older Pi distributions without the current
@earendil-works/pi-aihelper are not supported by this release.
The extracted npm archive was loaded in both real hosts on Windows. Isolated smoke providers confirmed the supported effort choices, propagation of a successful decision into provider request options, and zero classifier calls before consent. The classifier response was controlled in these smoke runs: this is not a live Jev availability test or a cache-hit benchmark. Unit tests cover cancellation, manual overrides, failure preservation, privacy boundaries, configuration, and consent.
Development and release
npm install
npm run check
npm test
npm pack
npm run probe makes a real, potentially billable Jev request containing only the synthetic task in scripts/probe.js; it never sends conversation history. It uses a saved key or environment key and is an explicit diagnostic, not automatic routing.
Inspect the tarball before publishing. Its allowlist includes only runtime source, the setup CLI, package metadata, this README, and the license—no .env, tests, credentials, or local settings. npm publish --access public runs syntax checks and tests; publishing requires an npm account with permission to use the package name. Creating this package does not publish it.
License: MIT.
Release notes
0.3.0
- Interactive setup opens the host's text editor when an OpenRouter key is missing, saves it separately from settings, and activates routing without a restart.
- Environment keys remain optional overrides; headless setup remains noninteractive.
0.2.0
- Added Pi and OMP package entry points and supported-model capability discovery.
- Added persistent, versioned opt-in setup with the explicit GPT-6 Astra cache disclaimer.
- Moved settings outside the package and credentials to the host environment; removed implicit package-local
.envloading. - Preserved host-native reasoning until a classifier decision succeeds; invalidated pending decisions on model changes.