responses feedback items: whitelist input-shape fields — api rejects response-only fields like status as unknown parameters (live 400)
This commit is contained in:
@@ -40,17 +40,21 @@ def _refusal_item():
|
||||
def _reasoning_item():
|
||||
item = Mock()
|
||||
item.type = "reasoning"
|
||||
item.model_dump = lambda: {"type": "reasoning", "encrypted_content": "opaque-cot"}
|
||||
item.id = "rs_1"
|
||||
item.summary = []
|
||||
item.encrypted_content = "opaque-cot"
|
||||
item.status = "completed" # response-only field; must NOT travel back
|
||||
return item
|
||||
|
||||
|
||||
def _call_item(name, args, call_id="call-1"):
|
||||
item = Mock()
|
||||
item.type = "function_call"
|
||||
item.id = "fc_1"
|
||||
item.name = name
|
||||
item.arguments = json.dumps(args)
|
||||
item.call_id = call_id
|
||||
item.model_dump = lambda: {"type": "function_call", "name": name, "arguments": json.dumps(args), "call_id": call_id}
|
||||
item.status = "completed"
|
||||
return item
|
||||
|
||||
|
||||
@@ -116,7 +120,12 @@ class TestResponsesPath(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertEqual(json.loads(answer["content"])["answer"], "done")
|
||||
responder._dispatch_tool.assert_awaited_once()
|
||||
followup_input = responses_mock.await_args_list[1].kwargs["input"]
|
||||
self.assertIn({"type": "reasoning", "encrypted_content": "opaque-cot"}, followup_input)
|
||||
reasoning = [item for item in followup_input if isinstance(item, dict) and item.get("type") == "reasoning"]
|
||||
self.assertEqual(len(reasoning), 1)
|
||||
self.assertEqual(reasoning[0]["encrypted_content"], "opaque-cot")
|
||||
self.assertNotIn("status", reasoning[0]) # response-only field stripped (live-400 regression)
|
||||
calls_back = [item for item in followup_input if isinstance(item, dict) and item.get("type") == "function_call"]
|
||||
self.assertNotIn("status", calls_back[0])
|
||||
outputs = [item for item in followup_input if isinstance(item, dict) and item.get("type") == "function_call_output"]
|
||||
self.assertEqual(len(outputs), 1)
|
||||
self.assertEqual(outputs[0]["call_id"], "call-9")
|
||||
|
||||
Reference in New Issue
Block a user