mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Store turn skill state in extension data (#36740)
## What changed - Store each turn's host skills snapshot in `ExtensionData` and expose it through `TurnContext::skills_snapshot`. - Lazily keep implicit skill invocation deduplication state in the same turn-scoped store. - Carry the skills snapshot into review turns without a separate `TurnSkillsContext` field. GitOrigin-RevId: d71579b5d230bd0b5f3c2ad062861f74d614d88c
This commit is contained in:
1 parent
d6407d7359
commit
79479cdf09
6 files changed
+26
-38
No files matched your search
@@ -25,21 +25,6 @@ use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::Ordering;
|
||||
use tracing::instrument;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct TurnSkillsContext {
|
||||
pub(crate) snapshot: HostSkillsSnapshot,
|
||||
pub(crate) implicit_invocation_seen_skills: Arc<Mutex<HashSet<String>>>,
|
||||
}
|
||||
|
||||
impl TurnSkillsContext {
|
||||
pub(crate) fn new(snapshot: HostSkillsSnapshot) -> Self {
|
||||
Self {
|
||||
snapshot,
|
||||
implicit_invocation_seen_skills: Arc::new(Mutex::new(HashSet::new())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) type ShellSnapshotTask = Shared<BoxFuture<'static, Option<Arc<ShellSnapshotFile>>>>;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -151,7 +136,6 @@ pub struct TurnContext {
|
||||
pub(crate) dynamic_tools: Vec<DynamicToolSpec>,
|
||||
pub(crate) turn_metadata_state: Arc<TurnMetadataState>,
|
||||
pub(crate) extension_data: Arc<codex_extension_api::ExtensionData>,
|
||||
pub(crate) turn_skills: TurnSkillsContext,
|
||||
pub(crate) turn_timing_state: Arc<TurnTimingState>,
|
||||
pub(crate) terminal_error: Arc<Mutex<Option<ErrorEvent>>>,
|
||||
pub(crate) server_model_warning_emitted: AtomicBool,
|
||||
@@ -164,6 +148,13 @@ enum TurnMultiAgentRuntime {
|
||||
}
|
||||
|
||||
impl TurnContext {
|
||||
pub(crate) fn skills_snapshot(&self) -> Arc<HostSkillsSnapshot> {
|
||||
let Some(snapshot) = self.extension_data.get::<HostSkillsSnapshot>() else {
|
||||
unreachable!("every turn has a host skills snapshot");
|
||||
};
|
||||
snapshot
|
||||
}
|
||||
|
||||
pub(crate) fn collaboration_mode(&self) -> CollaborationMode {
|
||||
CollaborationMode {
|
||||
mode: self.mode,
|
||||
@@ -319,7 +310,6 @@ impl TurnContext {
|
||||
dynamic_tools: self.dynamic_tools.clone(),
|
||||
turn_metadata_state: self.turn_metadata_state.clone(),
|
||||
extension_data: Arc::clone(&self.extension_data),
|
||||
turn_skills: self.turn_skills.clone(),
|
||||
turn_timing_state: Arc::clone(&self.turn_timing_state),
|
||||
terminal_error: Arc::clone(&self.terminal_error),
|
||||
server_model_warning_emitted: AtomicBool::new(
|
||||
@@ -548,7 +538,7 @@ impl Session {
|
||||
));
|
||||
let (current_date, timezone) = local_time_context();
|
||||
let extension_data = Arc::new(codex_extension_api::ExtensionData::new(sub_id.clone()));
|
||||
extension_data.insert(skills_snapshot.clone());
|
||||
extension_data.insert(skills_snapshot);
|
||||
TurnContext {
|
||||
sub_id,
|
||||
trace_id: current_span_trace_id(),
|
||||
@@ -589,7 +579,6 @@ impl Session {
|
||||
dynamic_tools: session_configuration.dynamic_tools.clone(),
|
||||
turn_metadata_state,
|
||||
extension_data,
|
||||
turn_skills: TurnSkillsContext::new(skills_snapshot),
|
||||
turn_timing_state: Arc::new(TurnTimingState::default()),
|
||||
terminal_error: Arc::new(Mutex::new(None)),
|
||||
server_model_warning_emitted: AtomicBool::new(false),
|
||||
|
||||
Reference in new issue
Block a user