Overview
Sometimes you need tools that can schedule actions to happen in the future without blocking the agent. The SDK supports this through deferred tool execution - the tool returns an observation immediately, but spawns a background task that can inject messages into the conversation later. This pattern is useful for:- Reminders - Schedule messages to be sent after a delay
- Human-in-the-loop - Allow external input to be injected into conversations
- Async operations - Start long-running tasks without blocking the agent
Example: Remind Tool
This example is available on GitHub: examples/01_standalone_sdk/33_remind_tool.py
examples/01_standalone_sdk/33_remind_tool.py
Running the Example
Key Implementation Details
1. The Executor Receives the Conversation
The key to deferred tools is that the executor receives theconversation parameter in its __call__ method:
2. Background Thread for Deferred Action
The executor spawns a background thread that sleeps for the specified delay, then usesconversation.send_message() to inject the reminder:
3. Immediate Return
The tool returns immediately with an observation confirming the reminder was scheduled, allowing the agent to continue working:Use Cases
Human-in-the-Loop
This pattern enables human-in-the-loop interactions where external input can be injected into a conversation at any time. For example, you could create a tool that:- Registers a callback with an external system
- Returns immediately to let the agent continue
- Injects messages when the external system responds
Long-Running Operations
For operations that take significant time (like API calls to slow services), you can:- Start the operation in a background thread
- Return a “processing” observation immediately
- Inject the results when they’re ready
Next Steps
- Custom Tools - Learn the fundamentals of creating custom tools
- Send Messages While Running - Inject messages into running conversations

