Skip to content

feat: record gen_ai.tool.call.id on Python and C# tool spans - #818

Open
nik13 wants to merge 1 commit into
devfrom
feat/tool-call-id-py-csharp
Open

nik13 wants to merge 1 commit into
devfrom
feat/tool-call-id-py-csharp

Conversation

@nik13

@nik13 nik13 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  1. Python (fi-instrumentation-otel):
    • get_tool_attributes accepts a keyword-only tool_call_id and sets gen_ai.tool.call.id when it is a non-empty string.
    • FiSpan.set_tool accepts tool_call_id, and FiSpan.set_tool_call_id sets gen_ai.tool.call.id on a tool span (raising ValueError on any other span kind).
    • FITracer.tool(tool_call_id_arg=...) reads the named argument after binding (including through **kwargs) and records it in the start attributes of sync, async, generator, and async generator tool spans; missing, empty, or non-string values are skipped.
  2. C# (FIInstrumentation):
    • FISpan.SetTool accepts an optional toolCallId, and FISpan.SetToolCallId sets gen_ai.tool.call.id directly; both skip null or empty values.
    • Preserves the 1.0 SetTool(string name, string? description, object? parameters) signature as a hidden overload so assemblies built against 1.0 keep binary compatibility.
  3. Updates README and CHANGELOG entries for both packages.

Why?

Tool spans carried tool name, description, and parameters without gen_ai.tool.call.id, leaving no direct attribute link back to the model's tool call entry in Python and C# manual instrumentation.

How was it tested?

  • Python (python/tests/test_tracers.py): 15 unit tests covering get_tool_attributes, FiSpan.set_tool, FiSpan.set_tool_call_id (including non-tool span ValueError), and @tracer.tool(tool_call_id_arg=...) across sync, async, generator, async generator, **kwargs, missing, empty, and non-string values.

  • C# (csharp/tests/FIInstrumentation.Tests/FISpanTests.cs): 6 unit tests covering SetTool(..., toolCallId: ...), SetToolCallId(...), null/empty skipping, suppressed spans, and 3-argument overload compatibility.

  • Full regression matrices (0 new failures): fi_instrumentation (5,738 tests, +15), core-compat across 34 Python 3.10–3.15 configs (180,455 tests), 81 framework packages (99 suites, 13,025 tests), 24 path-triggered framework workflows, and C# .NET matrix (FIInstrumentation.Tests 510/510, AutoInstrumentation.Tests 1,771/1,771, HostingStartup.Tests 130/130).

  • Unit tests added / updated (pytest / dotnet test)

  • Integration tests pass (or N/A — no gateway behavior changed)

  • Docs and changelogs updated (python/README.md, python/CHANGELOG.md, csharp/src/FIInstrumentation/README.md, csharp/src/FIInstrumentation/CHANGELOG.md)

Checklist

  • Commit messages follow Conventional Commits
  • No TODOs or commented-out code left in
  • No real API keys or secrets in the diff
  • If prose was added or changed: checked against docs/VOCABULARY.md

Notes for reviewers

Targets dev.

Python (fi_instrumentation):
- get_tool_attributes takes a keyword-only tool_call_id and sets
  gen_ai.tool.call.id when it is a non-empty string.
- FiSpan.set_tool takes tool_call_id; FiSpan.set_tool_call_id sets the
  id on a tool span and raises ValueError on any other span kind.
- FITracer.tool(tool_call_id_arg=...) names the decorated function's
  argument that carries the model's tool call id. The id is read after
  binding (including through **kwargs) and lands in the start attributes
  of sync, async, generator and async generator tools. A missing, empty
  or non-string value is skipped.

C# (FIInstrumentation):
- FISpan.SetTool takes an optional toolCallId and FISpan.SetToolCallId
  sets it on its own; both skip a null or empty id. The 1.0
  SetTool(name, description, parameters) signature stays as a hidden
  overload so assemblies built against it keep binding.

Docs and changelogs describe the new parameters.

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