Skip to content

Conversation

@edlsh
Copy link
Contributor

@edlsh edlsh commented Dec 23, 2025

Phase 4: Rework TaskTool to schedule background execution (fire-and-forget)

Changes

  • TaskTool now returns immediately after scheduling child session work via SessionRunner
  • Added toolPartID to Tool.Context for post-return metadata updates
  • Parent tool part metadata updated via Session.updatePart() instead of ctx.metadata()
  • Subscribes to SessionRunner lifecycle events for cleanup and status updates

Stack

…ation

PR1 of async subagent delegation stack (Issue sst#5887).

This commit introduces the SessionRunner namespace which provides a unified
interface for executing session loops:

- runOnce(): Synchronous execution wrapping SessionPrompt.prompt (implemented)
- runBackground(): Fire-and-forget execution for async delegation (scaffold only)
- Options/RunResult types for future background execution
- State tracking infrastructure for active background runs

No behavior change - this is purely an abstraction layer.

Next: PR2 will implement runBackground() with lifecycle events.
…le events

- Add Job, JobKind, JobStatus, EnqueueOptions schemas
- Add enqueue(), cancel(), get(), list() APIs
- Add lifecycle events (Queued, Started, Completed, Failed, Canceled, TimedOut)
- Add configurable timeout and concurrency via experimental.backgroundTasks
- Fix: queue now restarts after idle (removed stale started flag)
- Fix: dedupe now returns completion promise, not immediate job reference
- Fix circular import by using regular function for runOnce
- Add toolPartID to Tool.Context for post-return metadata updates
- Pass toolPartID from prompt.ts when invoking tool.execute
- TaskTool now returns immediately after enqueueing work to SessionRunner
- Subscribe to child session part updates for live progress in parent metadata
- Update parent metadata with final job status on completion/failure/cancel/timeout
- Handle enqueue failures with logging and proper cleanup
- Use ctx.callID for accurate tool call tracing
@edlsh edlsh force-pushed the feat/async-subagent-4-tasktool branch from c138f7e to 32b6eb9 Compare December 24, 2025 03:08
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