Skip to content

Add shell command detection and execution to agent loop #16

@bug-ops

Description

@bug-ops

Description

Extend the agent loop to detect fenced bash code blocks in LLM output, execute them, and feed results back to the LLM for a final response.

Parent: #3

Branch

feat/m2/shell-execution

Files

  • crates/zeph-core/src/context.rs — context builder (system + skills + history + message)
  • crates/zeph-core/src/agent.rs — shell detection, execution, re-query loop
  • crates/zeph-core/Cargo.toml — add zeph-skills dependency

Detection Logic

  1. LLM returns response text
  2. Scan for ```bash\n...\n``` blocks
  3. If found: execute via tokio::process::Command
  4. Capture stdout + stderr
  5. Send back to LLM: "Command output:\n{stdout}\n\nFormat a response for the user."
  6. Return final response to user

Acceptance Criteria

  • Context includes system prompt + skill instructions
  • Bash code blocks detected in LLM output
  • Commands executed with 30s timeout
  • Output fed back to LLM for final answer
  • Non-bash code blocks ignored (not executed)
  • Command failure (non-zero exit) included in output

Depends On

#13 (Skill registry), #14 (Prompt formatter), #15 (Bundled skills), #11 (CLI agent loop)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions