Skip to main content
Send additional messages to a running agent mid-execution to provide corrections, updates, or additional context:
examples/01_standalone_sdk/18_send_message_while_processing.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Sending Messages During Execution

As shown in the example above, use threading to send messages while the agent is running:
The key steps are:
  1. Start conversation.run() in a background thread
  2. Send additional messages using conversation.send_message() while the agent is processing
  3. Use thread.join() to wait for completion
The agent receives and incorporates the new message mid-execution, allowing for real-time corrections and dynamic guidance.

Next Steps