Skip to main content

Installation

Setup

Wrap your OpenAI client with patch():
patch() wraps client.chat.completions.create to automatically log every LLM turn into the active reagent-flow session.

Basic usage

Tool result capture

When you send tool results back in the next create() call, the adapter automatically attaches them to the turn that requested them:
JSON-encoded tool content is automatically decoded before validation, so assert_tool_output_matches can validate dict/list shapes even when the content was serialized as a string.

What gets captured

Streaming

Streaming (stream=True) is detected and skipped with a warning. Use stream=False for traced calls.

No session active

If no reagent-flow session is active when create() is called, the adapter is a no-op — the original call passes through unchanged.