mirror of
https://github.com/openai/codex.git
synced 2026-11-02 19:43:24 +00:00
[codex] Preserve additional tools item IDs
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user