Skip to content

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

Open
howardpen9 wants to merge 1 commit intoMoonshotAI:mainfrom
howardpen9:fix/acp-terminal-handle-removal
Open

fix: replace removed acp.TerminalHandle with Client terminal methods#1400
howardpen9 wants to merge 1 commit intoMoonshotAI:mainfrom
howardpen9:fix/acp-terminal-handle-removal

Conversation

@howardpen9
Copy link
Contributor

@howardpen9 howardpen9 commented Mar 11, 2026

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 | Noneterminal_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 <noreply@anthropic.com>
Copy link
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 3 additional findings.

Open in Devin Review

@gp3t1
Copy link

gp3t1 commented Mar 14, 2026

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"
  }
}

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.

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

2 participants