[FEATURE] Allow restoring background task shell access from SDK so the Agent can KillShell for a session id still.
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When the Agent launches a sub process if we terminate and relaunch the application the Agent session restores but we no longer have access to background tasks, resulting in
<tool_use_error>No shell found with ID: bcf8f19</tool_use_error>
errors, since we're restoring a session I believe that the SDK should also be able to recover its background process context.
Proposed Solution
Agents restore Shell environments associated to a SessionID when a thread comes back to life.
Alternative Solutions
Expose an SDK first party background process poller (isTaskAlive, isTaskAvailableToContext) so Agent SDK can properly determine real state for the Session.
Priority
High - Significant impact on productivity
Feature Category
CLI commands and flags
Use Case Example
Ask the agent to launch a program. Close the agent on accident, or from a crash, or anything really. Relaunch Agent regains context of background processes properly. Ask agent to close the program. Program launched properly closes.
This avoids runaway background tasks as-well. Improves DX from having to maintain a process list and session map.
Additional Context
https://github.com/user-attachments/assets/0e9f8c88-c30f-4e30-9431-c9899e6c2921