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.
HandoffPayload.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": [...]}outcome is the overall verdict:
PASS — every claim was verified against the recorded data and matched.CAUGHT — at least one claim did not match the recorded data, or used an untrusted endpoint.ERROR — nothing could be verified (for example, no claim matched an intercept record).
Verifying zero claims always resolves to ERROR, never PASS.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.
NOTE
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 |
range_max | `float | int |
The evaluation engine processes claims using one of four specific strategies:
json_path string and compares it directly to the claimed_value.claimed_value and falls inclusively between defined range_min and range_max boundaries.When evaluate_handoff is invoked, the evaluator validates data integrity through a multi-layered trust gate:
Pre-Flight Check: Any claim missing a valid query_record_id fails immediately with a CAUGHT status.
Retrieve Logs & Proof: The engine uses the payload credentials to fetch the original HTTP query logs, response headers, and the cryptographic proof recorded during the interception phase.
Verify Cryptographic Proof: Before running any logical data checks, the engine validates the proof of the retrieved logs. This guarantees that:
Run Verification Rules: The engine applies your chosen verification_mode (such as an field_extraction) against the cryptographically verified records.
Final Verdict: The run receives a final PASS verdict only if the cryptographic proof is valid and every individual claim satisfies its verification rules.
For details on how database logging works, see architecture. To learn how HTTP requests are captured in real-time, see interceptor.