agent: trace tool retry attempts#4232
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the agent’s OpenTelemetry instrumentation to explicitly record tool retry attempt counts and configured tool retry budgets, and ensures those attempt counts are also persisted in run history so CLI inspection and traces remain consistent.
Changes:
- Add new OTel attribute keys for tool attempts/max attempts (
agent.tool.attempt,agent.tool.max_attempts). - Record tool attempt counts + configured tool retry budget on tool spans and persisted run events.
- Add a deterministic test covering a transient tool failure that succeeds on a retry, asserting both span attributes/events and persisted run history.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
agent/otel.go |
Adds tool attempt/max attempt attributes to tool spans and maps persisted run events to tool-specific attempt attribute keys. |
agent/otel_test.go |
Adds a new test validating tool retry attempt attribution in both OTel spans/events and persisted run history. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+369
to
+372
| toolAttempts := res.Attempts | ||
| if toolAttempts <= 0 { | ||
| toolAttempts = 1 | ||
| } |
Comment on lines
+387
to
+394
| toolAttempts := res.Attempts | ||
| if toolAttempts <= 0 { | ||
| toolAttempts = 1 | ||
| } | ||
| attrs = append(attrs, attribute.Int(AttrToolAttempt, toolAttempts)) | ||
| if a.opts.ToolMaxAttempts > 0 { | ||
| attrs = append(attrs, attribute.Int(AttrToolMaxAttempts, a.opts.ToolMaxAttempts)) | ||
| } |
Comment on lines
+192
to
+199
| summaries, err := ListRunSummaries(st, "tool-retry-otel") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| events, err := LoadRunEvents(st, "tool-retry-otel", summaries[0].RunID) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } |
This was referenced Jul 7, 2026
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.
Summary
Closes #4218
Closes #4231
Testing