Skip to content

fix: resume subagents lazily#380

Merged
kermanx merged 1 commit into
mainfrom
xtr/lazy-subagent-resume
Jun 3, 2026
Merged

fix: resume subagents lazily#380
kermanx merged 1 commit into
mainfrom
xtr/lazy-subagent-resume

Conversation

@kermanx
Copy link
Copy Markdown
Collaborator

@kermanx kermanx commented Jun 3, 2026

Related Issue

No linked issue; this addresses session resume work for persisted subagents.

Problem

Reopening a session eagerly replayed persisted subagents even when callers only needed the main agent. Several RPC and subagent paths also assumed referenced agents were already instantiated, which prevented persisted subagents from being restored only when they are accessed.

What changed

  • Resume only the main agent when reopening a session, and lazily restore persisted subagents through a shared ensureAgentResumed path.
  • Update session RPC, subagent host, subagent profile lookup, and resume result building to handle ready agents and in-flight resume entries correctly.
  • Update tests for lazy subagent access, permission parent restoration, async tool execution metadata, and ready-agent accessors.

Verification

  • pnpm --filter @moonshot-ai/agent-core typecheck
  • pnpm --filter @moonshot-ai/agent-core exec vitest run test/session/subagent-host.test.ts test/session/init.test.ts test/tools/agent.test.ts test/harness/runtime.test.ts test/harness/skill-session.test.ts
  • Read-only diff audit found no context-specific internal identifiers.

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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 3, 2026

🦋 Changeset detected

Latest commit: bd29df1

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

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 3, 2026

pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@bd29df1
npx https://pkg.pr.new/@moonshot-ai/kimi-code@bd29df1

commit: bd29df1

@kermanx kermanx force-pushed the xtr/lazy-subagent-resume branch from c806026 to bd29df1 Compare June 3, 2026 12:04
@kermanx kermanx merged commit 8639105 into main Jun 3, 2026
8 checks passed
@kermanx kermanx deleted the xtr/lazy-subagent-resume branch June 3, 2026 12:16
@github-actions github-actions Bot mentioned this pull request Jun 3, 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