mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Add turn-scoped context contributions (#28911)
## Summary - keep context injection on a single ContextContributor trait - split context injection into thread-scoped and turn-scoped contribution methods - wire turn-scoped fragments into initial context assembly so extensions can contribute context from turn-local state
This commit is contained in:
14 files changed
+307
-33
No files matched your search
@@ -11,6 +11,7 @@ use codex_tools::ToolExecutor;
|
||||
|
||||
use crate::ExtensionData;
|
||||
|
||||
mod context;
|
||||
mod mcp;
|
||||
mod prompt;
|
||||
mod thread_lifecycle;
|
||||
@@ -18,6 +19,7 @@ mod tool_lifecycle;
|
||||
mod turn_input;
|
||||
mod turn_lifecycle;
|
||||
|
||||
pub use context::TurnContextContributionInput;
|
||||
pub use mcp::McpServerContribution;
|
||||
pub use mcp::McpServerContributionContext;
|
||||
pub use prompt::PromptFragment;
|
||||
@@ -62,12 +64,34 @@ pub trait McpServerContributor<C: Sync>: Send + Sync {
|
||||
}
|
||||
|
||||
/// Extension contribution that adds prompt fragments during prompt assembly.
|
||||
///
|
||||
/// Implementations should use the method matching the scope needed by the
|
||||
/// fragment: thread/session context for stable inputs, and turn context for
|
||||
/// fragments that depend on turn-local host state.
|
||||
pub trait ContextContributor: Send + Sync {
|
||||
fn contribute<'a>(
|
||||
fn contribute_thread_context<'a>(
|
||||
&'a self,
|
||||
session_store: &'a ExtensionData,
|
||||
thread_store: &'a ExtensionData,
|
||||
) -> ExtensionFuture<'a, Vec<PromptFragment>>;
|
||||
) -> ExtensionFuture<'a, Vec<PromptFragment>> {
|
||||
Box::pin(async move {
|
||||
let _self = self;
|
||||
let _session_store = session_store;
|
||||
let _thread_store = thread_store;
|
||||
Vec::new()
|
||||
})
|
||||
}
|
||||
|
||||
fn contribute_turn_context<'a>(
|
||||
&'a self,
|
||||
input: TurnContextContributionInput<'a>,
|
||||
) -> ExtensionFuture<'a, Vec<PromptFragment>> {
|
||||
Box::pin(async move {
|
||||
let _self = self;
|
||||
let _input = input;
|
||||
Vec::new()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Contributor for host-owned thread lifecycle gates.
|
||||
|
||||
Reference in new issue
Block a user