Skip to content

Adapters

The adapter protocol and framework-specific implementations.

AgentAdapter Protocol

AgentAdapter

Bases: Protocol

Minimal interface any agent must implement for testing.

All agent-facing APIs are async-first. Sync agents are supported via the GenericAdapter which wraps sync callables in a thread executor.

Streaming is optional — adapters may also implement: async def run_stream(self, input: AgentInput) -> AsyncIterator[StreamEvent]

If run_stream is not present, CheckAgent falls back to run() and synthesizes streaming events from the completed trace.

run(input) async

Execute the agent and return a structured trace.

GenericAdapter

GenericAdapter(fn)

Wraps any Python callable to conform to the AgentAdapter protocol.

The callable should accept a string (the query) and return a string or any value that becomes the final_output. Additional kwargs from AgentInput.context are forwarded if the callable accepts **kwargs.

run(input) async

Execute the wrapped callable and return an AgentRun trace.

Accepts either an AgentInput or a plain string (converted automatically).

run_stream(input) async

Fallback stream — runs the callable and synthesizes events.

wrap

wrap(fn=None)

wrap(fn: Callable[..., Any]) -> GenericAdapter
wrap() -> Callable[[Callable[..., Any]], GenericAdapter]

Wrap a callable as a GenericAdapter. Usable as decorator or function.

@wrap async def my_agent(query: str) -> str: ...

or

adapter = wrap(my_sync_function)

Framework Adapters

Framework adapters require their respective packages to be installed. Install with optional extras:

pip install checkagent[langchain]     # LangChain
pip install checkagent[openai-agents] # OpenAI Agents SDK
pip install checkagent[pydantic-ai]   # PydanticAI
pip install checkagent[crewai]        # CrewAI
pip install checkagent[anthropic]     # Anthropic

LangChainAdapter

LangChainAdapter(runnable, *, input_key='input', extra_inputs=None)

Wraps a LangChain Runnable (chain, agent, or graph) as an AgentAdapter.

Parameters

runnable : Any A LangChain Runnable — could be a chain, agent executor, RunnableSequence, or LangGraph StateGraph / compiled graph. input_key : str Key used to pass the query into the runnable's invoke dict. Defaults to "input". extra_inputs : dict[str, Any] | None Additional variables to include in every invocation dict. Useful for multi-variable prompt templates (e.g. RAG chains needing context). Per-run values from AgentInput.context override these defaults.

run(input) async

Execute the runnable and return an AgentRun trace.

run_stream(input) async

Stream execution events via LangChain's astream_events API.

OpenAIAgentsAdapter

OpenAIAgentsAdapter(agent)

Wraps an OpenAI Agents SDK Agent as an AgentAdapter.

Parameters

agent : Any An agents.Agent instance.

run(input) async

Execute the agent via Runner.run() and return an AgentRun trace.

run_stream(input) async

Stream execution via Runner.run_streamed().

PydanticAIAdapter

PydanticAIAdapter(agent)

Wraps a PydanticAI Agent as an AgentAdapter.

Parameters

agent : Any A PydanticAI Agent instance.

run(input) async

Execute the agent and return an AgentRun trace.

run_stream(input) async

Stream execution events via PydanticAI's run_stream().

CrewAIAdapter

CrewAIAdapter(crew)

Wraps a CrewAI Crew as an AgentAdapter.

Parameters

crew : Any A CrewAI Crew instance.

run(input) async

Execute the crew and return an AgentRun trace.

run_stream(input) async

Stream execution events (synthesized from final result).

AnthropicAdapter

AnthropicAdapter(client, *, model='claude-sonnet-4-20250514', system=None, max_tokens=1024)

Wraps an Anthropic client as an AgentAdapter.

run(input) async

Send a message and return an AgentRun trace.

run_stream(input) async

Stream execution events via Anthropic's streaming API.