A simple Python script demonstrating how an AI agent can use bd to manage tasks.
- Finds ready work using
bd ready --json - Claims tasks by updating status
- Simulates discovering new issues during work
- Links discovered issues with
discovered-fromdependency - Completes tasks and moves to the next one
- Python 3.7+
- bd installed:
go install github.com/steveyegge/beads/cmd/bd@latest - A beads database initialized:
bd init
# Make the script executable
chmod +x agent.py
# Run the agent
./agent.py- Queries for ready work (no blocking dependencies)
- Claims the highest priority task
- "Works" on the task (simulated)
- If the task involves implementation, discovers a testing task
- Creates the new testing task and links it with
discovered-from - Completes the original task
- Repeats until no ready work remains
🚀 Beads Agent starting...
============================================================
Iteration 1/10
============================================================
📋 Claiming task: bd-1
🤖 Working on: Implement user authentication (bd-1)
Priority: 1, Type: feature
💡 Discovered: Missing test coverage for this feature
✨ Creating issue: Add tests for Implement user authentication
🔗 Linking bd-2 ← discovered-from ← bd-1
✅ Completing task: bd-1 - Implemented successfully
🔄 New work discovered and linked. Running another cycle...
To integrate with a real LLM-based agent:
- Replace
simulate_work()with actual LLM calls - Parse the LLM's response for discovered issues/bugs
- Use the issue ID to track context across conversations
- Export/import JSONL to share state across agent sessions
# Create an agent with custom behavior
agent = BeadsAgent()
# Find specific types of work
ready = agent.run_bd("ready", "--priority", "1", "--assignee", "bot")
# Create issues with labels
agent.run_bd("create", "New task", "-l", "urgent,backend")
# Query dependency tree
tree = agent.run_bd("dep", "tree", "bd-1")- ../bash-agent/ - Bash version of this example
- ../claude-desktop-mcp/ - MCP server for Claude Desktop