Skip to content

refactor(agent-core-v2): fold the prompt queue into the agent loop service - #3747

Merged
sailist merged 11 commits into
MoonshotAI:mainfrom
sailist:refact-206-09-13-delete-prompt-service
Sep 14, 2026
Merged

sailist merged 11 commits into
MoonshotAI:mainfrom
sailist:refact-206-09-13-delete-prompt-service

Conversation

@sailist

@sailist sailist commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Internal refactor tracked in the agent-core-v2 task system (delete PromptService after the human agent machine queue landed in production via #3737).

Problem

The agent machine queue is already the state-independent first-class queue on the production path, so AgentPromptService's private pending/active queue is a duplicate existence for prompt submit/queue/steer/abort. Keeping both means two queue semantics to reason about and to keep in sync for every lifecycle change.

What changed

  • Deleted AgentPromptService/IAgentPromptService and their Agent-scope registration (agent/prompt/promptService.ts, agent/prompt/prompt.ts), plus dead assets: promptResolutionKey, PROMPT_ALREADY_COMPLETED (including the kap-server 40903 path), promptLaunchingKey, and clear().
  • Folded the queue into AgentLoopService: reservations are the queue items; IAgentLoopService gains submitPrompt/submitSteerPrompt/enqueuePrompt/steerPrompts/abortPrompt/drainPrompts/injectPrompt/retryPrompt/promptQueue, hooks.onBeforeSubmitPrompt, and the promptAdmission reservation slot. A serialized drainPromptQueue launches one prompt at a time (launch-window reservations stay out of the snapshot, matching the old list() contract).
  • Preserved the observable contract: prompt lifecycle events (submitted/queued/started/completed/aborted/steered) fire at the baseline points with baseline payloads — started right after bind materialization, completions on the turn-result chain — pinned by the existing inline wire/event snapshots. prompt.accepted/completed/aborted/steered keep their durable registrations (agent/prompt/promptEvents.ts) and promptAdmissionKey its fold, so existing wire.jsonl replays identically (verified by the resume/undo suites).
  • Compaction gating (queue while compacting, resume on finish) moves into the loop reservation drain; FullCompaction itself is untouched.
  • Wire compatibility: a thin AgentPromptChannel facade keeps the 'agentPromptService' decorator id and the submit/submitSteer RPC shapes, so klient memory/ipc/debug transports and the kap-server dispatcher are unchanged; all 12 internal consumers plus kap-server routes/transcript/projection, the CLI print runner, and kimi-inspect now target IAgentLoopService/IAgentPromptChannel.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 63d325e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@63d325e
npx https://pkg.pr.new/@moonshot-ai/kimi-code@63d325e

commit: 63d325e

@sailist
sailist force-pushed the refact-206-09-13-delete-prompt-service branch from 9c8350e to 2faf3ec Compare September 14, 2026 06:51
…rvice

Delete AgentPromptService/IAgentPromptService: prompt submit/queue/steer/
abort now ride the agent machine queue through IAgentLoopService's extended
surface (submitPrompt/submitSteerPrompt/enqueuePrompt/steerPrompts/
abortPrompt/drainPrompts/injectPrompt/retryPrompt/promptQueue plus
hooks.onBeforeSubmitPrompt and the promptAdmission reservation slot).

Durable prompt.* event classes move to agent/prompt/promptEvents.ts and keep
their registrations; promptAdmissionKey keeps its fold. Dead assets go away:
promptResolutionKey, PROMPT_ALREADY_COMPLETED (kap-server 40903 path),
promptLaunchingKey and clear(). Compaction gating (queue while compacting,
resume on finish) moves into the loop reservation drain.

The 'agentPromptService' wire name keeps its shape: a thin AgentPromptChannel
facade (same decorator id) forwards submit/submitSteer to the loop, so
klient memory/ipc/debug transports and the kap-server dispatcher are
unchanged.
Rewrite promptService.test.ts (25 cases, count unchanged) against the real
AgentLoopService with the scripted-LLM harness, fold the launch-window
reservation out of promptQueue().pending to match the old snapshot contract
exactly, and update the debug-channels pin to the facade's submit/submitSteer
surface.
Match the deleted service's microtask position: prompt.completed/aborted and
the completion deferreds fire from a result.then chain attached at bind time
instead of synchronously inside endTurn, so wire/emit ordering with
post-turn producers (tool unregister, next-prompt launch) stays identical to
the baseline snapshots. Steered children move onto the reservation so the
chain can settle them after the active turn is gone.
@sailist
sailist force-pushed the refact-206-09-13-delete-prompt-service branch from 2faf3ec to 63d325e Compare September 14, 2026 07:03
@sailist
sailist merged commit 4623395 into MoonshotAI:main Sep 14, 2026
15 checks passed
7723qqq added a commit to 7723qqq/kimi-code that referenced this pull request Sep 15, 2026
- MoonshotAI#3750 loop_control.compaction_max_attempts caps one compaction round's
  requests (default 5, upstream's, replacing the hardcoded 10)
- MoonshotAI#3785 reject an unsupported [secondary_model].default_effort at load
  time, and surface adaptive_thinking on the catalog model
- MoonshotAI#3681 warn on [models] entries missing the model field
- MoonshotAI#3752 tower resolves a caller by its last roster entry and retires
  duplicate agent ids; only ENOENT means an uninitialized workspace
- MoonshotAI#3778 evict completed subagent scopes behind an LRU cache
  (KIMI_CODE_SUBAGENT_SCOPE_CACHE_SIZE, default 32) and rebuild them from
  the persisted resume record on demand
- MoonshotAI#3747 aborting an unknown or already-settled prompt answers 40402
  instead of 40903, end to end through the protocol and kimi-web
- MoonshotAI#3720/MoonshotAI#3717 scope task notifications by session, so one session's print
  turn can no longer consume another's completion

The allowlist verdicts move to ported where the behavior landed, and
ROADMAP 6.1 records the evidence and what stayed open.
sailist added a commit that referenced this pull request Sep 19, 2026
…story API) (#3532) (#3920)

This reverts 64505e3.

The v1 WS + legacy REST + transcript surfaces are alive on main and remain
the single protocol surface; kimi-inspect returns to the transcript-based
data model (keeping #3747's removal of the prompt input, which adapted to
the agent-core-v2 prompt-queue fold).
Leeeon233 added a commit to LodyAI/acp-extension-kimi that referenced this pull request Sep 24, 2026
* feat(kimi-code): carry turn trace id and copilot stats in rating surveys (MoonshotAI#3907)

* feat: expose resolved base_url on models.dev catalog provider items (MoonshotAI#3909)

* fix(agent-core-v2): restore thinking for the openrouter reasoning dialect (MoonshotAI#3910)

Keep string reasoning fields when a reasoning_details array is present, stamp each think part by source, and replay those fields on the next request.

* ci: release packages (MoonshotAI#3862)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* docs(changelog): sync 2.0.1 from apps/kimi-code/CHANGELOG.md (MoonshotAI#3912)

* fix(agent-core-v2): pre-shrink compaction history to the effective model window (MoonshotAI#3911)

* fix(vscode): ignore Enter during IME composition in question dialog (MoonshotAI#3915)

* fix(kap-server): deliver session-level interaction events past agent filters (MoonshotAI#3901)

* revert(kap-server): drop the flat entity message protocol (v3 WS + history API) (MoonshotAI#3532) (MoonshotAI#3920)

This reverts 64505e3.

The v1 WS + legacy REST + transcript surfaces are alive on main and remain
the single protocol surface; kimi-inspect returns to the transcript-based
data model (keeping MoonshotAI#3747's removal of the prompt input, which adapted to
the agent-core-v2 prompt-queue fold).

* feat(oauth): parse goods_version from the managed /me profile payload (MoonshotAI#3921)

* fix: keep turn ids above the wire-wide max and fold cold transcripts over the active branch (MoonshotAI#3922)

* fix(agent-core-v2): floor the human turn clock at the wire-wide max on engine journal reset

* fix(kap-server): fold the cold transcript snapshot over the restorable branch chain

* fix(agent-core-v2): advance the human turn clock when a turn starts

* fix(kap-server): split reused wire turn ids in the live transcript projector

* fix(kap-server): adopt the completed cold tip for mid-turn attach events

Continuation deltas after a lazy transcript attach belong on the last
cold turn, not a newly split export id.

* fix(agent-core-v2): remove the project-root assertion for cwd from the system prompt (MoonshotAI#3929)

Co-authored-by: 7Sageer <7sageer@djwcb.cn>

* chore: remove the tdd skill (MoonshotAI#3932)

* fix(agent-core-v2): don't record turn.steer when an unconsumed steer seeds the next turn (MoonshotAI#3933)

* chore: sync web dist from code-app (MoonshotAI#3934)

* chore: sync web dist from code-app

code-app: 44d7281c7a63ee3c7a907f9406e490efdbec7411

* chore: collapse web dist sync changesets into one summary entry

* ci: release packages (MoonshotAI#3913)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat: generate native Kimi ACP session titles (#15)

---------

Co-authored-by: Grapedge <shiwang.lj@alibaba-inc.com>
Co-authored-by: liruifengv <liruifeng1024@gmail.com>
Co-authored-by: Haozhe <yanghaozhe@moonshot.ai>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 7Hanrui <qihanrui@moonshot.ai>
Co-authored-by: 7Sageer <7sageer@djwcb.cn>
Co-authored-by: Zixuan Chen <remch183@outlook.com>
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