A YAML-driven Python CLI for governed, iterative multi-agent execution workflows.
council-agentflow runs review-driven, adjudicated iterations over OpenCode agent work. In each cycle, one agent executes, reviewers inspect the result, an adjudicator decides whether another iteration is worthwhile, and policy gates decide when autonomy is safe versus when a human should be involved.
The goal is to improve agent execution quality through controlled iterations, while reducing avoidable human interruptions and keeping agent autonomy bounded, reviewable, and auditable.
Single-session agent loops often struggle to reliably discover their own mistakes. Adding subagents can help, but without hard workflow boundaries it is still unclear who reviews, who adjudicates, when a rerun is justified, and when the system should pause for human input. This project separates those responsibilities into named roles and file artifacts, making each iteration easier to inspect and control.
Use it when you want:
- repeatable multi-agent execution from YAML;
- review-driven iterations that improve output quality without turning into unbounded loops;
- independent reviewer roles instead of one self-reviewing agent;
- explicit adjudication before reruns;
- bounded autonomy for low-risk blockers;
- human escalation when external judgment or authority is required.
council-agentflow is backed by OpenCode. OpenCode provides the agent runtime: tools, skills, model interaction, filesystem access, shell execution, and session handling for a single agent.
council-agentflow sits one level above that:
- OpenCode handles intra-agent orchestration: how one agent uses tools to do its work.
council-agentflowhandles inter-agent workflow governance: who runs first, who reviews, who adjudicates, when to rerun, when to stop, and when to escalate.
Diagram source: docs/diagrams/workflow.mmd
High-level flow:
executionperforms the task and writes a plain-text output artifact.reviewer_1andreviewer_2independently review that output.review_decisionadjudicates reviewer feedback and writes:- a JSON decision:
rerun_execution,human_review, ordone; - a merged plain-text review for the next execution step.
- a JSON decision:
rerun_executionapplies adjudicated feedback in another iteration of the current cycle.human_reviewnormally goes throughautonomy_decisionfirst, unless human review was forced from the console.doneends automatic work for the current cycle, then pauses at a cycle-end human review gate before completing or advancing.- Agent sessions are reused within a cycle and reset between cycles.
For detailed state transitions, loop detection, human-review handling, and session behavior, see docs/workflow.md.
- Python
>=3.11. uvis recommended;uv.lockis committed.- OpenCode must be installed and available on
PATHasopencode, unlessprogram.opencode_binoverrides it. - An OpenCode attach server and model/provider credentials must be configured. Start the OpenCode server from the target workspace/repository where agents should read files, modify files, and run commands. The sample config uses
attach_url: http://localhost:4096.
From a checked-out repo:
uv sync
uv run agentflow --helpWithout uv, install the package in your preferred virtual environment and run the generated CLI directly:
python3 -m pip install -e .
agentflow --helpCreate your own workflow config and jobs file. You can copy the examples as a starting point:
cp example.config.workflow.yaml my.workflow.yaml
cp example.jobs.yaml my.jobs.yamlThen edit:
my.workflow.yaml: shared runtime settings, prompt pack, models, iteration limits, output paths, and agent slots.my.jobs.yaml: the actual work items you want to run.
For most first runs, you can leave the agents block in my.workflow.yaml unchanged and only adjust program settings plus the jobs file.
Run your files:
uv run agentflow --config my.workflow.yaml --jobs my.jobs.yamlOr, without uv after installation:
agentflow --config my.workflow.yaml --jobs my.jobs.yamlCommon arguments:
--config: shared workflow configuration; containsprogramandagents.--jobs: project-specific jobs file; containsjobs.--prompt-pack-path: optional prompt packs directory containing<prompt_pack>/pack.yaml; overridesprogram.prompt_pack_path.--verbose: print rendered prompts and raw OpenCode JSON events.--quiet: suppress progress logs and print only errors plus final JSON.
Common workflow config:
program:
opencode_bin: opencode
attach_url: http://localhost:4096
default_model: openai/gpt-5.5
prompt_pack: implementation
max_rounds: 1
max_iterations_per_cycle: 10
temp_dir: .agentflow-temp
write_back: false
agents:
execution: {}
reviewer_1: {}
reviewer_2: {}
review_decision:
merged_review_output_path_template: ${job_temp_dir}/${agent_output_name}-cycle-${cycle_number}-iteration-${iteration_number}.review.txt
autonomy_decision:
decision_report_output_path_template: ${job_temp_dir}/${agent_output_name}-cycle-${cycle_number}-iteration-${iteration_number}.report.md
loop_detector: {}Jobs file:
jobs:
- topic: api-service-design
task: |
Produce an API service execution plan with goals, scope, constraints,
main steps, risks, and validation method.
metadata:
complexity_hint: 35
status: pendingThe built-in prompt packs are:
implementation: code implementation, scripts, tests, and bug fixes;planning: solution design, execution planning, documentation drafts, and architecture/process work.
If program.prompt_pack_path and --prompt-pack-path are omitted, built-in packs are resolved from prompts/en/<prompt_pack>.
You can also provide a custom prompt packs directory with program.prompt_pack_path or --prompt-pack-path; the selected pack is resolved as <prompt_pack_path>/<program.prompt_pack>/pack.yaml, and custom packs still use the fixed agent slots.
For full configuration defaults, prompt-pack resolution, agent slots, variant priority, and job behavior, see docs/configuration.md.
Job status controls execution:
doneandneeds_human_revieware terminal and skipped.- Any other status is executable.
- If
write_back: true, the workflow writes back status changes:running,done,needs_human_review, orfailed.
You can add human_review: | to a job while the workflow is paused. The workflow only injects that feedback after you explicitly confirm it should be used for the current round.
Each job must include metadata.complexity_hint, an integer from 1 to 100 used in run statistics and copied into the job artifact metadata.
Use path-safe, unique topic values such as api-service-design; the topic becomes part of the temp output path.
Run this in a clean branch, sandbox, or disposable clone first. Depending on OpenCode permissions and configuration, agents may read files, modify workspace files, and run local commands.
Task text, rendered prompts, repository context, and generated outputs may be sent to the configured model provider. Do not run the workflow on repositories containing secrets, customer data, private credentials, or other sensitive material unless you have reviewed and accepted that boundary.
By default, outputs are written under:
<jobs-file-dir>/<temp_dir>/runs/<run_id>/<topic>/
Typical artifacts include:
- agent output files;
job-metadata.jsoncontaining the run id, topic, task, job metadata, and resolved agent model/variant settings;adjudication-memory.latest.txt;- merged review files from
review_decision; autonomy-decision-*.report.mdwhenautonomy_decisionruns;- final CLI JSON summary with completed, failed, and skipped jobs.
For artifact schemas, retry behavior, and troubleshooting, see docs/artifacts-and-troubleshooting.md.
- Higher token consumption: review-driven iterations use multiple agent calls per iteration, plus adjudication and optional autonomy/loop-detection steps. This is more expensive than a single-agent run.
- Fixed workflow: the workflow topology is currently fixed around the built-in agent slots and step order. Prompt packs can change role semantics and prompt behavior, but they do not define an arbitrary custom workflow graph.
- Workflow mechanics:
docs/workflow.md - Configuration reference:
docs/configuration.md - Autonomy decision policy:
docs/autonomy-decision.md - Artifacts and troubleshooting:
docs/artifacts-and-troubleshooting.md
