Skip to content

Workflow authoring skill: any agent can author, validate, and run a Python workflow script #420

Description

@fanhongy

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

  1. User talks to any agent in a CAO session.
  2. User asks for something workflow-shaped (e.g. multi-file data analysis).
  3. 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.
  4. Agent validates the script (cao workflow validate) and fixes findings.
  5. Agent presents the plan and asks the user whether to run it. Never auto-runs.
  6. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions