12 Workflow Compile#

Script: example/12_compile.py.

Workflow.compile() performs a static pass over the registered module tree. It does not run a model or create a session, so the bundled example works without a real API key.

python example/12_compile.py
compiled = workflow.compile()

print(compiled.manifest.provider_models())
print(compiled.manifest.provider_kinds())
print(compiled.manifest.agents)
print(compiled.manifest.dynamic_nodes)

problems = compiled.validate()
compiled.validate(raise_on_error=True)

with workflow.compile() as live:
    result = live(session)

Surface

Meaning

manifest.agents

Reachable AgentParam snapshots with path, provider, memory flag, and prompt-session id.

manifest.dynamic_nodes

Known dynamic boundaries such as Selector; compile does not predict their targets.

validate()

Offline provider-kind and credential checks only.

context manager

Acquires each distinct bound memory store and releases it in reverse order.

compiled(session)

Delegates to the current wrapped workflow.

Static snapshot, not an execution plan

The manifest reflects the module tree and providers at compile time. Recompile after rebinding providers or changing the structure. Validation does not test model names, network access, sandboxes, tools, memory health, or Selector targets.

LiteLLM is treated as credential-resolvable during preflight because it may use provider-specific environment variables internally. A custom registered kind uses the OpenAI-compatible credential resolver in v1.3.0.

← Runnable Examples