Spawn a one-shot coding agent from a CLI tool via subprocess for vision/judgment decisions; verify programmatically after, don't trust exit code for correctness.
When a CLI pipeline hits a decision that requires vision, judgment, or multi-step reasoning (e.g. which direction to rotate a video, whether a generated image looks right), you can spawn a one-shot coding agent as a subprocess rather than building a bespoke ML pipeline or requiring user interaction.
Pattern (Python, works with omp/claude agents):
def run_harness_oneshot(prompt: str, *, cwd: Path, timeout: int = 600) -> int | None:
harness = find_harness() # shutil.which('omp') or shutil.which('claude')
if not harness:
return None
cmd = [harness, '-p', prompt, '--auto-approve']
r = subprocess.run(cmd, cwd=str(cwd), timeout=timeout)
return r.returncodeKey details:
-p (print mode): agent runs non-interactively, prints result, exits. No terminal UI.--auto-approve: auto-approves tool calls within the working directory. Safe when the agent only runs known idempotent/reversible commands.Read skill://<name> and follow it) containing the canonical procedure. The agent reads it and follows step-by-step. This decouples the decision logic from the CLI code.$OMPCODE/$CLAUDECODE env vars before spawning — if already inside an agent session, print instructions instead of nesting sessions.'ok'/'fixed'/'manual') so re-runs skip already-handled items. rc=0 + verified = 'fixed'; rc=0 + still wrong = 'manual' (needs human); rc≠0 = leave unmarked for retry.This pattern worked well for orientation fixing (vision decision: which way to rotate) but generalizes to any CLI step that needs judgment: image QA, content classification, data validation with context.