Skip to content

Conversation

@raphael
Copy link
Member

@raphael raphael commented Dec 26, 2025

Summary

When providers do not supply a tool_call_id, the runtime generates a deterministic ID in the format:

<runID>/<turnID>/<tool>/<index>

This caused collisions when the same run executed multiple tool batches within a single logical turn (common when TurnID is set to a constant run identifier). The same tool at the same index would receive identical IDs across different batches, causing metadata overwrites in downstream caches keyed by tool_call_id.

Fix

The fix adds the attempt counter to the generated ID:

<runID>/<turnID>/attempt-<attempt>/<tool>/<index>

The runtime increments Attempt on each planner iteration, ensuring generated IDs remain unique within the run even when TurnID is constant.

Changes

  • helpers.go: Updated generateDeterministicToolCallID to accept an attempt parameter
  • workflow.go: Pass base.RunContext.Attempt to the ID generator
  • tool_calls.go: Pass runCtx.Attempt to the ID generator
  • finalizer_invoker.go: Pass attempt=1 for finalizer tools
  • helpers_test.go: Added tests verifying uniqueness across attempts

Testing

  • Unit tests added and passing
  • Full test suite passes

…t collisions

When providers do not supply a tool_call_id, the runtime generates a
deterministic ID in the format: <runID>/<turnID>/<tool>/<index>

This caused collisions when the same run executed multiple tool batches
within a single logical turn (common when TurnID is set to a constant run
identifier). The same tool at the same index would receive identical IDs
across different batches, causing metadata overwrites in downstream
caches keyed by tool_call_id.

The fix adds the attempt counter to the generated ID:
  <runID>/<turnID>/attempt-<attempt>/<tool>/<index>

The runtime increments Attempt on each planner iteration, ensuring
generated IDs remain unique within the run even when TurnID is constant.
@raphael raphael merged commit d15a2d5 into main Dec 26, 2025
2 checks passed
@raphael raphael deleted the fix/deterministic-tool-call-id-collision branch December 26, 2025 17:48
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.

2 participants