[codex] Use input items for Responses Lite tools (#27946)

When using Responses Lite, we should all use `additional_tools` and a
developer item instead of the top level tools array & instructions
field. This keeps things 1-to-1.

Forced namespacing for _all_ tools will land in a following PR after
some coordination & fixes in Responses API (around collisions & return
items).

The goal is to eventually expand the scope of this to _all_ requests
from codex, but that will require larger coordination across providers &
slower rollout.
This commit is contained in:
rka-oai
2026-06-22 23:56:16 -07:00
committed by GitHub
parent a22e3d0b82
commit 33cc928d33
22 changed files with 298 additions and 45 deletions
+22 -4
View File
@@ -932,6 +932,14 @@ impl InternalChatMessageMetadataPassthrough {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema, TS)]
#[serde(tag = "type", rename_all = "snake_case")]
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>,
},
Message {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
@@ -1160,7 +1168,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, .. }
@@ -1181,7 +1190,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, .. }
@@ -1282,7 +1292,7 @@ impl ResponseItem {
internal_chat_message_metadata_passthrough: metadata,
..
} => metadata.as_ref(),
Self::CompactionTrigger { .. } | Self::Other => None,
Self::CompactionTrigger { .. } | Self::AdditionalTools { .. } | Self::Other => None,
}
}
@@ -1346,7 +1356,7 @@ impl ResponseItem {
internal_chat_message_metadata_passthrough: metadata,
..
} => Some(metadata),
Self::CompactionTrigger { .. } | Self::Other => None,
Self::CompactionTrigger { .. } | Self::AdditionalTools { .. } | Self::Other => None,
}
}
}
@@ -2237,6 +2247,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_passthrough_metadata(