Skip to content

fix: scope interactive agent requests#648

Merged
kermanx merged 1 commit into
mainfrom
xtr/fix-interactive-agent-scope
Jun 11, 2026
Merged

fix: scope interactive agent requests#648
kermanx merged 1 commit into
mainfrom
xtr/fix-interactive-agent-scope

Conversation

@kermanx

@kermanx kermanx commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This fixes a race where interactive agent selection could leak between overlapping async requests.

Problem

Interactive requests used a mutable active agent id on the shared harness. When /btw, queued prompts, cancellation, or other session operations overlapped, one request could restore or overwrite the active agent id while another request was still resolving, sending the later RPC to the wrong agent.

What changed

  • Scoped interactive agent selection with async-local state in the SDK instead of mutating shared harness state.
  • Updated /btw and queued-message flows to run their session operations inside the requested agent scope.
  • Added regression coverage for awaited operations and overlapping scoped requests while RPC resolution is pending.
  • Updated TUI test harnesses to model the same scoped behavior as the SDK.
  • Added a patch changeset for the CLI and SDK packages.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Verification

  • pnpm vitest run packages/node-sdk/test/session-prompt-input.test.ts packages/node-sdk/test/session-prompt-events.test.ts
  • pnpm vitest run apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts apps/kimi-code/test/tui/message-replay.test.ts
  • pnpm --filter @moonshot-ai/kimi-code-sdk typecheck
  • pnpm --filter @moonshot-ai/kimi-code typecheck

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 12b3b80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kimi-code Patch
@moonshot-ai/kimi-code-sdk Patch

Not sure what this means? Click here to learn what changesets are.

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 11, 2026

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

commit: 12b3b80

@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: 12b3b8011c

ℹ️ 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 thread .changeset/steady-agent-scopes.md
@kermanx kermanx merged commit 54302ad into main Jun 11, 2026
9 checks passed
@kermanx kermanx deleted the xtr/fix-interactive-agent-scope branch June 11, 2026 07:37
@github-actions github-actions Bot mentioned this pull request Jun 11, 2026
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