Skip to content

feat: replace baudbot attach with baudbot debug#168

Merged
benvinegar merged 2 commits into
mainfrom
feat/replace-attach-with-debug
Feb 24, 2026
Merged

feat: replace baudbot attach with baudbot debug#168
benvinegar merged 2 commits into
mainfrom
feat/replace-attach-with-debug

Conversation

@baudbot-agent
Copy link
Copy Markdown
Collaborator

Summary

The old baudbot attach command was fundamentally broken — it spawned a new pi instance connected to the control-agent's control socket instead of actually attaching to the running session. This created a duplicate agent, causing:

  • Two control-agents responding to Slack messages
  • Bridge routing conflicts (old vs new session UUIDs)
  • Confusion about which session was "real"

Changes

Replace baudbot attach with baudbot debug, which launches the debug-agent skill — a dedicated observability tool.

What baudbot debug does:

  • Launches a separate pi instance with the debug-agent skill + live dashboard extension
  • Dashboard shows: health metrics, bridge status, sessions, todos, worktrees, heartbeat state
  • Activity feed tails the control-agent's session log in real-time
  • Has --session-control so you can send_to_session to query running agents
  • Ctrl+C exits cleanly without affecting the control-agent

Usage:

sudo baudbot debug                           # auto-detect model
sudo baudbot debug --model anthropic/claude-sonnet-4-5  # explicit model

Model auto-detection:

Reads API keys from ~/.config/.env and picks a mid-tier model:

  • ANTHROPIC_API_KEYanthropic/claude-sonnet-4-5
  • OPENAI_API_KEYopenai/gpt-4.1
  • GEMINI_API_KEYgoogle/gemini-3-flash-preview
  • BAUDBOT_MODEL override takes priority

Removed:

  • cmd_attach, pause_before_attach, --pi/--tmux mode flags
  • All session-attach logic that spawned duplicate agents

Technical notes:

  • Unsets PKG_EXECPATH before launching to avoid varlock poisoning
  • Requires root (sudo) — consistent with other admin commands
  • Skill dir lookup: ~/.pi/agent/skills/debug-agent/opt/baudbot/current/pi/skills/debug-agent

Testing

  • bin/test.sh: 13/15 pass (2 pre-existing failures on main: heartbeat, memory)

The old `attach` command spawned a new pi instance connected to the
control-agent's control socket. This didn't actually attach to the
running session — it created a duplicate agent, causing confusion
(two control-agents responding, bridge routing conflicts, etc.).

Replace with `baudbot debug` which launches the debug-agent skill:
a dedicated observability tool with a live dashboard showing
control-agent activity, health metrics, and system state.

Key differences:
- No longer pretends to "attach" — clearly a separate debug tool
- Includes live dashboard (debug-dashboard.ts extension)
- Has --session-control so it can send_to_session to running agents
- Auto-detects model from API keys (uses mid-tier: sonnet/gpt-4.1)
- Supports --model override
- Unsets PKG_EXECPATH to avoid varlock poisoning in child processes
- Requires root (sudo baudbot debug) like other admin commands

Removed:
- cmd_attach and all attach-related helpers (pause_before_attach, etc.)
- --pi/--tmux mode flags (no longer applicable)
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 24, 2026

Greptile Summary

Replaces the broken baudbot attach command with a new baudbot debug command.

Key Changes:

  • Removed cmd_attach which incorrectly spawned a duplicate control-agent instance
  • Added cmd_debug which launches a separate debug-agent skill with live dashboard
  • Model auto-detection: reads API keys from ~/.config/.env and selects appropriate model
  • Unsets PKG_EXECPATH before launching to prevent varlock poisoning
  • Proper shell quoting used throughout the exec command

Technical Review:

  • The new implementation properly quotes the $MODEL and $SKILL_DIR variables in the exec command on lines 516-519
  • Skill directory fallback logic handles both runtime and deployed locations
  • The command requires root access (consistent with other admin commands)
  • Exit via Ctrl+C does not affect the running control-agent

Confidence Score: 4/5

  • Safe to merge - replaces broken functionality with proper implementation
  • The changes are well-structured and fix a fundamental issue (duplicate agent spawning). The code uses proper shell quoting and validates inputs. Score is 4 rather than 5 due to the complexity of the model auto-detection logic which reads from .env files - while properly implemented, this increases the surface area for edge cases
  • No files require special attention - the implementation follows secure coding practices with proper quoting and validation

Important Files Changed

Filename Overview
bin/baudbot Replaced attach command with debug in CLI dispatcher - minimal, safe changes to command registration
bin/lib/baudbot-runtime.sh Removed broken cmd_attach (114 lines) and replaced with cmd_debug (99 lines) - model auto-detection reads .env, launches debug-agent skill with proper quoting

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User runs: sudo baudbot debug] --> B{--model specified?}
    B -->|Yes| C[Use specified model]
    B -->|No| D[Read ~/.config/.env]
    D --> E{BAUDBOT_MODEL set?}
    E -->|Yes| C
    E -->|No| F{ANTHROPIC_API_KEY set?}
    F -->|Yes| G[Use claude-sonnet-4-5]
    F -->|No| H{OPENAI_API_KEY set?}
    H -->|Yes| I[Use gpt-4.1]
    H -->|No| J{GEMINI_API_KEY set?}
    J -->|Yes| K[Use gemini-3-flash-preview]
    J -->|No| L[Error: No API key found]
    C --> M{Skill dir exists?}
    G --> M
    I --> M
    K --> M
    M -->|Yes| N[Launch debug-agent pi session]
    M -->|No| O[Error: Run baudbot deploy]
    N --> P[Dashboard shows health metrics]
    P --> Q[User can send_to_session]
    Q --> R[Ctrl+C exits cleanly]
Loading

Last reviewed commit: b5854e6

Comment thread bin/lib/baudbot-runtime.sh
- Update baudbot.test.sh: rename attach tests to debug (matches cmd rename)
- Update test mock runtime stubs: cmd_attach → cmd_debug
- heartbeat.ts: remove unused 'resolve' import, isNaN → Number.isNaN,
  remove useless continue, remove unused catch binding
- heartbeat.test.mjs: remove unused imports (fs, path, os, beforeEach,
  afterEach) and unused helpers (setup, teardown, writeFile, and
  DEFAULT_INTERVAL_MS/MIN_INTERVAL_MS constants)
- bin/baudbot: suppress shellcheck SC2034 for YELLOW (used by config.sh)
- baudbot-runtime.sh: add MODEL input validation as defense-in-depth
@benvinegar benvinegar merged commit a4d7b06 into main Feb 24, 2026
9 checks passed
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