When to use this
Use this page when you want to inspect:- Which model was called
- What input and output were sent
- How long the call took
- Token usage and estimated cost when available
- Which tool ran, with what arguments, and whether it failed
Wrap an LLM client
instrumentLLM() returns a proxy with the same public shape as the original client. Known generation methods are recorded automatically.
LLM_ERROR. Calls that cross the configured latency threshold produce
LLM_SLOW_RESPONSE after two consecutive slow observations by default. Use
reportFailures: false, reportSlowResponses: false, or a wrapper-specific
slowResponseThresholdMs when a client has different expected behavior.
For async iterable streaming APIs such as streamText, Lynx keeps the original
iterator behavior and records the end of the LLM call only when iteration
reaches completion. An error raised while consuming the stream is recorded on
the same span. If a stream is created but never consumed, it has a start event
without an end event.
Guard an LLM client
UseguardLLM() when managed policies must inspect model input and output in
addition to recording the call.
LynxPolicyError before the
matching chunk is returned.
Wrap a tool
UseinstrumentTool() when you want to record a tool call without adding a policy check.
RUN_ERRORwhen the rootrun()callback throws and the failure is not already represented by a more specific Tool, LLM, or firewall detectionRUN_FAILEDwhenoutcome()explicitly records a failed technical or business resultLLM_ERRORfor an instrumented LLM failureLLM_SLOW_RESPONSEafter the configured number of consecutive slow calls
TOOL_ERROR record. An asynchronous call that
exceeds its configured timeoutMs produces TOOL_TIMEOUT. The server groups
repeated records by stable tool and error metadata, without putting the raw
error message in the fingerprint. Later successful calls produce a recovery
record after the configured threshold.
These records request asynchronous server review. They do not synchronously
create or close a final Issue, and issue-record delivery does not replace normal
application error handling.
Use reportFailures: false when a tool’s errors are expected and fully handled
by your application. A wrapper timeout cannot cancel the underlying operation,
so use the tool’s own AbortSignal or cancellation API when side effects must
stop after a timeout. Synchronous work cannot be interrupted by timeoutMs.
Use firewallTool() instead when the tool needs a policy check before it runs.
Custom LLM clients
If your client uses custom method names, pass a custom rule.What you can see in Lynx
After wrapping LLMs and tools, Lynx can show:- LLM calls in the session timeline
- Tool calls and tool results
- Failed or slow calls
- Retry patterns and repeated call loops
- Token usage, latency, and cost signals
- Related session and trace links
Security note
LLM inputs, model outputs, tool arguments, and tool results may contain sensitive data. Usemetadata-only, captureInput: false, captureOutput: false, or application-level redaction when needed.