Skip to content

refactor(worker): rename cleanupLocalMcpActivity to cleanupRunResourcesActivity#277

Merged
betterclever merged 3 commits intomainfrom
LuD1161/fix-cleanup-activity-name
Feb 11, 2026
Merged

refactor(worker): rename cleanupLocalMcpActivity to cleanupRunResourcesActivity#277
betterclever merged 3 commits intomainfrom
LuD1161/fix-cleanup-activity-name

Conversation

@LuD1161
Copy link
Contributor

@LuD1161 LuD1161 commented Feb 11, 2026

Summary

1. Refactoring (Original PR Scope)

  • Renamed cleanupLocalMcpActivitycleanupRunResourcesActivity
  • Renamed CleanupLocalMcpActivityInputCleanupRunResourcesActivityInput
  • Updated across 5 files (activities, types, workers, workflows)
  • The activity cleans up all run-scoped Docker resources (containers + volumes), not just local MCP servers
  • The old name was a misnomer from when only MCP containers existed

2. Orphan Prevention Fixes (Added)

Problem: Containers were orphaned when registration failed (network errors, Redis unavailable, crashes)

Solution:

  • ✅ Added dual-layer container cleanup:

    • Primary: Clean containers from tool registry (existing)
    • Fallback: Clean containers matching "mcp-server-*" pattern (new)
    • Deduplicates and cleans all found containers
  • ✅ Explicitly set autoRemove: false for MCP containers

    • Prevents race condition where container auto-removes before cleanup
    • Ensures containers persist for manual cleanup by workflow
    • Added STUDIO_RUN_ID env var for better identification
  • ✅ Preserved SKIP_CONTAINER_CLEANUP debug flag for E2E testing

Impact:

  • Orphaned containers now caught by name pattern fallback
  • Two-layer defense: registry tracking + pattern matching
  • No behavioral changes for normal workflows

Test plan

  • TypeScript compilation passes
  • Lint passes
  • Confirm Temporal worker starts without activity registration errors
  • Run a workflow with MCP tool nodes and verify cleanup still runs in the finally block
  • Verify orphaned container cleanup works (simulate registration failure)

…esActivity

The activity cleans up all run-scoped Docker resources (containers and
volumes), not just local MCP servers. Rename to accurately reflect its
broader scope.

Signed-off-by: Aseem Shrey <LuD1161@users.noreply.github.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ed690406a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

registerLocalMcpActivity,
registerRemoteMcpActivity,
cleanupLocalMcpActivity,
cleanupRunResourcesActivity,

Choose a reason for hiding this comment

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

P1 Badge Register the old cleanup activity name for compatibility

Renaming cleanupLocalMcpActivity to cleanupRunResourcesActivity changes the Temporal activity type and removes the old handler from worker registration. For workflows that were already running before this deploy, any pending/retried cleanupLocalMcpActivity task will now be polled by a worker that no longer serves that type, leading to repeated activity failures/timeouts for those executions. Keep a temporary alias for the legacy activity name (or gate with workflow versioning) until pre-rename runs are drained.

Useful? React with 👍 / 👎.

betterclever added a commit that referenced this pull request Feb 11, 2026
…esActivity

- Renamed cleanupLocalMcpActivity → cleanupRunResourcesActivity
- Renamed CleanupLocalMcpActivityInput → CleanupRunResourcesActivityInput
- The activity cleans up all run-scoped Docker resources (containers + volumes), not just local MCP servers
- The old name was a misnomer from when only MCP containers existed
- No behavioral changes, purely a naming fix

Applied from PR #277

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
betterclever and others added 2 commits February 11, 2026 23:02
**Problem:**
Containers were only cleaned up if registered in Redis tool registry,
causing orphans when registration failed (network errors, crashes, etc.)

**Solution:**
1. Added fallback container cleanup using name pattern matching
   - Primary: Clean containers from tool registry (existing)
   - Fallback: Clean containers matching "mcp-server-*" pattern (new)
   - Deduplicates and cleans all found containers

2. Explicitly set autoRemove=false for MCP containers
   - Prevents race condition where container auto-removes before cleanup
   - Ensures containers persist for manual cleanup by workflow
   - Added STUDIO_RUN_ID env var for better identification

**Impact:**
- Orphaned containers are now caught by name pattern fallback
- Two-layer defense: registry tracking + name pattern matching
- Debug flag (SKIP_CONTAINER_CLEANUP) preserved for E2E testing
- Volume cleanup unchanged (already uses labels correctly)

**Testing:**
- TypeScript compilation passes
- Maintains backward compatibility with existing cleanup flow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
@betterclever betterclever merged commit c8bf708 into main Feb 11, 2026
3 checks passed
@LuD1161 LuD1161 deleted the LuD1161/fix-cleanup-activity-name branch February 11, 2026 20:35
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