Repository navigation
fix(pi): align agent instrumentation with tracing spec - #2682
Open
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Open
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Conversation
> 🤖 **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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pi instrumentation did not always reflect what happened during a prompt:
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:
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.