fix(codex-bridge): preserve plaintext peer tasks and fail invalid transfers without retries
Server CI and Windows package / verify (push) Successful in 6m11s
Server CI and Windows package / windows-package (push) Successful in 17m49s

This commit is contained in:
yilsem committed 2026-10-20 07:35:41 +03:00
1 parent 212015e7c9
commit 1aa033a751
8 files changed
+143 -10

No files matched your search

@@ -45,6 +45,29 @@ class ToolNamespaces(unittest.TestCase):
self.assertEqual(restored["id"], "ctc_patch")
self.assertEqual(restored["input"], "patch text")
def test_plaintext_peer_marker_survives_namespace_restore_and_split_frames(self):
req = self.request(); names = {}; custom = env["flatten_request"](req, names)
alias = req["tools"][0]["name"]
arguments = json.dumps({"task_name": "child", "message": "Execute the complete delegated task."})
item = {"type": "function_call", "name": alias, "id": "fc_peer", "call_id": "call_peer", "arguments": arguments}
events = [
{"type": "response.output_item.added", "item": dict(item, arguments="")},
{"type": "response.function_call_arguments.delta", "item_id": "fc_peer", "delta": arguments[:17]},
{"type": "response.function_call_arguments.delta", "item_id": "fc_peer", "delta": arguments[17:]},
{"type": "response.output_item.done", "item": dict(item)},
{"type": "response.completed", "response": {"output": [dict(item)]}},
]
raw = b"".join(("data: " + json.dumps(event) + "\n\n").encode() for event in events)
adapter = env["SseRewriter"](custom, tool_names=names)
output = b"".join(adapter.feed(raw[i:i+13]) for i in range(0, len(raw), 13)) + adapter.flush()
restored = [json.loads(line[6:]) for line in output.decode().splitlines() if line.startswith("data: ")]
self.assertNotIn("encrypted_function_args", restored[0]["item"])
self.assertEqual(restored[1:3], events[1:3])
for final in (restored[3]["item"], restored[4]["response"]["output"][0]):
self.assertEqual(final["encrypted_function_args"], [])
self.assertEqual((final["namespace"], final["name"]), ("collaboration", "spawn_agent"))
self.assertEqual((final["id"], final["call_id"], final["arguments"]), ("fc_peer", "call_peer", arguments))
def test_plain_tools_stay_plain_and_history_not_mutated(self):
req = self.request(); original = copy.deepcopy(req); old_item = req["input"][0]
env["flatten_request"](req, {})