This page traces the complete journey of an OpenAgentFlow workflow — from authoring a .oaf file to receiving live LLM output.
graph LR
A["Author .oaf"] --> B["Lex & Parse"]
B --> C["Validate"]
C --> D["Generate IR"]
D --> E["Adapt to Runtime"]
E --> F["Execute"]
style A fill:#f9f,stroke:#333
style C fill:#ffd,stroke:#333
style F fill:#bfb,stroke:#333
Each stage has a clear input, output, and error surface. Understanding this lifecycle helps you debug issues and know exactly where in the pipeline a problem occurs.
You write a .oaf file using the OAF language. A workflow defines:
start to endworkflow "My Workflow" {
state { ... }
agent AgentA { ... }
agent AgentB { ... }
flow {
start -> AgentA
AgentA -> AgentB
AgentB -> end
}
}
Error surface: Syntax errors (typos, missing braces, invalid characters).
The Lexer reads raw text and produces a token stream. The Parser consumes tokens and builds an AST.
workflow, agent, state, flow, config, start, endstring, int, float, bool, list, map{ } [ ] ( ) : , -> @Program → WorkflowDecl → StateBlock, AgentBlock[], FlowBlock, ConfigBlock| Error Type | Example |
|---|---|
LexerError |
Unexpected character, unterminated string |
ParseError |
Missing brace, unexpected token, duplicate property, empty instructions |
oaf parse examples/hello.oaf
The Validator inspects the AST for errors that syntax alone cannot catch. It runs three phases in order:
start, end, workflow, etc.)inputs/outputs reference declared state variables[0.0, 2.0]"gemini" or "openai"max_iterations is a positive integer)startendstart (BFS)end (reverse BFS)Diagnostics follow the format: [SEVERITY] file:line:col — message
Severity levels:
oaf validate examples/hello.oaf
The IR Generator transforms the validated AST into a runtime-independent JSON document.
| AST Concept | IR Representation |
|---|---|
start -> AgentA edge |
graph.entrypoint: "AgentA" |
AgentB -> end edge |
graph.terminals: ["AgentB"] |
| Agent-to-agent edges | graph.edges: [{source, target}] |
Type expressions (list[string]) |
Type descriptors ("list<string>") |
State options (@required) |
options: [{name: "required", args: []}] |
The IR is:
oaf compile examples/hello.oaf
# Outputs IR JSON to stdout
The LangGraph Adapter transforms IR into executable Python code.
A single, self-contained Python script containing:
langgraph, langchain_google_genai / langchain_openai, typingWorkflowState TypedDict — maps state variables to Python typesget_llm() helper — runtime LLM provider selection with auto-detectionget_llm()build_graph() function — constructs the LangGraph StateGraph__main__ block — initializes state, handles --input files, runs the workflow| OAF Type | Python Type |
|---|---|
string |
str |
int |
int |
float |
float |
bool |
bool |
list[T] |
List[T] |
map[K, V] |
Dict[K, V] |
# Generate Python code
oaf compile examples/hello.oaf --target langgraph -o hello.py
# Or compile and save
oaf compile examples/hello.oaf -t langgraph -o workflow.py
The CLI runner spawns a Python subprocess to execute the generated code.
GOOGLE_API_KEY or OPENAI_API_KEY)OAF_DEFAULT_MODEL is set)Code generation: Adapter produces Python source
--input data.json embeds initial state at compile time--input or OAF_INPUT_FILEoaf run examples/hello.oaf
oaf run examples/summarize.oaf --input data.json
| Error | Cause |
|---|---|
| Python not found | Python not installed or not in PATH |
| No API key | Neither GOOGLE_API_KEY nor OPENAI_API_KEY is set |
| No model specified | Agent has no model and OAF_DEFAULT_MODEL is unset |
ModuleNotFoundError |
Python dependencies not installed (pip install langgraph ...) |
| LLM API error | Invalid API key, rate limiting, network issues |
graph TD
A[".oaf Source File"] -->|"oaf parse"| B["Token Stream"]
B --> C["AST"]
C -->|"oaf validate"| D{"Valid?"}
D -->|"No"| E["Diagnostics<br/>(errors + warnings)"]
D -->|"Yes"| F["IR (JSON)"]
F -->|"oaf compile"| G["Python Code"]
F -->|"oaf graph"| H["DOT Diagram"]
G -->|"oaf run"| I["Live LLM Output"]
style A fill:#f9f
style E fill:#fbb
style I fill:#bfb
.oaf Language — Learn the full syntax