Filter out reasoning items from previous turns (#5857)

Reduces request size and prevents 400 errors when switching between API
orgs.

Based on Responses API behavior described in
https://cookbook.openai.com/examples/responses_api/reasoning_items#caching
This commit is contained in:
pakrym-oai
2025-10-28 11:39:34 -07:00
committed by GitHub
parent 65107d24a2
commit 1b8f2543ac
6 changed files with 176 additions and 29 deletions

View File

@@ -68,6 +68,14 @@ impl ResponsesRequest {
.clone()
}
pub fn inputs_of_type(&self, ty: &str) -> Vec<Value> {
self.input()
.iter()
.filter(|item| item.get("type").and_then(Value::as_str) == Some(ty))
.cloned()
.collect()
}
pub fn function_call_output(&self, call_id: &str) -> Value {
self.call_output(call_id, "function_call_output")
}