Skip to content

agent: trace tool retry attempts#4232

Merged
asim merged 1 commit into
masterfrom
codex/increment-4231
Jul 7, 2026
Merged

agent: trace tool retry attempts#4232
asim merged 1 commit into
masterfrom
codex/increment-4231

Conversation

@asim

@asim asim commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • add OpenTelemetry attributes for tool retry attempts and configured tool retry budget
  • persist tool attempt counts in agent run history so inspect output and traces tell the same story
  • add coverage for a transient tool retry succeeding on the second attempt

Closes #4218
Closes #4231

Testing

  • go build ./...
  • go test ./agent
  • go test ./... (fails in this environment: atlascloud live stream returned 400; loopback gRPC tests are blocked by envoy "Loopback targets forbidden")
  • golangci-lint run ./...

Copilot AI review requested due to automatic review settings July 7, 2026 09:58
@asim asim added the codex label Jul 7, 2026
@asim asim merged commit 5b32014 into master Jul 7, 2026
10 checks passed

Copilot AI 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.

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 thread agent/otel.go
Comment on lines +369 to +372
toolAttempts := res.Attempts
if toolAttempts <= 0 {
toolAttempts = 1
}
Comment thread agent/otel.go
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 thread agent/otel_test.go
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loop: build increment #115 agent: emit OpenTelemetry spans from run history

3 participants