Skip to content

feat: claim_work MCP tool for session dedup#14

Merged
ludamad merged 31 commits intomainfrom
feat/context-links-oauth-refresh
Mar 18, 2026
Merged

feat: claim_work MCP tool for session dedup#14
ludamad merged 31 commits intomainfrom
feat/context-links-oauth-refresh

Conversation

@AztecBot
Copy link
Collaborator

Summary

  • Agents call claim_work() as their first action, describing what they're about to do
  • Tool atomically records the claim and returns all sessions from the last 24h
  • Agent semantically analyzes for overlap — exits with a link to the existing session if duplicate
  • If user explicitly insists, agent can proceed anyway

Changes

  • POST /api/internal/claim-work endpoint on host server
  • claim_work MCP tool in sidecar
  • HostClient.claimWork() method
  • Updated CLAUDE.md workflow to mandate claim_work before any work

Test plan

  • Verify claim_work returns recent sessions
  • Verify duplicate detection works when two sessions target same PR
  • Verify agent exits gracefully on duplicate

🤖 Generated with Claude Code

AztecBot and others added 30 commits March 10, 2026 18:55
channelInfoCache in http-routes.ts was never populated for non-DM
channels, so most sessions showed no channel name. Now resolves
channel info via Slack API (conversations.info) with caching, used
by both main dashboard and personal dashboard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract artifacts (PRs, issues, gists) and latest reply from
activity.jsonl in buildDashboardData. Render as compact clickable
chips and truncated reply preview on each workspace card.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All dashboard entries now use ThreadCard (collapsible). Collapsed
view shows status dot, artifacts inline in header, and reply preview
below. Running sessions auto-expand.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ck msg

- Default profile: fallbackRef=origin/next, description tells Claude to use next
- Claudebox-dev: fallbackRef=origin/main
- Soften fallback message from WARNING to informational note

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make it clear that session_status should be called after every major
step, with examples. Users watch progress live and see nothing
without these calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Double-RAF + 100ms mount scroll ensures content is painted before
scrolling. Fixes page not starting at bottom for long activity feeds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bot must call session_status before anything else so the user sees
immediate feedback. Even for trivial prompts like "wake up", post
status so the user knows the bot is alive.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…vements

- Add container recovery on server restart — re-attach streamers and exit
  monitors to Docker containers that survived the restart
- Fix massive activity.jsonl bloat from cumulative progress events — deduplicate
  tool_use entries by ID in session streamer, scope subagent discovery to current
  session only, add server-side dedup on SSE init
- Add `claudebox creds` CLI for managing multiple OAuth credential slots
  (list/use/save/rm) stored in ~/.claudebox/credentials/
- Add Agent Team UI component for rendering parallel agents on status page
- Fold tool results by default on status page (click to expand)
- Fix literal \n in GitHub comments — unescape in all body/content parameters
- Fix parallel tool call visibility — increase trunc limit, add timestamp to msgId
- Fix activity bleeding across runs — respect entry's own log_id in SSE handler
- Optimize SSE polling with byte-offset incremental reads
- Add set_workspace_name to all profile workflows (prevents ugly branch names)
- Remove update_meta_issue tool and all meta-issue references (use gists instead)
- Delete minimal profile
- Strengthen set_workspace_name tool description to MANDATORY

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… timer

- Recognize Slack URLs in link field and show as Slack origin with ↗ icon
- Promote link to slackLink when session has Slack URL but no slack_channel
- Add hourly OAuth token refresh via systemd timer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Show elapsed time since session start in every session_status update
- Include elapsed in GitHub completion comment (e.g. "✅ Run #1 — completed (12m)")
- Include elapsed in Slack status footer
- Compute from session.started or first activity timestamp

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- app_mention handler now skips bot_id and subtype messages
- Replace regex with indexOf for Slack URL check in dashboard template literal

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…at hooks

- Replace ci.sh shell-out in read-log with direct redis-cli + gunzip (fixes .fzf.bash pollution)
- Fix redis empty-key detection (strip trailing newline before length check)
- Fix HTTP fallback to use Basic auth header instead of URL credentials
- Add comprehensive make target listing to build tool description
- Add yarn_project_format and barretenberg_format MCP tools
- Add formatBeforePush hook to PR creation/update flow
- Mount reference repo node_modules for prettier in containers
- Add build-tools.ts, bootstrap.sh, install.sh, claudebox CLI
- Update barretenberg-audit profile and Dockerfile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add review profile with comprehensive aztec-packages review knowledge base
- Extract common aztec-packages sidecar setup into profiles/shared/
- Add GitHub webhook endpoint for claude-review label trigger
- Add manage_review_labels MCP tool and removeLabel to libcreds
- Move SESSIONS_DIR from .claude/ (credential-scoped) to ~/.claudebox/
  to survive credential changes — fixes dashboard showing no sessions
