Skip to content

fix: continue agent after resuming blocked goals#1627

Merged
chengluyu merged 7 commits into
mainfrom
fix/goal-resume-continuation
Jul 14, 2026
Merged

fix: continue agent after resuming blocked goals#1627
chengluyu merged 7 commits into
mainfrom
fix/goal-resume-continuation

Conversation

@chengluyu

@chengluyu chengluyu commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue.

Problem

When a goal became blocked, the Web goal controls could change it back to active, but no new agent turn was started. The goal then looked resumed while execution remained idle.

What changed

  • Keep blocked-to-active lifecycle changes as durable goal.update wire records.
  • Let the /api/v1 profile adapter explicitly request continuation for a blocked Web resume, while the goal domain continues to own the continuation prompt and loop admission checks.
  • Start exactly one continuation only when there is no live turn, pending continuation, or pending loop request. Active and paused resumes keep their existing behavior, and repeated resume calls are idempotent.
  • Re-run the existing budget gate before loop admission, so goals with exhausted turn, token, or wall-clock budgets remain blocked without sending an LLM request.
  • Track a continuation receipt through its assigned turn so the next goal turn can be scheduled after turn.ended without an old receipt clearing the new one.
  • Preserve the existing TUI and SDK resume flow; no Web UI or global startup queue was added.

The startup serialization commits from the original branch are already present on main through #1614 and are not part of this PR's effective diff.

Validation

  • pnpm --filter @moonshot-ai/agent-core-v2 exec vitest run test/agent/goal/goal.test.ts (55 passed)
  • pnpm --filter @moonshot-ai/kap-server exec vitest run test/sessions.test.ts test/rpc.test.ts (77 passed)
  • pnpm --filter @moonshot-ai/agent-core-v2 test (3263 passed)
  • pnpm --filter @moonshot-ai/kap-server test (618 passed)
  • pnpm run test --shard=4/5 (3044 passed, 19 skipped)
  • agent-core-v2 and kap-server typechecks; agent-core-v2 lint:domain
  • Kimi Web tests, typecheck, build, and check:style
  • pnpm changeset status --since=origin/main
  • git diff --check

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • 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. Existing EN/ZH goal docs already describe /goal resume for blocked goals.

@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5acab86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

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

wbxl2000 added 2 commits July 14, 2026 03:49
…sume

# Conflicts:
#	packages/agent-core-v2/test/agent/prompt/promptService.test.ts
#	packages/agent-core-v2/test/session/agentLifecycle/agentLifecycle.test.ts
@wbxl2000 wbxl2000 marked this pull request as ready for review July 13, 2026 20:37
@wbxl2000

Copy link
Copy Markdown
Collaborator

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

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

commit: 5acab86

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 877217c218

ℹ️ 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".

Comment thread packages/agent-core-v2/src/agent/goal/goalService.ts Outdated
@wbxl2000

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 791ab72ea1

ℹ️ 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".

…sume

# Conflicts:
#	packages/agent-core-v2/src/agent/goal/goalService.ts
#	packages/kap-server/test/sessions.test.ts
@wbxl2000

Copy link
Copy Markdown
Collaborator

@codex review

1 similar comment
@wbxl2000

Copy link
Copy Markdown
Collaborator

@codex review

@chengluyu chengluyu merged commit 28e9dd4 into main Jul 14, 2026
14 checks passed
@chengluyu chengluyu deleted the fix/goal-resume-continuation branch July 14, 2026 05:59
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 5acab868b2

ℹ️ 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".

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.

2 participants