Skip to content

fix(acp): assign message ids to streamed content#2359

Open
huntharo wants to merge 2 commits into
MoonshotAI:mainfrom
huntharo:fix/acp-message-ids
Open

fix(acp): assign message ids to streamed content#2359
huntharo wants to merge 2 commits into
MoonshotAI:mainfrom
huntharo:fix/acp-message-ids

Conversation

@huntharo
Copy link
Copy Markdown

@huntharo huntharo commented May 24, 2026

Motivation

I've been building Kimi support for PwrAgent, which works with Codex App Server and other agents via ACP. I signed up to a Kimi paid plan to add Kimi support via ACP, but unfortunately the support is missing just a couple of little features/fixes that make it work perfectly. I have been able to work around these to a degree, but Kimi would be easier for other ACP consumers to use if these were addressed.

  • This PR
    • Add messageId after upgrading to ACP 0.10.0
    • This makes it easier to update the correct streaming response
  • fix(acp): replay loaded session history #2363
    • Includes the commits from this PR so it gets the 0.10.0 bump and stable messageIds
    • Advertises a meta capability to indicate that the true thread history will be replayed by the session/load
    • Replays the thread history on session/load
  • feat(acp): support permission mode switching #2364
    • Currently, it is possible to put Kimi ACP into Yolo or Default mode by sending /yolo but it's a toggle as I understand it, so it turns it on of off
    • But at a protocol level, it's not possible to deterministically move into yolo or default mode while also knowing what mode you landed in
    • Adds support for session/set_mode to set the permission mode and current_mode_update to notify of the change

Summary

I fixed ACP streamed assistant content so each contiguous thought/message run gets a stable ACP messageId, while separate runs get distinct UUIDs. This lets clients distinguish token chunks for one transcript item from a new assistant message after a tool boundary.

This bumps agent-client-protocol from 0.8.0 to 0.10.0 because 0.10.0 adds the messageId field to AgentMessageChunk and AgentThoughtChunk. I also updated terminal auth method construction for the 0.10.0 schema.

Note that it's possible to fix this without messageId fields but it's much better for the agent to be declaring message boundaries than for the client to be inferring them.

Verification

I verified the ACP-focused test suite and touched-file checks:

  • uv run pytest tests/acp tests/ui_and_conv/test_acp_convert.py tests/ui_and_conv/test_acp_server_auth.py -q
  • uv run ruff check src/kimi_cli/acp/session.py src/kimi_cli/acp/server.py tests/acp/test_session_notifications.py tests/acp/test_server_initialize.py tests/ui_and_conv/test_acp_server_auth.py
  • uv run ruff format --check src/kimi_cli/acp/session.py src/kimi_cli/acp/server.py tests/acp/test_session_notifications.py tests/acp/test_server_initialize.py tests/ui_and_conv/test_acp_server_auth.py
  • uv run pyright src/kimi_cli/acp/session.py src/kimi_cli/acp/server.py

Screenshot

Testing with

After - messageId Allow Distinct In-Turn Reply Messages

Use a CLI like the following to point pwrdrvr/PwrAgent#556 at the locally checked out Kimi CLI with the fix:

PATH="/Users/huntharo/.codex/worktrees/mpjxx6jo/kimi-cli/.venv/bin:$PATH" \
PWRAGENT_PROFILE=dev \
pnpm dev:no-messaging
image

Before - Missing Item IDs Caused Intermediate Messages to be Overwritten

image
Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Copy link
Copy Markdown

@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: 7cbf01ff27

ℹ️ 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".

Comment thread src/kimi_cli/acp/server.py
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