Workflow Runtime
Source: examples/workflow/workflow_runtime.py
Introduction
Human-AI collaboration by design motivates transparent orchestration boundaries, AutoGen motivates composable multi-component execution, and HELM motivates repeatable runtime instrumentation for comparisons. This example is the minimal workflow-runtime build for observing step execution semantics directly.
Technical Implementation
Configure
Tracerwith JSONL + console output so each run emits machine-readable traces and lifecycle logs.Build the runtime surface (public APIs only) and execute
Workflow.run(...)with a fixedrequest_id.Capture structured outputs from runtime execution and preserve termination metadata for analysis.
Print a compact JSON payload including
trace_infofor deterministic tests and docs examples.
flowchart LR
A["Input prompt or scenario"] --> B["main(): runtime wiring"]
B --> C["Workflow.run(...)"]
C --> D["WorkflowRuntime schedules step graph (LogicStep)"]
C --> E["Tracer JSONL + console events"]
D --> F["ExecutionResult/payload"]
E --> F
F --> G["Printed JSON output"]
1from __future__ import annotations
2
3import json
4from pathlib import Path
5
6from design_research_agents import LogicStep, Tracer, Workflow
7
8
9def main() -> None:
10 """Run a minimal logic workflow and print literal payload."""
11 # Fixed request id keeps traces and docs output deterministic across runs.
12 request_id = "example-workflow-runtime-design-001"
13 tracer = Tracer(
14 enabled=True,
15 trace_dir=Path("artifacts/examples/traces"),
16 enable_jsonl=True,
17 enable_console=True,
18 )
19 # Build and run the minimal workflow using public runtime APIs.
20 workflow = Workflow(
21 tool_runtime=None,
22 input_schema={"type": "object"},
23 tracer=tracer,
24 steps=[
25 LogicStep(
26 step_id="design_runtime_ready",
27 handler=lambda _context: {
28 "message": "Design runtime orchestration validated.",
29 "check": "workflow-runtime-ready",
30 },
31 )
32 ],
33 )
34 result = workflow.run({}, execution_mode="sequential", request_id=request_id)
35 # Print the results
36 summary = result.summary()
37 print(json.dumps(summary, ensure_ascii=True, indent=2, sort_keys=True))
38
39
40if __name__ == "__main__":
41 main()
Expected Results
Run Command
PYTHONPATH=src python3 examples/workflow/workflow_runtime.py
Example output shape (values vary by run):
{
"success": true,
"final_output": "<example-specific payload>",
"terminated_reason": "<string-or-null>",
"error": null,
"trace": {
"request_id": "<request-id>",
"trace_dir": "artifacts/examples/traces",
"trace_path": "artifacts/examples/traces/run_<timestamp>_<request_id>.jsonl"
}
}