Skip to content

fix(pi-coding-agent): support streamFn -> streamFunction rename - #2392

Open
Alex Jean-Baptiste (justcodebruh) wants to merge 1 commit into
mainfrom
ajb-pi-compat-fix
Open

fix(pi-coding-agent): support streamFn -> streamFunction rename#2392
Alex Jean-Baptiste (justcodebruh) wants to merge 1 commit into
mainfrom
ajb-pi-compat-fix

Conversation

@justcodebruh

@justcodebruh Alex Jean-Baptiste (justcodebruh) commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • @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 on pi >= 0.81 no spans were emitted.

  • Resolves whichever property actually exists on the agent (streamFn or streamFunction) 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.2 with braintrust@3.27.0 no 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

  • Added a regression test (patches agent.streamFunction when streamFn is absent (pi >= 0.81)) in pi-coding-agent-plugin.test.ts covering the new shape.

@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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +239 to +240
// `agent.streamFunction` starting in v0.81.0. Resolve whichever property
// actually exists so both the pre- and post-rename shapes are patchable.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +431 to +435
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");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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