The handoff mechanism structures agent claims—such as the result of an API call—and submits them to an evaluation service. These claims are evaluated deterministically against authoritative records to provide verifiable runtime guardrails.
Agent frameworks (OpenAI Agents SDK, LangChain) should use SourceryKitAgentResponse as the structured output type. This enforces a typed contract where the LLM returns a reasoning string and a claimed_values list—a flat collection of ClaimedValue objects, each with a JSONPath-style path and an extracted string value. These claimed_values feed directly into the handoff payload.
The following example demonstrates how to construct a claim, bundle it into a HandoffPayload, and submit it for evaluation:
import uuid
from agents import Agent, Runner
from sourcerykit import build_handoff_payload, evaluate_handoff, SourceryKitAgentResponse
# Set SourceryKitAgentResponse as the structured output type on your agent.
# Pass the keyword argument supported by your framework, e.g.:
# output_type=SourceryKitAgentResponse (OpenAI Agents SDK)
# response_format=SourceryKitAgentResponse (LangChain)
agent = Agent(
name="demo",
instructions="You are a helpful assistant.",
tools=[...],
model=MODEL_NAME,
output_type=SourceryKitAgentResponse,
)
result = await Runner.run(agent, prompt)
final_output: SourceryKitAgentResponse = result.final_output
# Build the handoff payload from the agent's structured output
payload_data = {
"reasoning": final_output.reasoning,
"claims": [
{
"action_name": "get_data",
"claimed_value": final_output.claimed_values,
"verification_mode": "field_extraction",
}
],
}
# Assemble the handoff payload using the flat SDK builder
payload = await build_handoff_payload(
payload_data,
run_id=uuid.uuid4(),
intercept_agent_id="demo",
)
# Submit the payload directly to the evaluator
result = await evaluate_handoff(payload=payload)
print(f"Evaluation Verdict: {result.get('outcome')}")
# Returns: {"outcome": "PASS" | "CAUGHT" | "ERROR", "per_claim": [...], "errors": [...]}The build_handoff_payload function accepts a structured payload_data dictionary. Other runtime fields—such as network intercepts, organization IDs, and API keys—are resolved automatically by the SDK during compilation.
The fields below represent a complete and exhaustive view of the parameters you can manually configure. Any schema fields omitted from these tables are managed entirely by the SDK lifecycle.
| Field | Type | Description |
|---|---|---|
reasoning | str | None | Detailing the agent's logic or intent for the overall execution slice. |
claims | list[HandoffClaim] | A complete list of raw claim dictionaries to be resolved into execution claims. |
| Field | Type | Description |
|---|---|---|
action_name | str | Logical identifier for the agent action producing the claim. |
claimed_value | Any | The specific data value or object subset the agent claims to be true. |
verification_mode | str | The verification strategy applied to this specific claim (e.g., field_extraction). |
range_min | float | int | None | Optional inclusive lower bound boundary used for range_threshold mode. |
range_max | float | int | None | Optional inclusive upper bound boundary used for range_threshold mode. |
The evaluation engine processes claims using one of four specific strategies:
When evaluate_handoff is invoked, the evaluator validates data integrity through a multi-layered trust gate:
For details on how database logging works, see architecture. To learn how HTTP requests are captured in real-time, see interceptor.