- Add elapsed time to status comments
- Direct redis read_log (no ci.sh dependency)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes CodeQL actions/missing-workflow-permissions alerts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Build tools (build, build_cpp, run_test, yarn_project_format,
barretenberg_format) were causing sessions to get stuck. Replaced with
documentation in CLAUDE.md pointing to make targets, bootstrap.sh
fallback, and cmake commands. Formatting still runs automatically
before create_pr/update_pr via the formatChangedFiles hook.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…session

When a new session starts on an existing worktree, any containers from
previous runs (claude + sidecar + network) are now stopped and removed
first. This prevents stale sidecars with old MCP tools from lingering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- POST /run now accepts slack_channel and slack_thread_ts; when provided,
  posts an initial Slack message and updates it on completion, making
  HTTP-initiated sessions behave like Slack-originated ones
- Remove auto-resume on queue drain — users must explicitly reply
- Remove auto-resume in reconcile — always mark orphaned sessions cancelled
- Auto-merge failure detection triggers sessions from bot messages
- Relax merge-base check to warning instead of blocking PR creation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…to-resume

- POST /run now resolves slack_channel/slack_thread_ts from the resumed
  session (via PR binding or worktree_id). When found, posts a reply in
  the original Slack thread and updates it on completion — no workflow
  changes needed, works out of the box with existing claudebox.yml
- Also accepts explicit slack_channel/slack_thread_ts in body as fallback
- Remove auto-resume on queue drain — users must explicitly reply
- Remove auto-resume in reconcile — always mark orphaned sessions cancelled
- Auto-merge failure detection triggers sessions from bot messages
- Relax merge-base check to warning instead of blocking PR creation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When /run has no Slack context from a prior session, reverse-lookup the
channel from the channelProfiles map using the session's profile. This
means GitHub-triggered sessions (issue_comment, workflow_dispatch) post
a status message in the profile's Slack channel automatically — no
workflow changes needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of reverse-looking up profile→channel, parse the Slack channel
and thread_ts directly from the link field when it's a Slack URL
(e.g. https://workspace.slack.com/archives/CHANNEL/pTS?thread_ts=...).
This works out of the box — callers just pass the Slack URL as the link.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… skill

- Force all gists to be private (remove public_gist param from create_gist tool,
  hardcode public:false in createGist API)
- Add GCP service account support: bind-mount SA key into containers,
  activate in container-entrypoint.sh before Claude starts
- Migrate container HOME from /home/claude to /home/aztec-dev to match
  the devbox image user (uid 30079). Updated all fallback paths in
  mcp/server.ts, mcp/env.ts, cli.ts, tests, and settings.
- Rebuild audit-devbox from local devbox:latest to align uid
- Add network-logs skill and agent to default profile for GCP log queries
- Update CLAUDE.md with GCP instructions and build guidance (no Docker)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Agents must call claim_work() as their first action. It atomically
records what they're about to do and returns all sessions from the
last 24h. The agent semantically analyzes for overlap — if another
session is already handling the same task, it responds with the
existing session's log URL and exits.

- POST /api/internal/claim-work endpoint on host server
- claim_work MCP tool in sidecar (calls host, returns recent sessions)
- HostClient.claimWork() method
- Updated CLAUDE.md workflow to mandate claim_work before any work

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bind-mount ~/.bb-crs into both sidecar and Claude containers at
$HOME/.bb-crs:ro, matching the CI bootstrap_ec2 pattern. Avoids
2GB re-download per session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
readBody returns a string, not parsed JSON. Destructuring without
JSON.parse gave undefined for all fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only compare against sessions with the same profile — audit sessions
shouldn't dedup against default sessions and vice versa.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- "stop", "cancel", "kill", "abort" in a running session thread now
  kills the container immediately instead of queuing the message
- claim_work prompt is much stricter: same PR = same work even across
  branches (v4-next vs backport-to-v4-next-staging), automation sessions
  are flagged as duplicate-suspect, no "proceed anyway" escape hatch
  unless prompt explicitly says "ignore duplicates" or "force"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- All draft PRs created by claudebox now get both 'claudebox' and
  'ci-draft' labels automatically
- Removed "ignore duplicates" / "force" escape hatch from claim_work —
  if there's overlap with a running session, agent MUST exit, no exceptions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When overlap is detected, agent now asks the user in Slack whether to
proceed or let the existing session finish. User can reply to restart.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only create issues for genuinely new findings. If a finding already
has a linked GitHub issue, it is not new — skip it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ludamad ludamad merged commit fc1b957 into main Mar 18, 2026
5 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