MoonshotAI / MoonshotAI/kimi-code

ACP: agent-initiated turns (background task completions, cron fires) never emit session/update while no prompt is in flight

Open
#2,163 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

Summary

When kimi-code is driven as an ACP agent (kimi acp), turns that the agent starts on its own — e.g. resuming after a background subagent / background bash task completes, or a cron/scheduled reminder fires — never emit any session/update notifications. The client only receives traffic for these turns once the user sends a new prompt, and even then the missed content is lost (not buffered). From the client's perspective the agent goes silently idle, does invisible work, and the results never appear.

Environment

  • kimi-code 0.29.0 (~/.kimi-code/bin/kimi), macOS
  • ACP client: a desktop app hosting kimi acp over stdio (SergeCode, a T3-Code-style host)

Reproduction

  1. Over ACP, start a session and ask the agent to delegate work to background subagents (the Agent tool with run_in_background, or background Bash tasks).
  2. Wait for the background tasks to complete. The kimi runtime injects the completion notification into the session and the agent autonomously starts a new turn (reads the task output, posts a summary) — with no session/prompt from the client.
  3. Observe the ACP wire during that window.

Expected: the agent-initiated turn streams session/update notifications as it happens — user_message_chunk for the injected completion notification, then agent_thought_chunk / agent_message_chunk / tool_call* for the turn's work. ACP permits agent→client notifications outside the prompt lifecycle.

Actual: zero session/update notifications while no prompt is in flight. The only agent→client traffic is session/request_permission for tool calls made by those autonomous turns — which proves the turns execute but their content is suppressed. The turns' text/tool activity is also not flushed when the next session/prompt arrives; it is never emitted at all.

Evidence (production ACP session log)

A real session where 3 background subagents + 2 background validation commands completed while the client was idle (5 autonomous turns between 18:24–18:31):

window session/update from autonomous turns other agent→client traffic
18:24–18:28 (3 subagent-completion turns) 0 12 × session/request_permission (Read/Bash approvals matching those turns' tool usage)
18:30–18:31 (2 task-completion turns) 0
  • Client-initiated prompt turns in the same session stream normally (thousands of session/update including agent_message_chunk).
  • The 5 autonomous replies' text appears nowhere in the wire log — including during/after the next client prompt — so the content is dropped, not buffered.

Why this matters

Any ACP client (Zed, JetBrains, custom hosts) that runs the agent with background tasks, subagents, or cron reminders will permanently miss entire turns: the user sees the agent go quiet, and the work it did autonomously is invisible in the client UI.

Suggested fix

  1. While no session/prompt is in flight, emit session/update for agent-initiated turns exactly as for prompt-driven turns (including a user_message_chunk for the injected trigger notification).
  2. Since ACP has no explicit turn-start notification, consider a _meta marker on updates belonging to agent-initiated turns (e.g. _meta: { "agentInitiated": true }) so clients can bracket them into a synthesized turn for UI purposes — right now a client cannot tell where an unprompted turn begins/ends except by quiescence.

Related: #1485 (zero agent_message_chunk within a prompt), #1956 (session history on load) — this one is specifically about live agent-initiated turns never being streamed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the kimi acp handling for ACP session/update notifications and compare the session/prompt path with autonomous turns triggered by background task completion or cron reminders. Reproduce the behavior over stdio and inspect the wire log. Done means agent-initiated turns emit their user_message_chunk and subsequent thought, message, and tool updates without a client prompt, without dropping content.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.