Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.

fix: replace removed acp.TerminalHandle with Client terminal methods - #1400

Merged
RealKai42 merged 1 commit into
MoonshotAI:mainfrom
howardpen9:fix/acp-terminal-handle-removal
Mar 24, 2026
Merged

RealKai42 merged 1 commit into
MoonshotAI:mainfrom
howardpen9:fix/acp-terminal-handle-removal

Conversation

@howardpen9

@howardpen9 howardpen9 commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replace all acp.TerminalHandle usage with the new ACP 0.8 request/response API in tools.py and kaos.py
  • create_terminal() now returns CreateTerminalResponse with .terminal_id instead of a TerminalHandle object
  • Terminal operations now use Client methods (wait_for_terminal_exit, terminal_output, kill_terminal, release_terminal) with explicit session_id and terminal_id parameters

Root Cause

agent-client-protocol 0.8.0 removed TerminalHandle from the public API (migration guide). Since kimi-cli v1.17+ pins agent-client-protocol==0.8.0, any ACP terminal tool call fails with:

Error running tool: module acp has no attribute TerminalHandle

Changes

src/kimi_cli/acp/tools.py

  • terminal: acp.TerminalHandle | None → terminal_id: str | None
  • Extract terminal_id from CreateTerminalResponse.terminal_id instead of asserting TerminalHandle
  • Call self._acp_conn.wait_for_terminal_exit(session_id, terminal_id) instead of terminal.wait_for_exit()
  • Call self._acp_conn.terminal_output(session_id, terminal_id) instead of terminal.current_output()
  • Call self._acp_conn.kill_terminal(session_id, terminal_id) instead of terminal.kill()
  • Call self._acp_conn.release_terminal(session_id, terminal_id) instead of terminal.release()

src/kimi_cli/acp/kaos.py

  • ACPProcess.__init__ now takes client: acp.Client, session_id: str, terminal_id: str instead of terminal: acp.TerminalHandle
  • All internal terminal operations updated to use Client methods with explicit IDs

Test plan

  • ruff check passes on both changed files
  • Run kimi-cli as ACP agent in Zed IDE and execute a shell command (e.g., git log --oneline -6)
  • Verify terminal tool call succeeds without TerminalHandle AttributeError

Fixes #1380

`acp.TerminalHandle` was removed in agent-client-protocol 0.8.0.
This updates `tools.py` and `kaos.py` to use the new request/response
API: `Client.wait_for_terminal_exit()`, `Client.terminal_output()`,
`Client.kill_terminal()`, and `Client.release_terminal()` with
explicit `session_id` and `terminal_id` parameters.

Fixes MoonshotAI#1380

Co-Authored-By: Claude Opus 4.6 <[email protected]>

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

Copy link
Copy Markdown
Contributor

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 3 additional findings.

Open in Devin Review

@gp3t1

gp3t1 commented Mar 14, 2026

Copy link
Copy Markdown

This PR fix the issue:

{
  "sessionId": "e9c5b198-7218-47b6-94f3-60df065b198e",
  "command": "git log --oneline -6",
  "outputByteLimit": 50000
}
{ "terminalId": "47559b91-1d53-4c49-912a-8ba01d35e147" }
{
  "sessionId": "e9c5b198-7218-47b6-94f3-60df065b198e",
  "update": {
    "sessionUpdate": "tool_call_update",
    "toolCallId": "054d330c-4f56-4e1c-98b4-a1b752a91e0f/Shell:0",
    "status": "in_progress",
    "content": [
      {
        "type": "terminal",
        "terminalId": "47559b91-1d53-4c49-912a-8ba01d35e147"
      }
    ]
  }
}
{ "sessionId": "e9c5b198-7218-47b6-94f3-60df065b198e", "terminalId": "47559b91-1d53-4c49-912a-8ba01d35e147" }
{ "exitCode": 0, "signal": null }
{ "sessionId": "e9c5b198-7218-47b6-94f3-60df065b198e", "terminalId": "47559b91-1d53-4c49-912a-8ba01d35e147" }
{
  "output": "7bce3e8 (HEAD -> master) xxxxxxxxxxxxxxxx ... \n",
  "truncated": false,
  "exitStatus": { "exitCode": 0, "signal": null }
}
{ "sessionId": "e9c5b198-7218-47b6-94f3-60df065b198e", "terminalId": "47559b91-1d53-4c49-912a-8ba01d35e147" }
{
  "sessionId": "e9c5b198-7218-47b6-94f3-60df065b198e",
  "update": {
    "sessionUpdate": "tool_call_update",
    "toolCallId": "054d330c-4f56-4e1c-98b4-a1b752a91e0f/Shell:0",
    "status": "completed"
  }
}

@he-yufeng he-yufeng 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.

Looks good to me. The migration from TerminalHandle to direct Client methods is the right approach per the ACP 0.8.0 migration guide, and CI is all green. This has been blocking Zed IDE users for a couple weeks now -- would be great to get it merged.

@RealKai42
RealKai42 merged commit c1e3cef into MoonshotAI:main Mar 24, 2026
19 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP terminal tool fails with 'module acp has no attribute TerminalHandle' in v1.17 & v1.18

4 participants