mirror of
https://github.com/openai/codex.git
synced 2026-10-26 18:38:47 +00:00
Move instruction preload helper out of core
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use codex_core::AgentsMdManager;
|
||||
use codex_core::ThreadManager;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::load_thread_user_instructions as preload_thread_user_instructions;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::error::Result as CodexResult;
|
||||
use codex_protocol::protocol::TurnEnvironmentSelection;
|
||||
|
||||
@@ -11,10 +12,24 @@ pub(super) async fn load_thread_user_instructions(
|
||||
config: &mut Config,
|
||||
environments: &[TurnEnvironmentSelection],
|
||||
) -> CodexResult<()> {
|
||||
preload_thread_user_instructions(
|
||||
config,
|
||||
thread_manager.environment_manager().as_ref(),
|
||||
environments,
|
||||
)
|
||||
.await
|
||||
let Some(primary_selection) = environments.first() else {
|
||||
config.user_instructions = None;
|
||||
return Ok(());
|
||||
};
|
||||
let environment = thread_manager
|
||||
.environment_manager()
|
||||
.get_environment(&primary_selection.environment_id)
|
||||
.ok_or_else(|| {
|
||||
CodexErr::InvalidRequest(format!(
|
||||
"unknown turn environment id `{}`",
|
||||
primary_selection.environment_id
|
||||
))
|
||||
})?;
|
||||
let mut warnings = Vec::new();
|
||||
let user_instructions = AgentsMdManager::new(config)
|
||||
.load_user_instructions(environment.as_ref(), &mut warnings)
|
||||
.await;
|
||||
config.startup_warnings.extend(warnings);
|
||||
config.user_instructions = user_instructions;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user