mirror of
https://github.com/openai/codex.git
synced 2026-11-24 15:21:20 +00:00
Route extension warnings to app-server threads (#35168)
## Why Extension warnings need a stable thread target even when they are emitted outside an active turn. ## What changed - Add `ExtensionWarning` and a dedicated `ExtensionEventSink::emit_warning` path with an explicit thread ID and optional turn ID. - Deliver extension warnings as thread-scoped app-server `warning` notifications, preserving listener ordering and waiting briefly for a subscriber when no listener is active. - Move skills warnings to the new path, limiting provider catalog warnings to four messages of 256 bytes each. ## Testing - Cover warning routing, ordering, UTF-8-safe truncation, subscriber fallback, and invalid thread IDs. - Verify skills warning bounds and app-server delivery of executor catalog budget warnings. GitOrigin-RevId: 4dcb1ba7f17c0edb1a9d548f9568e0c734bffc15
This commit is contained in:
1 parent
c8957bbf0f
commit
5dd992acd3
15 files changed
+592
-65
No files matched your search
@@ -1,5 +1,16 @@
|
||||
use codex_protocol::protocol::Event;
|
||||
|
||||
/// Extension warning with an explicit thread target and optional turn correlation.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ExtensionWarning {
|
||||
/// Stable host-owned thread identifier used for delivery.
|
||||
pub thread_id: String,
|
||||
/// Stable host-owned turn identifier when the warning arose in a turn callback.
|
||||
pub turn_id: Option<String>,
|
||||
/// Concise warning message for the user.
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
/// Host-provided fire-and-forget sink for extension-generated events.
|
||||
///
|
||||
/// Extensions construct protocol events with the correlation id appropriate for
|
||||
@@ -8,6 +19,12 @@ use codex_protocol::protocol::Event;
|
||||
pub trait ExtensionEventSink: Send + Sync {
|
||||
/// Queue one protocol event for host-owned delivery.
|
||||
fn emit(&self, event: Event);
|
||||
|
||||
/// Queue one warning for host-owned delivery.
|
||||
///
|
||||
/// Implementations must use [`ExtensionWarning::thread_id`] for routing. The optional
|
||||
/// [`ExtensionWarning::turn_id`] is correlation metadata and does not identify a thread.
|
||||
fn emit_warning(&self, warning: ExtensionWarning);
|
||||
}
|
||||
|
||||
/// Event sink used when the host does not expose extension event emission.
|
||||
@@ -16,4 +33,6 @@ pub struct NoopExtensionEventSink;
|
||||
|
||||
impl ExtensionEventSink for NoopExtensionEventSink {
|
||||
fn emit(&self, _event: Event) {}
|
||||
|
||||
fn emit_warning(&self, _warning: ExtensionWarning) {}
|
||||
}
|
||||
Reference in new issue
Block a user