Skip to content

fix(agentic): preserve background subagent dialog turn ids - #1616

Merged
wsp1911 merged 1 commit into
GCWing:mainfrom
wsp1911:dev
Jul 18, 2026
Merged

fix(agentic): preserve background subagent dialog turn ids#1616
wsp1911 merged 1 commit into
GCWing:mainfrom
wsp1911:dev

Conversation

@wsp1911

@wsp1911 wsp1911 commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes a background subagent regression introduced by 5e48999f94daf119c1217ed6b71ba878d564f5dd (refactor(cli): route Peer Host through the assembled runtime).

  • Allocate the child dialog_turn_id before composing background-result metadata.
  • Reuse that ID in the scheduler and direct hidden-subagent paths.
  • Generate new child turn IDs as raw UUIDs rather than subagent-<uuid>.
  • Add coverage for raw UUID generation and preallocated-ID reuse.

Fixes #

Type and Areas

Type: Regression fix

Areas: Rust core, agent coordination, subagent scheduling

Motivation / Impact

5e48999 added exact parent/child turn lineage to background-result metadata for Peer Host routing and delivery control. It also read request.dialog_turn_id before the scheduler or direct execution path assigned it.

The prepared hidden-subagent request intentionally has no turn ID at that stage, so every background subagent failed with:

prepared hidden subagent request is missing dialog_turn_id

The fix establishes the child turn ID at the background-launch boundary and preserves it through scheduling and execution. This keeps metadata, the scheduler queue, and the actual child DialogTurn aligned.

No migration is required. Existing persisted turns remain unchanged.

Verification

  • pnpm run fmt:rs
  • git diff --check
  • cargo check -p bitfun-core -j 1
  • cargo test -p bitfun-core hidden_subagent_dialog_turn_id_reuses_existing_or_generates_raw_uuid -- --nocapture
  • cargo test -p bitfun-core --lib hidden_subagent_dialog_turn_id_reuses_existing_or_generates_raw_uuid -j 1 -- --nocapture
  • Manual: reproduced the original background-subagent failure, then confirmed the same scenario succeeds after the fix.

Reviewer Notes

The regression came from moving the requirement for a child turn ID ahead of its existing allocation point. The scheduler now reuses a preallocated ID, and the non-scheduler path already consumes a supplied ID, so both execution modes retain one stable identity for Peer Host lineage and background-result delivery.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, with local test limitations explained.
  • No user-facing strings, docs, or locale resources changed.

Allocate the child turn ID before building background delivery metadata.
Reuse it in the scheduler and direct execution paths without a subagent prefix.
Add coverage for raw UUID generation and existing-ID reuse.
@wsp1911
wsp1911 merged commit 92c3da9 into GCWing:main Jul 18, 2026
5 checks passed
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