Tracing
any_agent.tracing.agent_trace.AgentTrace
Bases: BaseModel
A trace that can be exported to JSON or printed to the console.
Source code in src/any_agent/tracing/agent_trace.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
cost
cached
property
The current total cost for this trace. Cached after first computation.
duration
property
Duration of the parent invoke_agent
span as a datetime.timedelta object.
The duration is computed from the span's start and end time (in nanoseconds).
Raises ValueError if
- There are no spans.
- The invoke_agent span is not the last span.
- Any of the start/end times are missing.
final_output = None
class-attribute
instance-attribute
Contains the final output message returned by the agent.
spans = Field(default_factory=list)
class-attribute
instance-attribute
A list of AgentSpan
that form the trace.
tokens
cached
property
The current total token count for this trace. Cached after first computation.
add_span(span)
Add an AgentSpan to the trace and clear the usage_and_cost cache if present.
add_spans(spans)
Add a list of AgentSpans to the trace and clear the usage_and_cost cache if present.
any_agent.tracing.agent_trace.AgentSpan
Bases: BaseModel
A span that can be exported to JSON or printed to the console.
Source code in src/any_agent/tracing/agent_trace.py
add_cost_info()
Extend attributes with TokenUseAndCost
.
Source code in src/any_agent/tracing/agent_trace.py
from_readable_span(readable_span)
classmethod
Create an AgentSpan from a ReadableSpan.
Source code in src/any_agent/tracing/agent_trace.py
is_agent_invocation()
Check whether this span is an agent invocation (the very first span).
is_llm_call()
is_tool_execution()
set_attributes(attributes)
Set attributes for the span.
Source code in src/any_agent/tracing/agent_trace.py
to_readable_span()
Create an ReadableSpan from the AgentSpan.