diff --git a/codex-launcher_2.1.1_all.deb b/codex-launcher_2.1.1_all.deb index 3c5eb8d..0e25230 100644 Binary files a/codex-launcher_2.1.1_all.deb and b/codex-launcher_2.1.1_all.deb differ diff --git a/src/translate-proxy.py b/src/translate-proxy.py index 9a5000d..b167441 100755 --- a/src/translate-proxy.py +++ b/src/translate-proxy.py @@ -148,8 +148,19 @@ def oa_input_to_messages(input_data): if isinstance(input_data, str): msgs.append({"role": "user", "content": input_data}) elif isinstance(input_data, list): + pending_tool_calls = [] for item in input_data: t = item.get("type") + if t == "function_call": + pending_tool_calls.append( + {"id": item.get("call_id", item.get("id", uid("tc"))), + "type": "function", + "function": {"name": item.get("name", ""), + "arguments": item.get("arguments", "{}")}}) + continue + if pending_tool_calls: + msgs.append({"role": "assistant", "content": None, "tool_calls": pending_tool_calls}) + pending_tool_calls = [] if t == "message": role = item.get("role", "user") if role == "developer": @@ -167,16 +178,11 @@ def oa_input_to_messages(input_data): break if text is not None: msgs.append({"role": role, "content": text}) - elif t == "function_call": - msgs.append({"role": "assistant", "content": None, "tool_calls": [ - {"id": item.get("call_id", item.get("id", uid("tc"))), - "type": "function", - "function": {"name": item.get("name", ""), - "arguments": item.get("arguments", "{}")}} - ]}) elif t == "function_call_output": msgs.append({"role": "tool", "tool_call_id": item.get("id", ""), "content": item.get("output", "")}) + if pending_tool_calls: + msgs.append({"role": "assistant", "content": None, "tool_calls": pending_tool_calls}) return msgs def oa_convert_tools(tools):