Skip to content
 
 

Repository files navigation

pi logo

Discord npm

New issues and PRs from new contributors are auto-closed by default. Maintainers review auto-closed issues daily. See CONTRIBUTING.md.

Pi Agent Harness — LocalPibox Fork

This fork of earendil-works/pi adds targeted support for Qwen models with reasoning (thinking) for local Lemonade backends (llama.cpp). All LocalPibox changes are kept as small surgical edits on top of upstream v0.84.1 so the delta is minimal and rebasing onto new releases is straightforward.

Base: upstream v0.84.1 ✅

These features are already in upstream v0.84.1 and require no LocalPibox patches:

Feature Location What it does
qwen-chat-template thinking format ai/src/api/openai-completions.ts Sends chat_template_kwargs.enable_thinking + preserve_thinking for Qwen/llama.cpp
reasoning_effort mapping ai/src/api/openai-completions.ts Sends top-level reasoning_effort for various providers
vLLM supportsThinkingTokenBudget ai/src/api/openai-completions.ts Caps reasoning via top-level thinking_token_budget (vLLM servers)
compact() method agent/src/harness/agent-harness.ts Agent harness compaction support
Compaction for Qwen thinking windows agent/src/harness/compaction/compaction.ts Passes reasoning/thinking during compaction

Added by LocalPibox on top of v0.84.1 🔧 (4 files, +29 lines)

These are the only changes this fork adds on top of v0.84.1:

File Change Why
ai/src/utils/overflow.ts Case 4 overflow detection Qwen/Llama.cpp reasoning blocks silently consume the output budget → stopReason "length" + output > 0 + input ≥ 90% of window. Without it, Pi treats overflow as a dead session after compaction.
ai/src/types.ts reasoningBudgetTokens compat field Lets a provider (e.g. the lemonade plugin) set a Qwen thinking budget (0 = soft-capped, positive = token limit, -1 = unbounded).
ai/src/api/openai-completions.ts qwen-chat-template sends reasoning_effort mapping + reasoning_budget_tokens soft-cap Reads compat.reasoningBudgetTokens and emits the reasoning_budget_tokens llama.cpp sampler param to prevent runaway thinking.

Intentionally NOT included: The SessionTreeEntry/fromHook refactor, compaction comment-only changes, and the baseten / qwen-token-plan-individual provider removals. None are required for Lemonade/Qwen support, and they are incompatible with the v0.84.1 codebase (they were written against an older v0.83 base).

Why these changes?

The target hardware (Ryzen AI Max+ 395, 128 GB unified memory) runs Qwen3.6-35B locally via Lemonade. The lemonade-pi-plugin sets reasoningBudgetTokens (soft-cap) and thinkingFormat: "qwen-chat-template" on Qwen models. This fork makes core Pi:

  • Send the reasoning_budget_tokens soft-cap so Qwen's thinking doesn't exhaust max_tokens
  • Detect Qwen reasoning-driven context overflow (Case 4) instead of leaving the session dead

Upstream mapping

LocalPibox Upstream
localpibox/pi (branch lpb) earendil-works/pi

Reporting Issues

Development

npm install --ignore-scripts  # Install all dependencies without running lifecycle scripts
npm run build         # Refresh model data, then build all packages
npm run check         # Lint, format, and type check
./test.sh            # Run tests (skips LLM-dependent tests without API keys)

License

See the upstream license. LocalPibox patches inherit the same license.

pi.dev domain graciously donated by

Exy mascot
exe.dev

About

AI agent toolkit: unified LLM API, agent loop, TUI, coding agent CLI

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages