Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ title: "Tool Spans Creation"
description: "Manually trace tool functions alongside LLM calls by creating spans that capture inputs, outputs, and key events."
---

## What it is
## About

**Tool Spans** let you manually instrument tool functions so they appear as structured spans in your traces. You create a parent span for the tool call — setting attributes like `fi.span.kind`, input value, function name, and argumentsthen nest an LLM span underneath it to capture the model's response. This gives you full visibility into both the tool execution and the LLM call that follows.
LLM agents often call external tools (APIs, databases, code interpreters), but these calls are invisible in traces unless manually instrumented. Tool spans make each tool invocation visible by creating a parent span with the function name, arguments, and output, then nesting an LLM span underneath to capture the model's response. The result is a full parent/child trace showing both what the tool did and what the LLM returned.

## Use cases
---

## When to use

- **Tool call visibility** Trace each tool invocation with its function name, arguments, and output as structured span attributes.
- **Nested LLM tracing** Capture the LLM response as a child span under the tool span to see the full request/response chain.
- **Debugging tool chains** Inspect the exact input and output at each step when a tool call feeds into an LLM call.
- **Tool call visibility**: Trace each tool invocation with its function name, arguments, and output as structured span attributes.
- **Nested LLM tracing**: Capture the LLM response as a child span under the tool span to see the full request/response chain.
- **Debugging tool chains**: Inspect the exact input and output at each step when a tool call feeds into an LLM call.

---

Expand Down Expand Up @@ -227,16 +229,16 @@ description: "Manually trace tool functions alongside LLM calls by creating span

## Key concepts

- **`fi.span.kind: "TOOL"`**Marks the span as a tool call so it renders with the correct icon and label in the Future AGI dashboard.
- **`fi.span.kind: "LLM"`**Marks the nested span as an LLM call. Nesting it inside the tool span creates a parent/child relationship visible in the trace tree.
- **`message.tool_calls.0.tool_call.function.name`**The name of the tool function being called, captured before execution in case the tool raises an exception.
- **`message.tool_calls.0.tool_call.function.arguments`**JSON-serialized arguments passed to the tool function.
- **`message.tool_calls.0.tool_call.function.output`**The tool's return value, set after the function completes.
- **`input.value` / `output.value`**Standard span attributes for the input and output of each span.
- **`fi.span.kind: "TOOL"`**:Marks the span as a tool call so it renders with the correct icon and label in the Future AGI dashboard.
- **`fi.span.kind: "LLM"`**:Marks the nested span as an LLM call. Nesting it inside the tool span creates a parent/child relationship visible in the trace tree.
- **`message.tool_calls.0.tool_call.function.name`**:The name of the tool function being called, captured before execution in case the tool raises an exception.
- **`message.tool_calls.0.tool_call.function.arguments`**:JSON-serialized arguments passed to the tool function.
- **`message.tool_calls.0.tool_call.function.output`**:The tool's return value, set after the function completes.
- **`input.value` / `output.value`**:Standard span attributes for the input and output of each span.

---

## What you can do next
## Next Steps

<CardGroup cols={2}>
<Card title="Instrument with traceAI Helpers" icon="plug" href="/docs/observe/features/manual-tracing/instrument-with-traceai-helpers">
Expand Down