Skip to content

feat: implement actor_id resume in run/spawn + fix turnCount#1563

Open
faceair wants to merge 1 commit into
XiaomiMiMo:mainfrom
faceair:feat/actor-id-resume
Open

feat: implement actor_id resume in run/spawn + fix turnCount#1563
faceair wants to merge 1 commit into
XiaomiMiMo:mainfrom
faceair:feat/actor-id-resume

Conversation

@faceair

@faceair faceair commented Jul 4, 2026

Copy link
Copy Markdown

Closes #1562

Type of change

  • Bug fix
  • New feature

What does this PR do?

Makes the actor_id parameter on run/spawn actually work. Previously it was dead code — the schema said "resume" but execute never read it.

When actor_id is provided and findActor finds an idle actor, the resume branch calls promptOps.prompt({ agentID: actor_id }) instead of actor.spawn(). run blocks on the result; spawn fires a background fiber. Both are wrapped in runTurn so the registry updates status/lastOutcome and publishes ActorStatusChanged — without this, wait never resolves because it subscribes to that event.

Also fixes turnCount always being 0: registry.updateTurn was defined but never called. Added the call inside runTurn (shared entry point for all actor turns).

spawn resume provides EffectLogger.layer to the forked fiber to prevent Effect logs from going to stdout and corrupting the TUI.

How did I verify your code works?

  • bun run typecheck passes (12 packages)
  • bun test test/tool/actor.test.ts test/tool/actor-send.test.ts — 18 pass, 0 fail
  • End-to-end in TUI session:
    • actor run creates sidekick-N, actor run with actor_id=sidekick-N reuses it (same ID returned, conversation context preserved)
    • actor spawn with actor_id resumes in background, wait returns result + correct turnCount + lastOutcome: success
    • No stdout log pollution from spawn resume

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

- actor.ts: add resume branch in run/spawn execute path — when op.actor_id
  exists and findActor finds an idle actor, call promptOps.prompt with the
  existing actorID instead of spawning a new actor. run blocks on result;
  spawn uses Effect.runFork for fire-and-forget. Both wrapped in runTurn for
  registry status/turnCount/lastOutcome updates.

- actor.ts: add sessionId/actorId to send metadata for TUI card navigation

- turn.ts: call registry.updateTurn in runTurn so turnCount increments on
  every turn (was defined but never called — turnCount was always 0)

- actor.test.ts: update dead-code test to real resume test

- spawn resume: provide EffectLogger.layer to prevent stdout log pollution
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.

[FEATURE]: actor tool — make run/spawn actor_id parameter actually work (resume existing idle actor)

1 participant