[codex] Simplify Responses Lite request tests

This commit is contained in:
Rohit Arunachalam
2026-06-16 19:56:16 -07:00
parent c292eb318d
commit 0ff32c55bb
2 changed files with 15 additions and 9 deletions

View File

@@ -104,11 +104,13 @@ fn responses_lite_request_copies_strip_image_details() {
#[test]
fn serializes_text_verbosity_when_set() {
let input: Vec<ResponseItem> = vec![];
let tools: Vec<serde_json::Value> = vec![];
let req = ResponsesApiRequest {
model: "gpt-5.4".to_string(),
instructions: "i".to_string(),
input: vec![],
tools: Some(vec![]),
input,
tools: Some(tools),
tool_choice: "auto".to_string(),
parallel_tool_calls: true,
reasoning: None,
@@ -135,6 +137,8 @@ fn serializes_text_verbosity_when_set() {
#[test]
fn serializes_text_schema_with_strict_format() {
let input: Vec<ResponseItem> = vec![];
let tools: Vec<serde_json::Value> = vec![];
let schema = serde_json::json!({
"type": "object",
"properties": {
@@ -152,8 +156,8 @@ fn serializes_text_schema_with_strict_format() {
let req = ResponsesApiRequest {
model: "gpt-5.4".to_string(),
instructions: "i".to_string(),
input: vec![],
tools: Some(vec![]),
input,
tools: Some(tools),
tool_choice: "auto".to_string(),
parallel_tool_calls: true,
reasoning: None,
@@ -208,11 +212,13 @@ fn serializes_text_schema_with_non_strict_format() {
#[test]
fn omits_text_when_not_set() {
let input: Vec<ResponseItem> = vec![];
let tools: Vec<serde_json::Value> = vec![];
let req = ResponsesApiRequest {
model: "gpt-5.4".to_string(),
instructions: "i".to_string(),
input: vec![],
tools: Some(vec![]),
input,
tools: Some(tools),
tool_choice: "auto".to_string(),
parallel_tool_calls: true,
reasoning: None,

View File

@@ -60,9 +60,9 @@ fn additional_tools(body: &Value) -> Result<&[Value]> {
body["input"]
.as_array()
.context("Responses request input should be an array")?
.iter()
.find(|item| item.get("type").and_then(Value::as_str) == Some("additional_tools"))
.context("Responses request should contain additional_tools")?["tools"]
.first()
.filter(|item| item.get("type").and_then(Value::as_str) == Some("additional_tools"))
.context("Responses request should start with additional_tools")?["tools"]
.as_array()
.map(Vec::as_slice)
.context("additional_tools tools should be an array")