mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
Share additional tool declarations across response item clones (#54945)
## Why Cloning `ResponseItem::AdditionalTools` deep-copies its tool declarations for history and request copies. ## What changed Store `tools` in an `Arc<[serde_json::Value]>` so clones share immutable declarations. Update constructors and existing test fixtures to use the shared representation. GitOrigin-RevId: eb8831774afb45fe8431a796f34ae9d1243e884a
This commit is contained in:
@@ -2,6 +2,7 @@ use std::collections::HashMap;
|
||||
use std::io;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_utils_image::PromptImageMode;
|
||||
use codex_utils_image::data_url_from_bytes;
|
||||
@@ -1055,7 +1056,8 @@ pub enum ResponseItem {
|
||||
id: Option<ResponseItemId>,
|
||||
role: String,
|
||||
#[ts(type = "unknown[]")]
|
||||
tools: Vec<serde_json::Value>,
|
||||
// Share immutable declarations across history and request copies.
|
||||
tools: Arc<[serde_json::Value]>,
|
||||
},
|
||||
Message {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
@@ -2807,7 +2809,7 @@ mod tests {
|
||||
let mut additional_tools = ResponseItem::AdditionalTools {
|
||||
id: None,
|
||||
role: "developer".to_string(),
|
||||
tools: Vec::new(),
|
||||
tools: Arc::from([]),
|
||||
};
|
||||
additional_tools.set_id(Some(ResponseItemId::with_suffix("at", "test")));
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user