Three decorators cover the vast majority of instrumentation needs. Each captures inputs and outputs, measures duration, and emitsDocumentation Index
Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
Use this file to discover all available pages before exploring further.
*_start and *_end events to Observatory.
@agent
The top-level decorator. Wrap the function that handles one user request.
Parameters
The agent identifier. Shows up in the Agent column on LLM Calls, in Risk Dashboard, and in ROI baselines. Use kebab-case.
Identifier of the user this run belongs to. Surfaces in filters and Threads grouping.
Arbitrary user properties attached to the run (e.g.
{"plan": "enterprise"}).Tags attached to every run of this agent (e.g.
["claims", "prod"]). Used for filtering in LLM Calls and analytics.@chain
Use for sub-steps that aren’t external work but are worth seeing in the trace.
Parameters
Same shape as@agent. The chain inherits the parent run’s app and project context — you only need to name it.
@tool
Use for the leaf-level units of work — database queries, REST calls, file operations, computation.
Parameters
Same signature as@agent — name, user_id, user_props, tags.
Async functions
All three decorators detectasync def and wrap it natively. No different syntax.
Error handling
If the wrapped function raises, the SDK:- Emits an
*_endevent withstatus=errorand the exception’s class and message. - Re-raises the exception unchanged.
try/except still runs.
Class-based instrumentation
The decorators also work on methods. Use@agent on the entry method of a class:
self is excluded from captured inputs automatically.
When NOT to use a decorator
| Situation | Better choice |
|---|---|
You want to attach a custom event (saved, chat) | Call track_event() directly. |
| The function runs millions of times per request | Decorate the parent, not the leaf. |
| You only want to record success metrics | Use the analytics API on the recorded run instead. |
Related resources
Event reporting
Custom events and the wire protocol.
SDK overview
Install and configuration.

