Repository navigation
Conversation
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c9de4207d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const assertIdle = (): void => { | ||
| const snap = loop.snapshot(); | ||
| const compacting = agent.accessor.get(IAgentFullCompactionService).compacting !== null; | ||
| if (snap.state === 'running' || snap.paused || snap.hasPendingRequests || compacting) { |
There was a problem hiding this comment.
Allow crash-interrupted loops through the busy checks
When a session is cold-restored after a process crash, the core loop has state.status === 'interrupted'; hasPendingRequests() consequently returns true for that non-idle status. This condition therefore returns 40901 SESSION_BUSY before checking whether the orphaned turn is continuable, and AgentLoopService.continueTurn() repeats the same check even if this guard is bypassed. As a result, the advertised crash-recovery case can never reach loop.continue({ force: true }); distinguish an interrupted unfinished loop from genuinely active pending work in both gates.
Useful? React with 👍 / 👎.
| switch (record.type) { | ||
| case 'turn.prompt': | ||
| case 'turn.prompt': { | ||
| if (typeof record['trigger'] === 'string') state.recordsTurnEnds = true; |
There was a problem hiding this comment.
Reopen the orphaned turn when resuming it
Once a cold-restored crash continuation passes the busy checks, this new classification makes settleOrphanTurns() mark the orphan as ended/interrupted, but it does not add the turn to implicitlyEnded. When the core resumes the same turn number, the next step.begin therefore cannot reopen the known turn in turnForNumber() and instead creates a second conversation turn with the same turn_number; KAP clients retain the original as interrupted and receive the resumed output in a separate, user-message-less turn. Mark crash-settled turns as implicitly ended (or otherwise explicitly reopen them) so the WS/REST projection matches the core's same-turn resume.
Useful? React with 👍 / 👎.
| undo: { body: undoSessionRequestSchema, handle: undoSessionAction }, | ||
| cancel: { body: cancelSessionRequestSchema, handle: cancelSessionAction }, | ||
| wait: { body: waitSessionRequestSchema, handle: waitSessionAction }, | ||
| continue: { handle: continueSessionAction }, |
There was a problem hiding this comment.
Add a changeset for the public continue action
This adds an externally advertised core KAP capability and endpoint, but the commit contains no .changeset entry. The repository's changeset rules explicitly require public KAP conversation/session capabilities to produce a user-facing CLI changeset, so otherwise this new action will be absent from the generated release versioning and changelog; add a minor changeset for @moonshot-ai/kimi-code.
AGENTS.md reference: AGENTS.md:L109-L109
Useful? React with 👍 / 👎.
5c9de42 to
7acf8db
Compare
f8dc1f6 to
93ceab0
Compare
7acf8db to
4ac723d
Compare
93ceab0 to
e3eaf6d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ac723df68
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const retry = active?.retry; | ||
| return { | ||
| state: loop?.state.turn === undefined && active === undefined ? 'idle' : 'running', | ||
| state: loop?.state.status === 'running' || active !== undefined ? 'running' : 'idle', |
There was a problem hiding this comment.
Keep interrupted turns unavailable to cron scheduling
When a cron-enabled session is cold-restored with durable.unfinished, the loop has status === 'interrupted' and no active projection, so this change reports it as idle. tickCron() skips delivery only when snapshot().state === 'running'; a due persisted job can therefore call notify(), whose core scheduler invokes closeUnfinished() before starting the cron turn. This silently discards the resumable foreground turn before the user can call :continue, whereas the previous snapshot kept cron delivery blocked while that unfinished turn existed. Treat interrupted work as non-idle to existing schedulers, or update those schedulers to honor hasPendingRequests.
AGENTS.md reference: AGENTS.md:L115-L117
Useful? React with 👍 / 👎.
4ac723d to
24a1422
Compare
e3eaf6d to
7ea55aa
Compare
24a1422 to
69c7eab
Compare
7ea55aa to
eae5840
Compare
69c7eab to
edda32a
Compare
1c858f4 to
030a71d
Compare
Requirement or Bug
用户在取消(
:cancel)或因模型错误中断当前轮次、或进程异常退出留下未完结轮次后,需要一种无需伪造"继续"用户消息即可从中断点接着执行的会话动作。本 PR(Stacked on #4967)新增POST /api/v1/sessions/{session_id}:continue。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
flowchart TD Req["POST /api/v1/sessions/{id}:continue"] --> Resume["resumeSessionById + ensureMainAgent + loop.start()"] Resume --> Busy{"running / paused / compacting?"} Busy -- yes --> E40901["40901 SESSION_BUSY"] Busy -- no --> Check{"hasUnfinishedTurn || lastTurn in (cancelled, failed)?"} Check -- no --> E40940["40940 TURN_NOT_CONTINUABLE"] Check -- yes --> Remind{"hasUnfinishedTurn?"} Remind -- no --> Inject["loop.remind(<system-reminder>No new user message was sent. Continue...)</system-reminder>"] Remind -- yes --> Cont["loop.continueTurn() (loop.continue({ force: true }))"] Inject --> Cont Cont --> Resp["200 { continued: true } (非阻塞,事件走 WS)"]packages/agent-core-v2:LoopSnapshot:修正state判定为loop?.state.status === 'running' || active !== undefined ? 'running' : 'idle',避免冷恢复后携带崩溃未结轮次(loop.state.status === 'interrupted')时被误判为running;同时暴露hasUnfinishedTurn?: boolean。IAgentLoopService.continueTurn():非阻塞排空pendingReminders并调用loop.continue({ force: true })(崩溃未结轮次走turn.resumed续跑原轮次;已结束的cancelled/failed轮次开启trigger: 'continue'新轮次,不在对话流中生成user_message条目)。LoopErrors:新增TURN_NOT_CONTINUABLE(turn.not_continuable)。packages/kap-server:routes/sessions.ts:新增动作continue(映射40940 TURN_NOT_CONTINUABLE),对已结cancelled/failed轮次在续跑前注入origin: { kind: 'injection', variant: 'turn_continue' }的系统提醒,引导模型直接从中断处继续而不重复已完成步骤;在openapi/transforms.ts投影POST /api/v1/sessions/{session_id}:continue并更新apiSurface快照。docs/{zh,en}/reference/server-api*.md:增量补充POST /api/v1/sessions/{session_id}:continue与40940错误码说明。Behavior Changes and Affected Users
POST /api/v1/sessions/{session_id}:continue40001 unsupported action)main的未结、cancelled或failed轮次并返回{ continued: true };运行中返回40901,新会话或已completed轮次返回40940apiSurface.snapshot.test.ts.snap新增/api/v1/sessions/{session_id}:continue):continue时所有既有提交路径不变:continue续跑已结cancelled/failed轮次时的提醒注入:cancel仅注入"The user's next message continues the conversation.")POST /sessions/{id}:continue且非崩溃unfinished恢复时,追加一句提醒:"No new user message was sent. Continue the interrupted work from where it stopped; do not repeat steps that already completed."(origin.kind: "injection",UI 隐藏)POST /api/v1/sessions/{id}:continue的客户端会话接收该提醒;普通/prompts提交完全不触发POST /sessions/{id}/prompts发送显式用户消息LoopSnapshot.state在冷恢复存在崩溃unfinished轮次时的值loop.state.turn非空曾返回'running'(尽管loop.state.status === 'interrupted'且无活跃执行)'idle'并置hasUnfinishedTurn: trueloop.state.status === 'running'不变packages/agent-core-v2(agent/loop)、packages/kap-server(routes/sessions.ts、openapi/transforms.ts、错误码与快照)、docs/。conversationContract.e2e.test.ts新增S13覆盖新建空会话拒绝(40940)、运行中拒绝(40901)、:cancel后:continue无user_message正常续跑完成、正常完成后拒绝(40940)、上游报错failed后:continue续跑恢复;typecheck、oxlint与 VitePress 构建全绿。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.