@bismawy/pi-agentrouter

Unified frontier models. Self-healing WAF recovery. Zero workflow interruption. GPT-6 Astra, Claude, DeepSeek and GLM under one agentrouter/ namespace.

Packages

Package details

extension

Install @bismawy/pi-agentrouter from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@bismawy/pi-agentrouter
Package
@bismawy/pi-agentrouter
Version
1.7.0
Published
Oct 24, 2026
Downloads
760/mo · 394/wk
Author
bismawy
License
MIT
Types
extension
Size
103.3 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "image": "https://raw.githubusercontent.com/bismawy/pi-agentrouter/main/assets/banner.webp",
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

AgentRouter

Unified frontier models. Self-healing WAF recovery. Zero workflow interruption.

Custom badge badge license

Overview

pi-agentrouter provides a unified provider for AgentRouter in Pi — routing GPT-6 Astra, GPT-5.6 Sol, Claude Opus 4.8 / 5, DeepSeek V4 Flash, and GLM 5.3 under a single agentrouter/ namespace with self-healing WAF recovery.

  • Protocol Routing: GPT-6 Astra routes via OpenAI Responses, Claude models via Anthropic Messages, and others via OpenAI Completions under one provider.
  • WAF Header & Language Guard: Forces Pi's canonical system header to byte 0 and applies language framing on user turns.
  • Self-Healing Recovery: Redacts older history turns in two stages on content-filter triggers, and automatically translates the latest turn to English when needed.
  • Payload Sanitization: Strips ANSI escape codes, null bytes, control characters, and orphan Unicode surrogates before dispatch.
  • Session Affinity: Injects sendSessionAffinityHeaders: true by default to maximize server-side cache hits.

Model Catalog

The catalog is discovered live: on every pi model refresh (startup and right after /login), the extension probes GET https://agentrouter.org/v1/models with your key and registers exactly what the account lists — no manual model entries. Any probe failure (offline, missing key, WAF) falls back to the last confirmed snapshot. Current snapshot and verified wire configs:

Model Context Input Protocol Thinking
agentrouter/gpt-6-astra 272k text, image OpenAI Responses low – xhigh
agentrouter/gpt-5.6-sol 272k text, image OpenAI Completions low – xhigh
agentrouter/gpt-6.1-sol 272k text, image OpenAI Responses low – xhigh

Catalog ids without a verified config register with a conservative text-only default. Retired ids keep their wire configs in MODEL_BLUEPRINTS, so a relisted model (e.g. claude-opus-5, glm-5.3, deepseek-v4-flash) automatically comes back with the right protocol.

Install

pi install npm:@bismawy/pi-agentrouter

Supply your API key via /login agentrouter, export AGENTROUTER_API_KEY="your-key", or in ~/.pi/agent/models.json.

No account yet? Register on AgentRouter for a $50 bonus.

To test locally without installing:

pi -e ./index.ts

Commands

Command Action
/agentrouter Interactive menu with Status and Usage panels
/agentrouter status View active models, status, and balance in a styled TUI panel
/agentrouter usage Inspect session usage metrics and cost estimates

Architecture

  1. Forces Pi's system prompt header to the very start of the payload.
  2. On content-blocked or sensitive-words errors, marks the turn retryable for automatic recovery.
  3. Stage 1 redacts older user turns; Stage 2 escalates to assistant turns while preserving tool pairs.
  4. Stage 3 translates the newest turn to English if redaction is exhausted, avoiding user turn deletion.
  5. Redaction depth resets on new conversations or compaction.
npm test # Runs check-framing.ts self-checks

License

Distributed under the MIT license.

Author

Bisma