Skip to main content

Event Schemas

Plan runner events let adapters forward engine progress to logs, SSE streams, Quality Lab results, and learning records. Events are dataclasses in Python and can be serialized with dataclasses.asdict().

Common Fields

Every runner event can include these fields:

FieldMeaning
typeStable event type string
stageEngine stage, usually runner
plan_idPlan identifier
step_idStep identifier when the event belongs to a step
toolTool name when the event belongs to a tool call
graph_tool_call_versionLibrary version that emitted the event
trace_metadataAdapter-provided metadata copied onto every event

trace_metadata is the right place for safe identifiers such as collection id, case id, request id, or auth readiness status. Do not put raw tokens or cookies there.

Runner Event Types

TypeEmitted WhenImportant Fields
plan.startedA run beginsgoal, step_count
step.startedA step is about to call a toolargs_resolved, index, total
step.completedA step returns successfullyduration_ms, output_preview, output_size
step.failedA step call or binding failserror, duration_ms
plan.completedThe whole plan succeedsoutput, trace_steps, total_duration_ms
plan.abortedThe run stops after a failurefailed_step, error, trace_steps
step.retryingRetry mode is about to retry a stepattempt, max_attempts, delay_ms
step.skippedRecover mode skips an unused failed stepreason, error
plan.repairedRecover mode synthesized a replacement planold_plan_id, new_plan_id, excluded_tools
binding.repairedBinding recovery found an alternate value pathfield_name, recovered_path, value_preview
args.coercedArgument validation coerced valueschanges, unresolved

Streaming Example

from dataclasses import asdict

from graph_tool_call.plan import PlanRunner

runner = PlanRunner(call_tool, on_error="abort")

for event in runner.run_stream(
plan,
trace_metadata={
"collection_id": "orders",
"quality_case_id": "order-detail-001",
},
):
send_sse(asdict(event))

Example Event

{
"type": "step.completed",
"stage": "runner",
"plan_id": "plan-001",
"step_id": "s2",
"tool": "getOrderDetail",
"duration_ms": 184,
"output_preview": {"orderNo": "A-100"},
"output_size": 472,
"graph_tool_call_version": "0.32.1",
"trace_metadata": {
"collection_id": "orders",
"quality_case_id": "order-detail-001"
}
}

Error Shape

step.failed and plan.aborted carry an error object. Adapters should keep reason codes stable and product-visible.

{
"type": "step.failed",
"step_id": "s1",
"tool": "getOrderDetail",
"error": {
"kind": "tool",
"message": "HTTP 403",
"reason_code": "auth_failed"
}
}

Recommended adapter reason codes include:

ReasonMeaning
auth_context_requiredRuntime user/session context was missing
auth_profile_missingTool required auth but the collection had no auth profile
auth_header_resolution_failedAdapter could not resolve execution headers
auth_failedDownstream API returned 401 or 403
http_4xxDownstream API returned another client error
http_5xxDownstream API returned a server error
unsatisfied_fieldRequired request input could not be filled
cleanup_failedMutation cleanup failed

Event Handling Guidelines

  • Forward events as-is; avoid renaming fields in product adapters.
  • Add product-specific facts under trace_metadata.
  • Store only compact previews, not full sensitive payloads.
  • Use plan.completed and plan.aborted to create trace learning records.
  • Keep event consumers tolerant of additive fields.