mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
Fix skills catalog budgets and warning delivery
This commit is contained in:
@@ -79,6 +79,7 @@ async fn contribute_prompt(
|
||||
fragments.extend(
|
||||
contributor
|
||||
.contribute(ContextContributionContext {
|
||||
thread_id: codex_protocol::ThreadId::new(),
|
||||
session_store,
|
||||
thread_store,
|
||||
turn_store: &turn_store,
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::protocol::Event;
|
||||
|
||||
/// Host-provided fire-and-forget sink for extension-generated events.
|
||||
///
|
||||
/// Extensions construct protocol events with the correlation id appropriate for
|
||||
/// the callback they are handling, then leave persistence, ordering, transport
|
||||
/// fanout, and logging decisions to the host.
|
||||
/// the callback they are handling and identify the owning thread explicitly,
|
||||
/// then leave persistence, ordering, transport fanout, and logging decisions to
|
||||
/// the host.
|
||||
pub trait ExtensionEventSink: Send + Sync {
|
||||
/// Queue one protocol event for host-owned delivery.
|
||||
fn emit(&self, event: Event);
|
||||
fn emit(&self, thread_id: ThreadId, event: Event);
|
||||
}
|
||||
|
||||
/// Event sink used when the host does not expose extension event emission.
|
||||
@@ -15,5 +17,5 @@ pub trait ExtensionEventSink: Send + Sync {
|
||||
pub struct NoopExtensionEventSink;
|
||||
|
||||
impl ExtensionEventSink for NoopExtensionEventSink {
|
||||
fn emit(&self, _event: Event) {}
|
||||
fn emit(&self, _thread_id: ThreadId, _event: Event) {}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_context_fragments::ContextualUserFragment;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::items::TurnItem;
|
||||
use codex_protocol::protocol::ReviewDecision;
|
||||
use codex_protocol::protocol::TokenUsageInfo;
|
||||
@@ -44,6 +45,7 @@ pub type ExtensionFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
|
||||
/// Host context available while extensions contribute initial model input.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ContextContributionContext<'a> {
|
||||
pub thread_id: ThreadId,
|
||||
pub session_store: &'a ExtensionData,
|
||||
pub thread_store: &'a ExtensionData,
|
||||
pub turn_store: &'a ExtensionData,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
|
||||
/// Host-owned turn environment summary visible to turn-input contributors.
|
||||
@@ -16,6 +17,8 @@ pub struct TurnInputEnvironment {
|
||||
/// Turn facts supplied before the host records turn-local model input items.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TurnInputContext {
|
||||
/// Thread that owns this turn.
|
||||
pub thread_id: ThreadId,
|
||||
/// Stable host-owned turn identifier.
|
||||
pub turn_id: String,
|
||||
/// User input submitted for this turn.
|
||||
|
||||
@@ -201,6 +201,7 @@ async fn contributors_preserve_registration_order() {
|
||||
fragments.extend(
|
||||
contributor
|
||||
.contribute(ContextContributionContext {
|
||||
thread_id: codex_protocol::ThreadId::new(),
|
||||
session_store: &session_store,
|
||||
thread_store: &thread_store,
|
||||
turn_store: &turn_store,
|
||||
@@ -323,7 +324,7 @@ struct RecordingEventSink {
|
||||
}
|
||||
|
||||
impl ExtensionEventSink for RecordingEventSink {
|
||||
fn emit(&self, event: Event) {
|
||||
fn emit(&self, _thread_id: codex_protocol::ThreadId, event: Event) {
|
||||
let EventMsg::Warning(warning) = event.msg else {
|
||||
panic!("test sink only accepts warning events");
|
||||
};
|
||||
@@ -339,13 +340,15 @@ fn custom_event_sink_survives_registry_build() {
|
||||
let sink = Arc::new(RecordingEventSink::default());
|
||||
let builder = ExtensionRegistryBuilder::<()>::with_event_sink(sink.clone());
|
||||
|
||||
builder
|
||||
.event_sink()
|
||||
.emit(warning_event("builder", "before"));
|
||||
builder.event_sink().emit(
|
||||
codex_protocol::ThreadId::new(),
|
||||
warning_event("builder", "before"),
|
||||
);
|
||||
let registry = builder.build();
|
||||
registry
|
||||
.event_sink()
|
||||
.emit(warning_event("registry", "after"));
|
||||
registry.event_sink().emit(
|
||||
codex_protocol::ThreadId::new(),
|
||||
warning_event("registry", "after"),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
sink.events
|
||||
|
||||
Reference in New Issue
Block a user