Skip to content

fix(agent-core-v2): suppress automatic MCP retry status repeats - #4492

Merged
sailist merged 1 commit into
release/2026-10-28from
bug-315-10-28-mcp-retry-event-dedup-release-2026-10-28
Oct 28, 2026
Merged

sailist merged 1 commit into
release/2026-10-28from
bug-315-10-28-mcp-retry-event-dedup-release-2026-10-28

Conversation

@sailist

@sailist sailist commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Backport of #4491 to release/2026-10-28.

Transient MCP failures trigger automatic reconnects, but each retry emits another failure status, causing repeated MCP failure rows in the TUI.

Bug Reproduction Steps

  1. Configure a Streamable HTTP MCP server that is unavailable.
  2. Start the TUI and wait through several automatic reconnect attempts.
  3. Observe repeated MCP server "<name>" failed: ... rows. Restoring the server allows the connection to recover.

Root Cause

McpConnectionManager.transition emitted every public failed → pending → failed transition. The TUI's status deduplication key changes on pending, so each later failed passes deduplication and appends another row. Durable failure episodes were already deduplicated; the problem is limited to observable status events. This is a targeted fix at the event-production boundary, not a change to retry policy.

Code Changes

This backport applies the same two-file change as #4491:

  • Identify automatic retry attempts at the state-transition boundary using retryDue and a connecting entry with an existing failure streak.
  • Suppress emission only for the automatic retry's intermediate pending state and its return to retryWaiting.
  • Preserve initial failures, manual reconnects, recovery, needs-auth, terminal failures, status snapshots, retry scheduling, and durable records.
  • Update three existing regression tests without increasing the test count.

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
Automatic MCP retry statuses Every retry emitted pending and another failed, producing repeated TUI error rows Automatic retry intermediates are not emitted; initial failure and recovery are still emitted CLI/TUI users and SDK consumers with transient MCP failures No separate opt-out; live snapshots still expose current state and nextRetryAt
Manual reconnects, recovery, needs-auth, and terminal failures Status events emitted normally Unchanged CLI/TUI users, SDK consumers, and MCP authorization flows N/A
Status snapshots and durable failure records Live state and episode records retained Unchanged Session restore, status queries, and durable episode tracking N/A

Affected module: agent-core-v2 MCP connection management. Verification on the release branch: 46 focused tests passed and agent-core-v2 typecheck passed. The original change also passed full typecheck/lint, the m0-dev full suite of 17,903 tests, native SEA smoke, and a real MCP connected → error → connected session.

Checklist

  • I have read the CONTRIBUTING document.
  • Related issue: N/A — this is a backport of fix(agent-core-v2): suppress automatic MCP retry status repeats #4491.
  • Existing regression tests were updated to cover the fix.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill; no changeset was added at the author's request.
  • No documentation update is needed because configuration and public interfaces are unchanged.

@changeset-bot

changeset-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7afa852

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T10:19:30.866166Z 7afa852 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Oct 28, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@7afa852
npx https://pkg.pr.new/@moonshot-ai/kimi-code@7afa852

commit: 7afa852

@sailist
sailist merged commit ef34222 into release/2026-10-28 Oct 28, 2026
14 of 15 checks passed
@sailist
sailist deleted the bug-315-10-28-mcp-retry-event-dedup-release-2026-10-28 branch October 28, 2026 10:18

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

Copy link
Copy Markdown

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: 7afa852b9b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +574 to 576
const suppressRetryStatus = event.type === 'retryDue' || (automaticRetry && plan.target === 'retryWaiting');
if (!suppressRetryStatus && (plan.forceEmit === true || !publicEntriesEqual(before, after))) {
this.emit(entry);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve notifications for OAuth waiters after retry failures

When an OAuth credential event arrives during an automatic reconnect, WorkspaceMcpService.handleMcpOAuthEvent sees pending and waits at lines 214–234 for the next non-pending status before applying the credential change. If that attempt fails transiently, this condition suppresses the retryWaiting/failed notification, so the waiter remains subscribed and the saved or invalidated credentials are not acted on until a later attempt eventually succeeds or reaches a terminal error; during a prolonged outage, each credential event can also leave another listener behind indefinitely. Suppress the user-facing duplicate downstream, or otherwise notify this coordination path when the attempt settles.

AGENTS.md reference: AGENTS.md:L131-L133

Useful? React with 👍 / 👎.

Comment on lines +574 to 576
const suppressRetryStatus = event.type === 'retryDue' || (automaticRetry && plan.target === 'retryWaiting');
if (!suppressRetryStatus && (plan.forceEmit === true || !publicEntriesEqual(before, after))) {
this.emit(entry);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add a CLI changeset for suppressed retry updates

This changes user-visible CLI behavior: automatic retries previously produced alternating pending/failed status events that the TUI renders, while the updated tests now require those repeats to disappear. Because this internal-package fix perceptibly changes CLI output, add a patch changeset for @moonshot-ai/kimi-code so it is included in the release changelog.

AGENTS.md reference: AGENTS.md:L90-L91

Useful? React with 👍 / 👎.

Grapedge pushed a commit that referenced this pull request Oct 28, 2026
* fix(agent-core-v2): suppress automatic MCP retry status repeats (#4492)

* ci: release packages (#4463)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Haozhe <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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