mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
Allow replacing dynamic tools between model steps (#57553)
## What changed Add `CodexThread::replace_dynamic_tools` to replace the tool catalog without starting a turn. Updates apply to subsequent model steps and future turns while preserving in-flight calls; an empty list clears the catalog. Require host opt-in through `allow_persistent_dynamic_tool_updates` for persistent threads. Persist replacements before publishing them, restore the latest catalog on resume, and preserve replacements and explicit clears through compaction. Keep explicit resume overrides separate from the persisted catalog. ## Testing Add coverage for pending calls during replacement, replacement and clearing across restart, compaction recovery, resume overrides, submission ordering after caller cancellation, host opt-in, and persistence failures. GitOrigin-RevId: fd2634906895a9b72ae7892ddd9435dced45eccb
This commit is contained in:
@@ -719,6 +719,24 @@ impl CodexThread {
|
||||
self.session.update_settings(updates).await.map(|_| ())
|
||||
}
|
||||
|
||||
/// Replaces tools for subsequent model steps and future turns, preserving in-flight calls.
|
||||
/// An empty list removes all dynamic tools. Persistent threads require host opt-in
|
||||
/// so every reader can restore successful updates on resume.
|
||||
///
|
||||
/// Once queued, stopping the caller does not cancel the update.
|
||||
/// A persistence error can leave the durable result indeterminate; retry the same replacement
|
||||
/// before continuing.
|
||||
pub async fn replace_dynamic_tools(
|
||||
&self,
|
||||
tools: Vec<codex_protocol::dynamic_tools::DynamicToolSpec>,
|
||||
) -> CodexResult<()> {
|
||||
let (reply, result) = oneshot::channel();
|
||||
self.io
|
||||
.submit(Op::ReplaceDynamicTools { tools, reply })
|
||||
.await?;
|
||||
result.await.unwrap_or(Err(CodexErr::InternalAgentDied))
|
||||
}
|
||||
|
||||
/// Persists current settings without emitting a live settings event.
|
||||
///
|
||||
/// Serializes snapshot capture and persistence with accepted settings updates.
|
||||
|
||||
Reference in New Issue
Block a user