MoonshotAI / MoonshotAI/kimi-code
ACP: agent-initiated turns (background task completions, cron fires) never emit session/update while no prompt is in flight
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 acpover stdio (SergeCode, a T3-Code-style host)
Reproduction
- Over ACP, start a session and ask the agent to delegate work to background subagents (the
Agenttool withrun_in_background, or background Bash tasks). - 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/promptfrom the client. - 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/updateincludingagent_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
- While no
session/promptis in flight, emitsession/updatefor agent-initiated turns exactly as for prompt-driven turns (including auser_message_chunkfor the injected trigger notification). - Since ACP has no explicit turn-start notification, consider a
_metamarker 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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