agora.core.flow

Reusable flow/package definitions — YAML-declared agent team + task graph templates.

Position: the on-disk (YAML) form of a project. load_flow() parses and validates the YAML (with recursive include resolution) into an immutable Flow; instantiate_flow() then materialises runtime AgentConfig + Task objects the orchestrator executes. Templates are serializable and finding-annotated; the live objects are not.

Load-time lints (fail early, before any model runs):
  • _lint_role_write_scope() — F2: fatally rejects a task assigned to a role that cannot write its own output_path (delegates to agora.core.role_scope, the same oracle the runtime guard uses, so a clean lint guarantees a runnable write — the F1 collision cannot reach runtime).

  • _lint_spec_channel() — F6: warns loudly when a task description CITES an external spec/doc the runtime will not deliver into the prompt (the specification-channel starvation that made a tester fabricate an API).

Functions

instantiate_flow(flow, project_name[, ...])

Concrete AgentConfigs + Tasks from a flow template, with ${var} substitution.

load_flow(path)

Load, validate, and resolve includes for a flow YAML.

save_flow(flow, path)

Serialize a flow to YAML.

Classes

Flow

A whole project template: the agent team plus its task graph, with two optional embedded contracts (brief, api_spec) that a plan-builder authors ONCE and propagates so downstream executors — which start in a fresh work_dir — ground on the same source of truth rather than re-imagining it (the coordination failure the api_spec field kills).

PostconditionRef

Typed postcondition reference resolved at instantiate time via the plan registry.

StageTemplate

Serializable description of a Stage.

TaskTemplate

Serializable YAML row for one task; instantiate_flow() turns it into a runtime Task.

class agora.core.flow.PostconditionRef[source]

Bases: object

Typed postcondition reference resolved at instantiate time via the plan registry.

v2.0 plans use this in place of postcondition_descriptions so the declarative YAML can hold real postcondition semantics instead of free text.

name: str
args: tuple[tuple[str, Any], ...] = ()
args_dict()[source]
__init__(name, args=())
class agora.core.flow.StageTemplate[source]

Bases: object

Serializable description of a Stage.

instruction is free-form text (rendered as a YAML block scalar) for kind="llm" stages. validation callables are not supported in plan YAML — express them as task-level postconditions instead.

kind="decision" stages have no LLM call at all. The framework posts question + options as a Matrix question-card, awaits the user’s answer via any of three surfaces (poll click, emoji reaction, or /agora decision <answer> chat command), and writes the chosen answer id to output_path under the task’s work_dir. Decision stages take ownership of the decision metadata so the LLM cannot paraphrase it — fixes the 7B deviation observed in live plan-builder runs.

name: str
instruction: str = ''
context_files: tuple[str, ...] = ()
max_iterations: int = 5
kind: str = 'llm'
decision_id: str = ''
question: str = ''
options: tuple[str, ...] = ()
output_path: str = ''
validation_args: tuple[tuple[str, str], ...] = ()
validation_args_dict()[source]
hide_tools: tuple[str, ...] = ()
__init__(name, instruction='', context_files=(), max_iterations=5, kind='llm', decision_id='', question='', options=(), output_path='', validation_args=(), hide_tools=())
class agora.core.flow.TaskTemplate[source]

Bases: object

Serializable YAML row for one task; instantiate_flow() turns it into a runtime Task. Postconditions are carried as PostconditionRef (resolved against the plan registry at instantiate time), so validation can happen before any predicate object exists. The phase / blocking / order_after fields mirror Task’s phase-gate semantics (see that class for F5).

id: str
assigned_to: str
description: str
depends_on: tuple[str, ...] = ()
precondition_descriptions: tuple[str, ...] = ()
postcondition_descriptions: tuple[str, ...] = ()
postconditions: tuple[PostconditionRef, ...] = ()
output_path: str = ''
stages: tuple[StageTemplate, ...] = ()
phase: str = ''
blocking: bool = True
order_after: tuple[str, ...] = ()
__init__(id, assigned_to, description, depends_on=(), precondition_descriptions=(), postcondition_descriptions=(), postconditions=(), output_path='', stages=(), phase='', blocking=True, order_after=())
class agora.core.flow.Flow[source]

Bases: object

A whole project template: the agent team plus its task graph, with two optional embedded contracts (brief, api_spec) that a plan-builder authors ONCE and propagates so downstream executors — which start in a fresh work_dir — ground on the same source of truth rather than re-imagining it (the coordination failure the api_spec field kills). probe_version stamps experiment provenance for probe flows.

name: str
description: str
agents: tuple[AgentConfig, ...]
task_graph: tuple[TaskTemplate, ...]
brief: str = ''
api_spec: str = ''
probe_version: int | None = None
__init__(name, description, agents, task_graph, brief='', api_spec='', probe_version=None)
agora.core.flow.load_flow(path)[source]

Load, validate, and resolve includes for a flow YAML.

agora.core.flow.save_flow(flow, path)[source]

Serialize a flow to YAML.

Uses version 2.0 iff any task carries v2.0-only fields (typed postconditions, output_path, or stages); otherwise emits v1.0 for backward compatibility with existing fixtures.

agora.core.flow.instantiate_flow(flow, project_name, variables=None, *, id_strategy='uuid')[source]

Concrete AgentConfigs + Tasks from a flow template, with ${var} substitution.

Always-available variables: project_name. Callers may pass more via variables (e.g. {"repo_path": "./workspace/repo"}). Any ${unknown} token in a string field raises AgoraError.

id_strategy:
  • "uuid" (default, preserves v1.0 behavior): task ids become fresh UUIDs; depends_on is remapped.

  • "preserve" (used by agora.plan.loader): task ids are kept as the template’s string ids so a staged-task dict keyed by those ids still matches.

For tasks with typed postconditions (v2.0 plans), each reference is resolved via agora.plan.predicate_registry. Tasks with only postcondition_descriptions fall back to the _always_true stub.