Skip to content

feat: add exec command and inline pipeline execution#7

Open
numman-ali wants to merge 2 commits intoshouc:masterfrom
numman-ali:feat/exec-and-inline-run
Open

feat: add exec command and inline pipeline execution#7
numman-ali wants to merge 2 commits intoshouc:masterfrom
numman-ali:feat/exec-and-inline-run

Conversation

@numman-ali
Copy link
Copy Markdown

Summary

  • agentflow exec — run a single agent with a prompt, get raw output back. No files needed.
  • agentflow run -e — pass inline JSON or Python expression directly
  • agentflow run - — read pipeline from stdin

Usage

# Single agent call — just prompt in, output out
agentflow exec shell "echo hello"
agentflow exec claude "Explain this codebase" --tools read_only
agentflow exec gemini "Search GitHub trends" --model gemini-3-pro-preview --output text

# Inline JSON pipeline
agentflow run -e '{"name":"q","nodes":[{"id":"q","agent":"shell","prompt":"echo works"}]}'

# Inline Python pipeline
agentflow run -e 'from agentflow import Graph, shell
with Graph("test") as g:
    shell(task_id="q", script="echo works")
print(g.to_json())'

# Pipeline from stdin
echo '{"name":"q","nodes":[...]}' | agentflow run -
python3 my_pipeline.py | agentflow run -

Design

  • exec builds a single-node PipelineSpec in memory, runs through the standard orchestrator
  • exec --output auto defaults to raw text on TTY, JSON when piped
  • run -e auto-detects JSON (starts with {) vs Python (executed as subprocess, matching existing .py loader)
  • run - reads stdin, same JSON/Python detection
  • Backwards compatible: agentflow run <path> works unchanged

Test plan

  • agentflow exec shell "echo hello"hello
  • agentflow exec shell "echo hello" --output texthello
  • agentflow run -e '{"name":"q","nodes":[...]}' → pipeline runs
  • agentflow run -e 'from agentflow import ...' → Python inline works
  • echo '...' | agentflow run - → stdin works
  • agentflow run pipeline.py → backwards compatible
  • Error cases: bad agent, empty prompt, both path and -e, no input
  • All 156 non-CLI tests pass; CLI test failures are pre-existing

🤖 Generated with Claude Code

Numman Ali and others added 2 commits April 3, 2026 18:41
Two new ways to run pipelines without creating files:

1. `agentflow exec <agent> <prompt>` — single agent call, raw output:
   agentflow exec shell "echo hello"
   agentflow exec gemini "Search the web" --model gemini-3-pro-preview
   agentflow exec claude "Explain this" --tools read_only --output text

2. `agentflow run -e <json|python>` — inline pipeline:
   agentflow run -e '{"name":"q","nodes":[...]}'
   agentflow run -e 'from agentflow import ...; print(g.to_json())'

3. `agentflow run -` — pipeline from stdin:
   echo '{"name":"q","nodes":[...]}' | agentflow run -

exec defaults to raw text output on TTY (just the agent response),
JSON when piped. Supports --model, --tools, --env, --provider,
--timeout, --extra-arg, and --output flags.

run -e auto-detects JSON (starts with {) vs Python code. Python
expressions are executed as subprocesses matching the existing
.py loader pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update SKILL.md: add exec quick start, inline run examples, gemini
  agent, reference pointer to exec.md
- Add skills/agentflow/references/exec.md: full reference for exec
  command (all flags, output formats, env vars, examples), inline
  pipeline via run -e, stdin via run -, and exec-vs-pipeline guidance
- Improve exec command docstring with usage examples in --help

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant