ExecuteToolScope Class
Provides OpenTelemetry tracing scope for AI tool execution operations.
Initialize the tool execution scope.
Constructor
ExecuteToolScope(request: Request, details: ToolCallDetails, agent_details: AgentDetails, user_details: UserDetails | None = None, span_details: SpanDetails | None = None)
Parameters
| Name | Description |
|---|---|
|
request
Required
|
Request details for the tool execution |
|
details
Required
|
The details of the tool call |
|
agent_details
Required
|
The details of the agent making the call |
|
user_details
|
Optional human user details Default value: None
|
|
span_details
|
Optional span configuration (parent context, timing, kind) Default value: None
|
Methods
| record_response |
Record the tool call result for telemetry tracking. Per OTEL spec, the result is expected to be an object. If a string is provided, it is recorded as-is (JSON string fallback). If a dict is provided, it is serialized to JSON. |
| start |
Creates and starts a new scope for tool execution tracing. |
record_response
Record the tool call result for telemetry tracking.
Per OTEL spec, the result is expected to be an object. If a string is provided, it is recorded as-is (JSON string fallback). If a dict is provided, it is serialized to JSON.
record_response(result: dict[str, object] | str) -> None
Parameters
| Name | Description |
|---|---|
|
result
Required
|
Tool call result as a structured dict or JSON string |
start
Creates and starts a new scope for tool execution tracing.
static start(request: Request, details: ToolCallDetails, agent_details: AgentDetails, user_details: UserDetails | None = None, span_details: SpanDetails | None = None) -> ExecuteToolScope
Parameters
| Name | Description |
|---|---|
|
request
Required
|
Request details for the tool execution |
|
details
Required
|
The details of the tool call |
|
agent_details
Required
|
The details of the agent making the call |
|
user_details
|
Optional human user details Default value: None
|
|
span_details
|
Optional span configuration (parent context, timing, kind) Default value: None
|
Returns
| Type | Description |
|---|---|
|
A new ExecuteToolScope instance |