Skip to content

fix(pi): align agent instrumentation with tracing spec - #2682

Open
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
mainfrom
compare-pi-instrumentatio-d012543b
Open

Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
mainfrom
compare-pi-instrumentatio-d012543b

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

🤖 This text was AI-generated.

Pi instrumentation did not always reflect what happened during a prompt:

  • Listening to agent events missed tools invoked through the session, so nested tool calls and their application spans could be absent or misplaced.
  • Tool start and end events could be emitted for a call blocked before its executor ran, but the trace marked that call as approved.
  • An installed tool wrapper could retain one SDK copy's tracing state after another copy became active, losing context and approval information.
  • Some error, attachment, usage, and request metadata handling did not fully match the instrumentation specification. Queued streaming prompts could also produce misleading prompt spans.
  • Several Pi version scenarios used fabricated responses, leaving their behavior against real provider responses unverified.

Subscribe to session events and route tool callbacks through a shared invocation hook. This captures the tool lifecycle and places application spans under the tool that created them:

prompt
├── model calls
└── tool execution
    └── application spans

Record approval only when the executor actually runs; leave it unset when execution cannot be observed. Preserve tool context across SDK copies and plugin teardown, and update errors, attachments, usage metrics, and metadata to follow the instrumentation specification. Avoid creating prompt spans for work only queued while Pi is streaming.

Replace fabricated responses with recorded provider responses for pinned and latest Pi versions, update the span-tree snapshots, and combine redundant tests while preserving coverage of the instrumentation behavior.

> 🤖 **This text was AI-generated.**

Pi instrumentation did not always reflect what happened during a prompt:

- Listening to agent events missed tools invoked through the session, so
  nested tool calls and their application spans could be absent or misplaced.
- Tool start and end events could be emitted for a call blocked before its
  executor ran, but the trace marked that call as approved.
- An installed tool wrapper could retain one SDK copy's tracing state after
  another copy became active, losing context and approval information.
- Some error, attachment, usage, and request metadata handling did not fully
  match the instrumentation specification. Queued streaming prompts could
  also produce misleading prompt spans.
- Several Pi version scenarios used fabricated responses, leaving their
  behavior against real provider responses unverified.

Subscribe to session events and route tool callbacks through a shared
invocation hook. This captures the tool lifecycle and places application
spans under the tool that created them:

```
prompt
├── model calls
└── tool execution
    └── application spans
```

Record approval only when the executor actually runs; leave it unset when
execution cannot be observed. Preserve tool context across SDK copies and
plugin teardown, and update errors, attachments, usage metrics, and metadata
to follow the instrumentation specification. Avoid creating prompt spans
for work only queued while Pi is streaming.

Replace fabricated responses with recorded provider responses for pinned and
latest Pi versions, update the span-tree snapshots, and combine redundant
tests while preserving coverage of the instrumentation behavior.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T15:13:59.449719Z 38c1e57 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

> 🤖 **This text was AI-generated.**

Add a patch release note describing the Pi instrumentation fixes.

This branch has not been deployed

No deployments
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