Skip to content

feat(examples): Slack auto-fix agent — monitors channel and auto-creates PRs#135

Draft
manan164 wants to merge 3 commits into
mainfrom
feature/slack-autofix-agent
Draft

feat(examples): Slack auto-fix agent — monitors channel and auto-creates PRs#135
manan164 wants to merge 3 commits into
mainfrom
feature/slack-autofix-agent

Conversation

@manan164

Copy link
Copy Markdown
Contributor

What this does

Adds 91_slack_autofix_agent.py — an autonomous engineering agent that monitors a Slack channel for bug reports and automatically investigates, fixes, and opens a GitHub PR.

Architecture

slack_autofix_pipeline (SEQUENTIAL)
├── issue_reader       — reads Slack channel, extracts bug description
├── code_investigator  — searches codebase, finds root cause
├── code_fixer         — applies minimal fix to the relevant files
└── pr_creator         — creates branch, commits, pushes, opens PR, replies in Slack

Tools

Tool What it does
fetch_slack_bug_reports Slack API — reads new messages from the bug channel
search_codebase grep -rn over the repo to find relevant code
read_file / write_file Read and write files in the repo
run_git_command Run arbitrary git commands
create_branch_and_commit Create branch + stage + commit
push_branch Push to remote origin
create_github_pr gh pr create — opens the PR
mark_message_processed State file — prevents re-processing the same bug
post_slack_reply Reply in the Slack thread with the PR link

Usage

# Required env vars
export SLACK_BOT_TOKEN=xoxb-...
export SLACK_CHANNEL_ID=C...
export GITHUB_TOKEN=ghp_...
export GITHUB_REPO=agentspan-ai/agentspan
export REPO_PATH=/path/to/agentspan
export AGENTSPAN_SERVER_URL=http://localhost:6767/api
export AGENTSPAN_LLM_MODEL=anthropic/claude-opus-4-6

# Run once
uv run python examples/91_slack_autofix_agent.py

# Dry-run (investigate only, no writes or PRs)
uv run python examples/91_slack_autofix_agent.py --dry-run

# Continuous loop (poll every 5 minutes)
uv run python examples/91_slack_autofix_agent.py --loop --interval 300

Why Agentspan for this

  • Durable — agent run survives restarts; if the fixer crashes mid-commit, Conductor retries
  • Observable — every tool call, LLM decision, file write logged in Conductor UI
  • Auditable — full trace of what the agent read, changed, and why — before the PR is merged
  • Sequential guaranteecode_fixer never runs before code_investigator completes

🤖 Generated with Claude Code

Monitors a Slack channel for bug reports and autonomously:
1. Reads and classifies Slack messages (issue_reader)
2. Investigates root cause in the codebase (code_investigator)
3. Applies the fix (code_fixer)
4. Creates a branch, commits, pushes, opens a PR, and replies in Slack (pr_creator)

Supports --dry-run (investigate only, no writes) and --loop (continuous polling).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@manan164 manan164 marked this pull request as draft April 16, 2026 15:44
@manan164 manan164 marked this pull request as draft April 16, 2026 15:44
bradyyie
bradyyie previously approved these changes May 12, 2026

@bradyyie bradyyie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — Well-documented Slack auto-fix agent example. Good demonstration of AgentSpan's sequential strategy for a real-world use case (Slack monitoring -> code investigation -> fix -> PR creation). Clear README, practical usage instructions, and proper env var handling.

@bradyyie bradyyie dismissed their stale review May 12, 2026 16:05

Dismissing approval — need to properly reproduce bugs before approving. Re-reviewing with hands-on QA.

manan164 added a commit that referenced this pull request Jun 15, 2026
…ention

Follows the pattern in sdk/python/examples/91_slack_autofix_agent.py
(per PR #135): poll the alert channel with conversations.history + reply
via chat.postMessage using a bot token only — no slack_bolt / Socket Mode,
no app-level token. Run-once or --loop, dedup via a local state file.

Slack I/O lives in a deterministic poller; the triage agent stays pure
(investigates a given execution id). Adds test_poller.py covering
alert-only triage, cross-poll dedup, and failure reporting (fakes, no
network/LLM; validated fail-then-pass per CLAUDE.md).

Config: drop SLACK_APP_TOKEN; add SLACK_ALERT_CHANNEL (required),
ONCALL_POLL_INTERVAL, ONCALL_STATE_FILE. requirements: drop slack-bolt,
add requests.

Co-Authored-By: Claude Opus 4.8 (1M context) <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.

2 participants