Skip to content

fix(pi): the proxy plane connects the way pi does - #389

Merged
xxchan merged 1 commit into
mainfrom
fix/pi-dispatcher-parity
Oct 13, 2026
Merged

xxchan merged 1 commit into
mainfrom
fix/pi-dispatcher-parity

Conversation

@xxchan

@xxchan xxchan commented Oct 13, 2026

Copy link
Copy Markdown
Member

Bug. When pi's settings or the environment name a proxy, or set a non-default idle timeout, OAR's pi proxy plane installs an undici 8 EnvHttpProxyAgent as the process-global dispatcher. It left out the connection options pi's own dispatcher sets (pi-coding-agent 1.2.0 core/http-dispatcher.js):

  • allowH2: false: undici 8 otherwise negotiates HTTP/2.
  • proxyTunnel: true: undici 8.7+ otherwise sends http targets to a proxy without a CONNECT tunnel.
  • connect.autoSelectFamilyAttemptTimeout: 2000.

So an embedded pi connected differently from pi itself. And because the plane is the global dispatcher, so did every global fetch in the host. Found while reviewing Raft's daemon move from undici 7 to 8 for #386, where Raft deliberately keeps HTTP/1.1.

Fix.

  • piDispatcherOptions(plan) builds the agent's options with pi's three settings plus the plan.
  • docs/runtimes/pi.md reverses its earlier "allowH2/connect tuning not taken" and says why.
  • undici.install() and pi's per-client error listener stay out, as before.

Tests.

  • A new test pins the options. It also reads the installed pi's http-dispatcher.js, so a change in pi fails it.
  • The proxy tests' stand-in now answers CONNECT, as a proxy pi talks to must.
  • Typecheck, lint, the full unit suite (1782 tests) and the pi-aimock vendor suite (38) pass.

Behavior change. Only when the plane is installed: HTTP/1.1 instead of possibly HTTP/2, and CONNECT tunnels for http targets behind a proxy, both as pi does.

🤖 Generated with Claude Code

…tunnels)

OAR's pi proxy plane built undici 8's EnvHttpProxyAgent without the
options pi's own dispatcher sets (pi-coding-agent 1.2.0
core/http-dispatcher.js): allowH2: false, proxyTunnel: true and a 2 s
address-family attempt timeout. undici 8 otherwise negotiates HTTP/2 and
sends http targets to a proxy without a CONNECT tunnel, so an embedded pi
connected differently from pi itself, and, the plane being the global
dispatcher, so did every global fetch in the host. Found while reviewing
Raft's daemon move to undici 8 (#386), where the host keeps HTTP/1.1.

piDispatcherOptions builds the options; a test reads pi's own file, so a
change there fails it. The proxy tests' stand-in now answers CONNECT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 041c0f7 into main Oct 13, 2026
17 checks passed
@xxchan
xxchan deleted the fix/pi-dispatcher-parity branch October 13, 2026 12:25
@xxchan xxchan mentioned this pull request Oct 13, 2026
xxchan added a commit that referenced this pull request Oct 13, 2026
Release OAR and CLI 0.62.1. This PR changes only the two package version
fields.

**Fixed: pi's proxy plane connects the way pi does** (#389)
- When pi's settings or the environment name a proxy (or set a
non-default idle timeout), OAR installs an undici `EnvHttpProxyAgent` as
the process-global dispatcher for an embedded pi.
- It now carries the connection options pi's own dispatcher sets
(pi-coding-agent 1.2.0 `core/http-dispatcher.js`):
  - `allowH2: false`;
  - `proxyTunnel: true`;
  - a 2 s address-family attempt timeout.
- Before this, undici 8 could negotiate HTTP/2 and send http targets to
a proxy without a CONNECT tunnel. An embedded pi connected differently
from `pi` itself, and so did every global `fetch` in the host, because
the dispatcher is process-global.
- A test reads pi's own file, so a change in pi shows up.
- A dispatcher the host set itself is still never replaced.

**Docs** (#387, #388)
- `docs/runtimes/pi.md` says a bundled host must keep one copy of pi-ai,
and why: an `undici` that differs from pi-coding-agent's pin splits it.
It also says how to check a bundle (#386).

**Behavior changes**
- Only when the plane is installed: HTTP/1.1 instead of possibly HTTP/2,
and CONNECT tunnels for http targets behind a proxy, as `pi` does.

Validation: #389 passed all 17 checks on its final head, and its merged
tree equals its CI tree. Typecheck, lint, the unit suite (1782 tests)
and the pi-aimock vendor suite (38) pass. The proxy tests now go through
a stand-in that answers CONNECT. After this PR passes CI and merges, tag
its exact squash commit as `v0.62.1` to trigger npm trusted publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant