fix(pi-coding-agent): support streamFn -> streamFunction rename - #2392
fix(pi-coding-agent): support streamFn -> streamFunction rename#2392Alex Jean-Baptiste (justcodebruh) wants to merge 1 commit into
Conversation
@earendil-works/pi-coding-agent renamed agent.streamFn to agent.streamFunction starting in v0.81.0. wrapPiCodingAgentSDK and the Pi Coding Agent auto-instrumentation plugin only detected/patched streamFn, so tracing silently stopped emitting spans on pi >= 0.81 (observed on 0.84.2). Resolve whichever property actually exists on the agent and patch that one instead of assuming streamFn.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 426b546408
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| // `agent.streamFunction` starting in v0.81.0. Resolve whichever property | ||
| // actually exists so both the pre- and post-rename shapes are patchable. |
There was a problem hiding this comment.
Expand the auto-instrumentation version range
For the reported 0.84.2 auto-hook case, this resolver is never reached: js/src/auto-instrumentations/configs/pi-coding-agent.ts:4 still restricts the transform to >=0.79.0 <0.82.0, so Orchestrion skips AgentSession.prompt on every 0.82+ installation. The manual wrapper may benefit, but default auto-instrumentation continues emitting no Pi spans; extend the config and verify the target path for the versions this change claims to support.
AGENTS.md reference: AGENTS.md:L28-L30
Useful? React with 👍 / 👎.
| it("patches agent.streamFunction when streamFn is absent (pi >= 0.81)", async () => { | ||
| const interceptor = promptInterceptor(enablePlugin(plugins)); | ||
| const finalMessage = makeAssistantMessage("done"); | ||
| const originalStreamFn = vi.fn(async () => makeStream(finalMessage)); | ||
| const agent = makeAgent(originalStreamFn, "streamFunction"); |
There was a problem hiding this comment.
Exercise the renamed SDK in e2e
This synthetic-agent unit test is the only new verification, while the Pi e2e scenario remains pinned to 0.79.1 and 0.79.10, so neither the real 0.81+ package shape nor its wrapped and auto-hook paths are exercised. Add pinned and separately named latest dependency variants for the renamed API and include both in the CI e2e summary as required for newly supported instrumentation versions.
AGENTS.md reference: AGENTS.md:L60-L60
Useful? React with 👍 / 👎.
Summary
@earendil-works/pi-coding-agentrenamedagent.streamFntoagent.streamFunctionstarting in v0.81.0.wrapPiCodingAgentSDKand the Pi Coding Agent auto-instrumentation plugin only detected/patchedstreamFn, so on pi >= 0.81 no spans were emitted.Resolves whichever property actually exists on the agent (
streamFnorstreamFunction) and patches that one, so both pre- and post-rename shapes work.Context
Surfaced via the customer, Unit, running
@earendil-works/pi-coding-agent@0.84.2withbraintrust@3.27.0no logs were reaching Braintrust at all.Verified end-to-end locally against pi 0.84.2 with a one-off patched build before opening this PR.
Test plan
patches agent.streamFunction when streamFn is absent (pi >= 0.81)) inpi-coding-agent-plugin.test.tscovering the new shape.