Goal
Any CAO agent (developer, supervisor, reviewer — doesn't matter) can take a user's natural-language request ("run a data analysis over these files"), author a Python workflow script for it, validate it, and — after explicit user approval — run it against cao-server.
Follow-on to #312 / PR #399 (script tier). This is the authoring-skill piece: today the only workflow skill teaches YAML, so agents produce the wrong artifact.
User flow
- User talks to any agent in a CAO session.
- User asks for something workflow-shaped (e.g. multi-file data analysis).
- Agent authors the
.py workflow script via the skill — or, if it lacks write permission, hands off authoring to a developer agent, passing the skill name.
- Agent validates the script (
cao workflow validate) and fixes findings.
- Agent presents the plan and asks the user whether to run it. Never auto-runs.
- On approval, agent invokes the run with an explicit, pre-announced run id and reports the status/cancel handles.
Design decisions
- Rewrite
workflow-author in place (single authoring path, Python-first; YAML demoted to describe/display). Skill is discovered via the existing skill catalog + load_skill, so all agent profiles inherit it with zero per-profile wiring.
- Validate gate is mandatory between author and ask-to-run. The
.py lint findings (fan-out without step_id, disallowed imports, nondeterminism) are load-bearing, not advisory.
- Explicit
--run-id, announced before the run starts — until a cao workflow runs list verb exists, an unnamed long run is uncancellable mid-flight.
- Blocking vs background: short runs use the synchronous
workflow_run MCP tool; long runs are backgrounded via bash (cao workflow run <name> --run-id <id> --json &) so the agent's terminal stays free.
- Hard rule: no path skips user approval before execution (the script tier executes generated Python).
Operational facts the skill must teach
- Script lives at
~/.aws/cli-agent-orchestrator/workflows/<name>.py; run by stem (no path separators; no same-stem .yaml sibling).
- Fan-out:
ThreadPoolExecutor, max_workers 3–5, explicit stable step_id per concurrent call, sorted() inputs (determinism obligation — resume relies on it).
- Big outputs: agents write files and return paths; per-step
output is null for schema-less steps, so emit_output / files are the source of truth.
- Failure recovery:
cao workflow resume <run-id> replays completed steps from the journal.
- Provider/agent guidance: use a headless provider (
claude_code); kiro_cli has an open TUI bug.
Acceptance criteria
- From a fresh session, an agent asked to "create a workflow for X" produces a validated
.py script (not YAML) via the skill.
- A read-only agent hands off authoring to
developer correctly.
- The agent asks before running; on approval the run starts with a pre-announced run id; the user is told how to check status and cancel.
- A fan-out script authored via the skill passes validate with explicit
step_ids and survives a resume after a killed run.
Dependencies / relations
Goal
Any CAO agent (developer, supervisor, reviewer — doesn't matter) can take a user's natural-language request ("run a data analysis over these files"), author a Python workflow script for it, validate it, and — after explicit user approval — run it against cao-server.
Follow-on to #312 / PR #399 (script tier). This is the authoring-skill piece: today the only workflow skill teaches YAML, so agents produce the wrong artifact.
User flow
.pyworkflow script via the skill — or, if it lacks write permission, hands off authoring to adeveloperagent, passing the skill name.cao workflow validate) and fixes findings.Design decisions
workflow-authorin place (single authoring path, Python-first; YAML demoted to describe/display). Skill is discovered via the existing skill catalog +load_skill, so all agent profiles inherit it with zero per-profile wiring..pylint findings (fan-out withoutstep_id, disallowed imports, nondeterminism) are load-bearing, not advisory.--run-id, announced before the run starts — until acao workflow runslist verb exists, an unnamed long run is uncancellable mid-flight.workflow_runMCP tool; long runs are backgrounded via bash (cao workflow run <name> --run-id <id> --json &) so the agent's terminal stays free.Operational facts the skill must teach
~/.aws/cli-agent-orchestrator/workflows/<name>.py; run by stem (no path separators; no same-stem.yamlsibling).ThreadPoolExecutor,max_workers3–5, explicit stablestep_idper concurrent call,sorted()inputs (determinism obligation — resume relies on it).outputis null for schema-less steps, soemit_output/ files are the source of truth.cao workflow resume <run-id>replays completed steps from the journal.claude_code); kiro_cli has an open TUI bug.Acceptance criteria
.pyscript (not YAML) via the skill.developercorrectly.step_ids and survives aresumeafter a killed run.Dependencies / relations
cao workflow runs, id-at-submit) — separate scope, but the skill's run-id rule is the interim mitigation.