Files
beads/examples/bash-agent/README.md
Steve Yegge 83ae110508 refactor: Remove legacy MCP Agent Mail integration (bd-6gd)
Remove the external MCP Agent Mail server integration that required
running a separate HTTP server and configuring environment variables.

The native `bd mail` system (stored as git-synced issues) remains
unchanged and is the recommended approach for inter-agent messaging.

Files removed:
- cmd/bd/message.go - Legacy `bd message` command
- integrations/beads-mcp/src/beads_mcp/mail.py, mail_tools.py
- lib/beads_mail_adapter.py - Python adapter library
- examples/go-agent/ - Agent Mail-focused example
- examples/python-agent/agent_with_mail.py, AGENT_MAIL_EXAMPLE.md
- docs/AGENT_MAIL*.md, docs/adr/002-agent-mail-integration.md
- tests/integration/test_agent_race.py, test_mail_failures.py, etc.
- tests/benchmarks/ - Agent Mail benchmarks

Updated documentation to remove Agent Mail references while keeping
native `bd mail` documentation intact.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:14:23 -08:00

3.2 KiB
Raw Blame History

Bash Agent Example

A bash script demonstrating how an AI agent can use bd to manage tasks autonomously.

Features

  • Pure bash implementation (no Python/Node required)
  • Colorized terminal output
  • Automatic work discovery
  • Random issue creation to simulate real agent behavior
  • Dependency linking with discovered-from
  • Statistics display

Prerequisites

  • bash 4.0+
  • bd installed: go install github.com/steveyegge/beads/cmd/bd@latest
  • jq for JSON parsing: brew install jq (macOS) or apt install jq (Linux)
  • A beads database initialized: bd init

Usage

# Make executable
chmod +x agent.sh

# Run with default 10 iterations
./agent.sh

# Run with custom iteration limit
./agent.sh 20

What It Does

The agent runs in a loop:

  1. Looks for ready work (no blockers)
  2. Claims the task (sets status to in_progress)
  3. "Works" on it (simulates 1 second of work)
  4. 50% chance to discover a follow-up issue
  5. If discovered, creates and links the new issue
  6. Completes the original task
  7. Shows statistics and repeats

Example Output

🚀 Beads Agent starting...
   Max iterations: 10

═══════════════════════════════════════════════════
  Beads Statistics
═══════════════════════════════════════════════════
Open: 5  In Progress: 0  Closed: 2

═══════════════════════════════════════════════════
  Iteration 1/10
═══════════════════════════════════════════════════
 Looking for ready work...
 Claiming task: bd-3
✓ Task claimed
 Working on: Fix authentication bug (bd-3)
  Priority: 1
⚠ Discovered issue while working!
✓ Created issue: bd-8
✓ Linked bd-8 ← discovered-from ← bd-3
 Completing task: bd-3
✓ Task completed: bd-3

Use Cases

Continuous Integration

# Run agent in CI to process testing tasks
./agent.sh 5

Cron Jobs

# Run agent every hour
0 * * * * cd /path/to/project && /path/to/agent.sh 3

One-off Task Processing

# Process exactly one task and exit
./agent.sh 1

Customization

Edit the script to customize behavior:

# Change discovery probability (line ~80)
if [[ $((RANDOM % 2)) -eq 0 ]]; then  # 50% chance
# Change to:
if [[ $((RANDOM % 10)) -lt 3 ]]; then  # 30% chance

# Add assignee filtering
bd ready --json --assignee "bot" --limit 1

# Add priority filtering
bd ready --json --priority 1 --limit 1

# Add custom labels
bd create "New task" -l "automated,agent-discovered"

Integration with Real Agents

This script is a starting point. To integrate with a real LLM:

  1. Replace do_work() with calls to your LLM API
  2. Parse the LLM's response for tasks to create
  3. Use issue IDs to maintain context
  4. Track conversation state in issue metadata

See Also