Skip to content

fix(agent-core-v2): serialize agent startup - #1614

Merged
chengluyu merged 3 commits into
mainfrom
fix/v2-goal-mode-startup-crash
Jul 13, 2026
Merged

fix(agent-core-v2): serialize agent startup#1614
chengluyu merged 3 commits into
mainfrom
fix/v2-goal-mode-startup-crash

Conversation

@chengluyu

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This is a focused fix for a reproducible v2 startup crash.

Problem

The agent lifecycle registered the main-agent handle before asynchronous bootstrap completed. Concurrent requests could therefore observe an agent whose activity lane was still initializing. A prompt submitted in that window could reject during loop launch and escape the fire-and-forget prompt scheduler, crashing the server. A failed bootstrap could also leave an unusable handle in the registry.

This happened reliably when the first prompt created a goal while the v2 agent was still starting.

What changed

  • Make same-id agent creation single-flight and return only settled handles from readiness lookups.
  • Make main-agent creation notification idempotent for concurrent callers.
  • Remove and dispose partially bootstrapped handles after startup failure so later requests can retry cleanly.
  • Settle synchronous prompt-launch failures as failed prompts instead of allowing an unhandled rejection.
  • Add regression coverage for concurrent main-agent creation, readiness ordering, failed-bootstrap recovery, and prompt-launch failure.
  • Add a patch changeset for @moonshot-ai/kimi-code.

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. No docs update is needed because this fixes a crash without changing commands, configuration, or documented usage.

@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 260623b

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

@chengluyu
chengluyu marked this pull request as ready for review July 13, 2026 13:39
@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@260623b
npx https://pkg.pr.new/@moonshot-ai/kimi-code@260623b

commit: 260623b

@chengluyu
chengluyu merged commit 3c0e368 into main Jul 13, 2026
14 checks passed
@chengluyu
chengluyu deleted the fix/v2-goal-mode-startup-crash branch July 13, 2026 13:44
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
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