mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-08 11:56:59 +00:00
Checkpoint Odysseus local update
This commit is contained in:
@@ -37,3 +37,23 @@ def test_gemma_parser_does_not_strip_non_tool_fenced_metadata():
|
||||
|
||||
assert parse_tool_blocks(raw) == []
|
||||
assert strip_tool_blocks(raw) == raw
|
||||
|
||||
|
||||
def test_strip_raw_openai_function_json_leak():
|
||||
raw = (
|
||||
'{"function":{"arguments":"{\\"action\\":\\"search\\",\\"tex\\":\\"hi\\"}",'
|
||||
'"name":"manage_memory"},"id":"call_memory_search1","type":"function"}]</|assistan|Done.'
|
||||
)
|
||||
|
||||
assert strip_tool_blocks(raw) == "Done."
|
||||
|
||||
|
||||
def test_strip_raw_openai_function_json_array_leak():
|
||||
raw = (
|
||||
'Before\n['
|
||||
'{"function":{"arguments":"{\\"action\\":\\"add\\",\\"text\\":\\"x\\"}",'
|
||||
'"name":"manage_memory"},"id":"call_memory_add1","type":"function"}'
|
||||
']\nAfter'
|
||||
)
|
||||
|
||||
assert strip_tool_blocks(raw) == "Before\nAfter"
|
||||
|
||||
@@ -86,6 +86,28 @@ def test_normal_model_payload_keeps_temperature_above_one(monkeypatch):
|
||||
assert payload["temperature"] == 1.2
|
||||
|
||||
|
||||
def test_local_minimax_mlx_payload_gets_stability_defaults(monkeypatch):
|
||||
import src.model_context as model_context
|
||||
|
||||
monkeypatch.setattr(model_context, "is_local_endpoint", lambda _url: True)
|
||||
payload = {
|
||||
"model": "cookietimeh/MiniMax-M2.7-BF16-ultra-uncensored-heretic-mlx-4Bit",
|
||||
"temperature": 0.9,
|
||||
}
|
||||
|
||||
llm_core._apply_local_generation_stability(
|
||||
payload,
|
||||
"http://192.168.1.22:8091/v1/chat/completions",
|
||||
"cookietimeh/MiniMax-M2.7-BF16-ultra-uncensored-heretic-mlx-4Bit",
|
||||
)
|
||||
|
||||
assert payload["temperature"] == 0.2
|
||||
assert payload["top_p"] == 0.9
|
||||
assert payload["top_k"] == 20
|
||||
assert payload["max_tokens"] == 2048
|
||||
assert payload["repetition_penalty"] == 1.12
|
||||
|
||||
|
||||
def test_chatgpt_subscription_payload_omits_max_output_tokens():
|
||||
# ChatGPT Subscription Codex API does not support max_output_tokens —
|
||||
# passing it returns HTTP 400 "Unsupported parameter: max_output_tokens".
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
from src.agent_loop import _normalize_stream_document_fences
|
||||
from src.tool_parsing import parse_tool_blocks
|
||||
|
||||
|
||||
def test_truncated_update_document_fence_is_executable():
|
||||
text = "```update_documen\n# Title\n\nSwedish body\n```"
|
||||
|
||||
normalized = _normalize_stream_document_fences(text, "update_document")
|
||||
blocks = parse_tool_blocks(normalized)
|
||||
|
||||
assert len(blocks) == 1
|
||||
assert blocks[0].tool_type == "update_document"
|
||||
assert "Swedish body" in blocks[0].content
|
||||
|
||||
|
||||
def test_truncated_edit_document_fence_is_executable():
|
||||
text = (
|
||||
"```edit_documen\n"
|
||||
"<<<FIND>>>\nold\n<<<REPLACE>>>\nnew\n<<<END>>>\n"
|
||||
"```"
|
||||
)
|
||||
|
||||
normalized = _normalize_stream_document_fences(text, "update_document")
|
||||
blocks = parse_tool_blocks(normalized)
|
||||
|
||||
assert len(blocks) == 1
|
||||
assert blocks[0].tool_type == "edit_document"
|
||||
|
||||
|
||||
def test_compact_truncated_edit_document_fence_is_executable():
|
||||
text = "```edi_documen\n<<FIND>old\n<<REPLACE>new\n<<END>```\n|end|"
|
||||
|
||||
normalized = _normalize_stream_document_fences(text, "update_document")
|
||||
blocks = parse_tool_blocks(normalized)
|
||||
|
||||
assert len(blocks) == 1
|
||||
assert blocks[0].tool_type == "edit_document"
|
||||
assert blocks[0].content == "<<<FIND>>>\nold\n<<<REPLACE>>>\nnew\n<<<END>>>"
|
||||
@@ -516,6 +516,33 @@ async def test_app_api_blocks_cookbook_host_control_routes_before_loopback(monke
|
||||
assert error_text in result["error"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_api_blocks_search_route_before_loopback(monkeypatch):
|
||||
import httpx
|
||||
from src.tool_implementations import do_app_api
|
||||
|
||||
class UnexpectedAsyncClient:
|
||||
def __init__(self, *args, **kwargs):
|
||||
raise AssertionError("app_api should block search routes before loopback")
|
||||
|
||||
monkeypatch.setattr(httpx, "AsyncClient", UnexpectedAsyncClient)
|
||||
|
||||
result = await do_app_api(
|
||||
json.dumps(
|
||||
{
|
||||
"action": "call",
|
||||
"method": "GET",
|
||||
"path": "/api/search",
|
||||
"query": {"q": "crow box designs"},
|
||||
}
|
||||
),
|
||||
owner="admin",
|
||||
)
|
||||
|
||||
assert result["exit_code"] == 1
|
||||
assert "use the `web_search` tool" in result["error"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_api_endpoint_discovery_hides_shell_routes(monkeypatch):
|
||||
_install_core_middleware_stub(monkeypatch)
|
||||
|
||||
@@ -55,3 +55,10 @@ def test_genuine_keywords_still_force_include():
|
||||
assert "reply_to_email" in ti.get_tools_for_query("reply to this email")
|
||||
assert "edit_document" in ti.get_tools_for_query("edit the document")
|
||||
assert "serve_model" in ti.get_tools_for_query("serve the model")
|
||||
|
||||
|
||||
def test_find_info_online_forces_web_search_tools():
|
||||
ti = _index()
|
||||
tools = ti.get_tools_for_query("find info online about crow box designs")
|
||||
assert "web_search" in tools
|
||||
assert "web_fetch" in tools
|
||||
|
||||
Reference in New Issue
Block a user