Trace events (normative)

Normative naming contract for ArcFlow engine trace event kinds. This is a reference document, not a tutorial. Each event serializes as { "kind": "<PascalCaseName>",...fields }.

trace data policy (absolute): No LLM prompts/responses, tool input/output values, memory values, credentials, raw workflow input, or PII in stored or exported traces.

Tutorial-style reference: Trace event reference.

Total engine event kinds: 40 (K-02). workflow graph envelope kinds may appear in extended exports alongside engine events.

Envelope

Every event shares correlation fields where applicable:

FieldTypeDescription
trace_idstringSame as run_id
timestampdatetime UTC msEmission time
sequenceu64Monotonic per run
kindstringPascalCase variant name

D.1 Workflow lifecycle

KindTriggerFieldsTrace policy
WorkflowStartedRun beginsrun_id, workflow_name, step_countSafe
WorkflowCompletedAll steps successrun_id, duration_ms, total_tokensSafe
WorkflowFailedTerminal failurerun_id, duration_ms, failed_step_index?, error_codeSafe
WorkflowValidationFailedPre-run validation failrun_id, reasonSafe if reason has no user text
WorkflowRecoveryStartedResume beginsrun_id, original_run_id, resume_from_stepSafe
WorkflowRecoveryCompletedResume finishesrun_id, original_run_id, steps_re_executedSafe

D.2 Step lifecycle

KindTriggerFieldsTrace policy
StepStartedBefore agent for steprun_id, step_id, step_index, agent_name, agent_roleSafe if names not PII
StepCompletedStep successrun_id, step_id, step_index, duration_ms, tokens, output_size_bytesSafe
StepFailedStep failurerun_id, step_id, step_index, duration_ms, error_code, error_messageSafe if message bounded
StateCommittedOutput committedrun_id, step_id, committed_step_countSafe
StepFallbackActivatedFallback agent usedrun_id, step_id, primary_agent_name, fallback_agent_nameSafe

D.3 Agent and provider

KindTriggerFieldsTrace policy
AgentInvokedAgent processing startsrun_id, step_id, agent_name, input_size_bytesSafe
AgentResponseReceivedAgent output readyrun_id, step_id, agent_name, output_size_bytesSafe
TokensConsumedToken counts knownrun_id, step_id, agent_name, tokensSafe
ProviderRequestSentLLM request dispatchedrun_id, step_id, provider_id, model_id, max_tokens, prompt_size_bytesSafe
ProviderResponseReceivedLLM response receivedrun_id, step_id, provider_id, model_id, tokens, latency_msSafe
ProviderRateLimitedProvider 429run_id, step_id, provider_id, retry_after_seconds?Safe
ProviderErrorProvider failurerun_id, step_id, provider_id, error_code, error_messageSafe if bounded

D.4 Tools

KindTriggerFieldsTrace policy
ToolCallStartedTool dispatchrun_id, step_id, tool_name, input_schema_hashSafe
ToolCallCompletedTool successrun_id, step_id, tool_name, duration_ms, output_size_bytesSafe
ToolCallFailedTool failurerun_id, step_id, tool_name, duration_ms, failure_reason, error_codeSafe
ToolInputValidationFailedSchema validation failrun_id, step_id, tool_name, violation_descriptionSafe if no arg values

D.5 Memory

KindTriggerFieldsTrace policy
MemoryWriteWrite to memoryrun_id, step_id, agent_name, memory_type, key, duration_msSafe
MemoryReadRead from memoryrun_id, step_id, agent_name, memory_type, key, hit, duration_msSafe
MemoryRetrievedRAG retrievalrun_id, step_id, agent_name, chunk_count, total_bytesSafe
MemoryDegradedBackend degradedrun_id, memory_type, backend, reasonSafe
MemoryEvictedEvictionrun_id, memory_type, key, eviction_reasonSafe

D.6 Reliability

KindTriggerFieldsTrace policy
RetryAttemptedRetry scheduledrun_id, step_id, attempt_number, max_attempts, backoff_ms, trigger_error_codeSafe
RetryExhaustedRetries exhaustedrun_id, step_id, total_attempts, last_error_codeSafe
TimeoutEnforcedTimeout firedrun_id, step_id, timeout_type, configured_ms, elapsed_msSafe
TraceStorageWarningTrace buffer pressurerun_id, events_dropped, capacity_limitSafe

D.7 Streaming

KindTriggerFieldsTrace policy
StreamChunkReceivedStream chunk (size only in trace)run_id, step_id, chunk_bytesSafe
TokenEmittedToken delta accountingrun_id, step_id, completion_token_delta, prompt_token_deltaSafe

SDK streaming may expose text to the local process during run_stream(); persisted traces remain count-based.

D.8 External bindings

KindTriggerFieldsTrace policy
ExternalBindingStartedExternal wait beginsrun_id, binding_id, step_id, modeSafe
ExternalBindingCompletedExternal successrun_id, binding_id, step_id, duration_msSafe
ExternalBindingFailedExternal failurerun_id, binding_id, step_id, error_code, statusSafe
ExternalRecoveryTriggeredExternal recovery actionrun_id, binding_id, action, attempt_numberSafe

Example trace excerpt

json
[
 { "kind": "WorkflowStarted", "run_id": "r1", "workflow_name": "demo", "step_count": 2 },
 { "kind": "StepStarted", "run_id": "r1", "step_id": "s1", "step_index": 0, "agent_name": "a1", "agent_role": "Analyst" },
 { "kind": "ProviderRequestSent", "run_id": "r1", "step_id": "s1", "provider_id": "openai", "model_id": "gpt-4o-mini", "max_tokens": 1024, "prompt_size_bytes": 512 },
 { "kind": "ProviderResponseReceived", "run_id": "r1", "step_id": "s1", "provider_id": "openai", "model_id": "gpt-4o-mini", "tokens": { "input": 120, "output": 45, "total": 165 }, "latency_ms": 890 },
 { "kind": "StepCompleted", "run_id": "r1", "step_id": "s1", "step_index": 0, "duration_ms": 920, "tokens": { "input": 120, "output": 45, "total": 165 }, "output_size_bytes": 180 },
 { "kind": "WorkflowCompleted", "run_id": "r1", "duration_ms": 950, "total_tokens": { "input": 120, "output": 45, "total": 165 } }
]

Persistence

When Postgres persistence is enabled, events are stored in arcflow_trace_events (migration 000005). Payloads must remain trace data policy compliant at rest.

Adding new event kinds

Before merging new TraceEventKind variants:

  1. Update this page when engine events change.
  2. Update events.rs and this page.
  3. Pass trace data policy review: no forbidden field categories.
  4. Consider Relay browser exposure path.