This commit is contained in:
@@ -217,6 +217,90 @@ def test_ollama_options_include_num_ctx():
|
||||
assert agent._ollama_options() == {"num_ctx": 64000}
|
||||
|
||||
|
||||
def test_codex_prompt_mentions_tools_and_images(tmp_path):
|
||||
memory = MemoryStore(str(tmp_path / "memory.sqlite3"))
|
||||
agent = OllamaAgent("codex", "gpt-5.3-codex", EmptyTools(), memory=memory, provider="codex")
|
||||
|
||||
prompt = agent._codex_cli_prompt(
|
||||
"check listing",
|
||||
[
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Look at this",
|
||||
"images": ["ZmFrZQ=="],
|
||||
"image_content_types": ["image/png"],
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "",
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "call_123",
|
||||
"type": "function",
|
||||
"function": {"name": "search_marketplace_listings", "arguments": "{\"commodity\":\"gold\"}"},
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_name": "search_marketplace_listings",
|
||||
"tool_call_id": "call_123",
|
||||
"content": "{\"ok\":true}",
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
assert "Available tools" in prompt
|
||||
assert "attached images: 1" in prompt
|
||||
assert "search_marketplace_listings" in prompt
|
||||
assert "tool search_marketplace_listings" in prompt
|
||||
|
||||
|
||||
def test_codex_structured_response_extracts_text_and_tool_calls():
|
||||
agent = OllamaAgent("codex", "gpt-5.3-codex", EmptyTools(), provider="codex")
|
||||
|
||||
result = agent._codex_structured_response(
|
||||
{
|
||||
"kind": "tool_call",
|
||||
"message": "",
|
||||
"tool_name": "search_marketplace_listings",
|
||||
"arguments_json": "{\"commodity\":\"gold\"}",
|
||||
}
|
||||
)
|
||||
|
||||
assert result["message"]["content"] == ""
|
||||
assert result["message"]["tool_calls"] == [
|
||||
{
|
||||
"id": result["message"]["tool_calls"][0]["id"],
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "search_marketplace_listings",
|
||||
"arguments": "{\"commodity\":\"gold\"}",
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def test_parse_codex_exec_output_reads_final_json():
|
||||
agent = OllamaAgent("codex", "gpt-5.3-codex", EmptyTools(), provider="codex")
|
||||
|
||||
result = agent._parse_codex_exec_output(
|
||||
{
|
||||
"returncode": 0,
|
||||
"stdout": "",
|
||||
"stderr": "",
|
||||
"events": [
|
||||
{"type": "thread.started", "thread_id": "abc"},
|
||||
{"type": "item.completed", "item": {"type": "agent_message", "text": "{\"kind\":\"final\",\"message\":\"hello\",\"tool_name\":\"\",\"arguments_json\":\"{}\"}"}},
|
||||
{"type": "turn.completed"},
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
assert result == {"kind": "final", "message": "hello", "tool_name": "", "arguments_json": "{}"}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_wake_response_executes_tool_calls(tmp_path):
|
||||
memory = MemoryStore(str(tmp_path / "memory.sqlite3"))
|
||||
|
||||
Reference in New Issue
Block a user