Skip to content

Conversation

@randomm
Copy link
Owner

@randomm randomm commented Feb 11, 2026

Summary

  • Fixed session ID mismatch causing async task results to never reach parent agent
  • Added parent_session_id to typeMetadata for explicit parent/child separation
  • Results now stored and retrieved by parent session ID
  • Auto-wakeup events correctly target parent session
  • Updated fork-features manifest with new criticalCode marker

Changes

  • async-tasks.ts: Added parent_session_id field, updated 4 lookups to use it
  • task.ts: Set session_id to child, parent_session_id to parent, pass parent as tracking key

Fixes #178

@randomm randomm merged commit fbeb585 into dev Feb 11, 2026
1 check passed
@randomm randomm deleted the fix/issue-178-task-result-delivery branch February 11, 2026 12:39
Copy link
Owner Author

@randomm randomm left a comment

Choose a reason for hiding this comment

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

Code Review: PR #179

Summary

This PR correctly fixes the session ID routing bug in the async task system by introducing parent_session_id to separate child (for tracking) from parent (for result delivery) concerns.

✅ Approved (with minor observations)

What Works Well

  1. Root Cause Identified Correctly: The issue is clearly understood - results stored under child ID but retrieved by parent ID.
  2. Clean Design: Adding parent_session_id provides explicit separation of concerns.
  3. Minimal/Surgical Changes: Only 7 line edits across 2 files + manifest update - exactly whats needed.
  4. All Tests Pass: 1069 tests passing, CI green ✅
  5. Fork Features Manifest Updated: parent_session_id added to criticalCode markers.

Session ID Routing Validation

Result Delivery: Bus events target parent_session_id (lines 220, 255 in async-tasks.ts) - CORRECT
Result Retrieval: getAndClearCompletedTasks() filters by parent_session_id (line 329) - CORRECT
Undelivered Check: hasUndeliveredCompletedTasks() filters by parent_session_id (line 355) - CORRECT
Auto-Wakeup: Handler checks event.properties.parentSessionID (line 468) - CORRECT

Cancellation Logic Validation

cancelBackgroundTask() (lines 541-545): Cancels metadata?.session_id (child session) - CORRECT
cleanupSessionMaps() (lines 562, 574, 583): All use session_id (child) - CORRECT, this cleans childs resources

Backward Compatibility

No Breaking Changes: TaskMetadata is used in runtime Maps, not persisted. Old metadata objects in memory wont have parent_session_id, but:

  • Optional chaining (?.) handles missing parent_session_id
  • Existing pending tasks will complete and deliver to parent correctly
  • No schema migration needed

Test Coverage Observation

Minor Note: No explicit regression tests in this PR for the core bug fix (parent receiving child results). The existing test suite passes, but future changes should consider adding an integration test that:

  1. Spawns a parent agent
  2. Parent spawns a subagent via /task
  3. Subagent creates a background task
  4. Background task completes
  5. Parent receives the result via auto-wakeup

This is not blocking - existing test coverage (check_task.test.ts, 5 passing tests) is sufficient for this fix.

Final Assessment

Status: ✅ APPROVED
CI/CD: ✅ All checks passing
Merge Ready: YES

Key Points

  • Correctly fixes the reported bug (#178)
  • Session ID routing is now correct for all paths
  • Cancellation and cleanup use appropriate IDs
  • Type change is backward compatible (runtime-only data)
  • Fork manifest updated with criticalCode marker

The fix is minimal, correct, and well-documented. Ready to merge.

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.

fix: async task results not delivered to parent session (session ID routing bug)

1 participant