feat: add interrupt support for active run lifecycle management#3588
feat: add interrupt support for active run lifecycle management#3588Oxygen56 wants to merge 1 commit into
Conversation
Adds RunInterruptSignal class that allows external code to request graceful interruption of the agent loop. The agent finishes the current turn and returns partial results. Changes: - Add RunInterruptSignal class with interrupt() method, is_interrupted property, and clear() for reuse - Add interrupt_signal field to RunConfig for configuring the signal - Add interrupted boolean flag to RunResult and RunResultStreaming - Check interrupt signal at top of main loop in AgentRunner.run() - Return partial result with interrupted=True when signaled - Check interrupt signal in streaming loop and set interrupted flag - Export RunInterruptSignal from the public API Closes openai#798 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 859746c518
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| agent. The model_provider passed in below must be able to resolve this model name. | ||
| """ | ||
|
|
||
| interrupt_signal: RunInterruptSignal | None = None |
There was a problem hiding this comment.
Append interrupt_signal to preserve RunConfig positional calls
Because RunConfig is an exported dataclass, inserting this field before model_provider changes the meaning of existing positional calls such as RunConfig("gpt-4.1", my_provider): the provider is now stored in interrupt_signal, leaving the default provider in use and causing the new loop check to access my_provider.is_interrupted. This violates the repo's public API positional-compatibility rule and silently breaks released callers; add the new optional field after the existing fields or provide a compatibility layer.
Useful? React with 👍 / 👎.
Adds interrupt signal to RunConfig for graceful run interruption.
Closes #798