Skip to content

fix(gateway): regenerate MCP config after stale-session retry - #73

Merged
aptend merged 1 commit into
mainfrom
fix/mcp-config-stale-session
Jul 8, 2026
Merged

fix(gateway): regenerate MCP config after stale-session retry#73
aptend merged 1 commit into
mainfrom
fix/mcp-config-stale-session

Conversation

@aptend

@aptend aptend commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Problem

When a Claude conversation hit a stale session (No conversation found with session ID: ...), the gateway's retry path failed with MCP config file not found, leaving the user with no response and a silent 5-min idle timeout.

Root cause

pool.kill() calls cleanup_mcp_config(), which deletes the MCP config file. The stale-session retry path reused the now-deleted file path when respawning Claude, so the new process exited immediately with Error: Invalid MCP configuration: MCP config file not found.

Trace from the incident:

01:35:48.195  No conversation found with session ID: 23d626ea-...
01:35:48.197  pool: cleared stale session; retrying without resume
01:35:48.378  Error: Invalid MCP configuration:
              MCP config file not found: /tmp/gw-mcp-14257427753054890763.json
01:35:48.386  claude process exited (exit code 1)
01:40:48      conversation worker idle timeout

Fix

  • Regenerate the MCP config file after kill() deletes it and before the retry reuses the path.
  • Extract the generation call into write_mcp_config_file() to deduplicate the initial-spawn and retry paths.
  • Log regeneration failures (tracing::warn!) instead of silently dropping them.

Scope

Only the Claude pool path is affected — Codex receives MCP config inline via thread/start params (mcp_config.thread_config()), not via the file, and has no stale-session retry path.

🤖 Generated with Claude Code

pool.kill() calls cleanup_mcp_config, which deletes the MCP config file.
The stale-session retry path reused the now-stale file path, so Claude
failed to start with "MCP config file not found" and the conversation
silently timed out. Regenerate the file before retrying, extract the
call into write_mcp_config_file to deduplicate, and log regeneration
failures instead of dropping them silently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@aptend
aptend force-pushed the fix/mcp-config-stale-session branch from 1b2d528 to 835d57d Compare July 8, 2026 09:17
@aptend
aptend merged commit 48452e4 into main Jul 8, 2026
1 check 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.

1 participant