[codex] Preserve additional tools item IDs

This commit is contained in:
Rohit Arunachalam
2026-06-22 00:03:47 -07:00
parent 0ff32c55bb
commit 0f97af09d4
4 changed files with 29 additions and 2 deletions
+14 -2
View File
@@ -920,6 +920,8 @@ pub enum ResponseItem {
#[schemars(skip)]
#[ts(skip)]
AdditionalTools {
#[serde(default, skip_serializing_if = "Option::is_none")]
id: Option<String>,
role: String,
tools: Vec<serde_json::Value>,
},
@@ -1156,7 +1158,8 @@ impl ResponseItem {
/// Returns the non-empty Responses API item ID, if present.
pub fn id(&self) -> Option<&str> {
match self {
Self::Message { id, .. }
Self::AdditionalTools { id, .. }
| Self::Message { id, .. }
| Self::AgentMessage { id, .. }
| Self::LocalShellCall { id, .. }
| Self::FunctionCall { id, .. }
@@ -1177,7 +1180,8 @@ impl ResponseItem {
/// Sets or clears the Responses API item ID for variants that carry one.
pub fn set_id(&mut self, new_id: Option<String>) {
match self {
Self::Message { id, .. }
Self::AdditionalTools { id, .. }
| Self::Message { id, .. }
| Self::AgentMessage { id, .. }
| Self::LocalShellCall { id, .. }
| Self::FunctionCall { id, .. }
@@ -2145,6 +2149,14 @@ mod tests {
item.set_id(/*new_id*/ None);
assert_eq!(item.id(), None);
let mut additional_tools = ResponseItem::AdditionalTools {
id: None,
role: "developer".to_string(),
tools: Vec::new(),
};
additional_tools.set_id(Some("at_test".to_string()));
assert_eq!(additional_tools.id(), Some("at_test"));
}
fn response_item_with_metadata(metadata: Option<ResponseItemMetadata>) -> ResponseItem {