mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
refactor(proxy): delete the unused memory_tool_adapter module
headroom/proxy/memory_tool_adapter.py (1280 lines) predates MemoryHandler and nothing in the product imports it. Its only importer was a small test that poked the adapter's private parse helpers on an object.__new__ instance; the live null-function parsing is covered by tests/test_memory_handler_null_function.py. Evidence: grep for memory_tool_adapter / MemoryToolAdapter across headroom, crates, plugins, sdk, scripts, docs, wiki, tests, pyproject.toml and the consumer repos finds only the module, that test, and a docstring mention in helpers.py (updated here). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: claude-code:claude-opus-5-5 Headline-Session: 6e77a807-8dd4-4a77-a2fa-ddce6dc2515e Headline-AI-Share: 100% strict / 100% weighted
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a9815bbb5f
commit
4b1cf7d93c
@@ -2426,8 +2426,7 @@ def serialize_tool_definition_canonical(tool_definition: dict[str, Any]) -> byte
|
||||
no ASCII escaping). Python 3.7+ dict insertion order is preserved by
|
||||
``json.dumps`` so callers must construct the tool definition with a
|
||||
stable key order — which the static schemas in
|
||||
``headroom/proxy/memory_handler.py`` and
|
||||
``headroom/proxy/memory_tool_adapter.py`` already do.
|
||||
``headroom/proxy/memory_handler.py`` already do.
|
||||
|
||||
Returned bytes pin the golden tool definition for a session: every
|
||||
follow-up turn must inject byte-equal output to keep the prefix
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,35 +0,0 @@
|
||||
"""A tool call with a null ``function`` / ``arguments`` must not crash the
|
||||
memory tool adapter's provider-format parsing.
|
||||
|
||||
``dict.get("function", {})`` returns ``None`` for a present-but-null key, so the
|
||||
following ``.get`` raised ``AttributeError``; a null ``arguments`` makes
|
||||
``json.loads(None)`` raise ``TypeError`` that the bare ``JSONDecodeError`` catch
|
||||
missed. Both are reachable from the untrusted upstream response. The parse
|
||||
helpers read only the ``tool_call`` argument, so we exercise them on a bare
|
||||
instance via ``object.__new__``.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from headroom.proxy.memory_tool_adapter import MemoryToolAdapter
|
||||
|
||||
_adapter = object.__new__(MemoryToolAdapter)
|
||||
|
||||
|
||||
def test_get_tool_name_survives_null_function():
|
||||
tc = {"id": "c1", "type": "function", "function": None}
|
||||
assert _adapter._get_tool_name(tc, "openai") == ""
|
||||
assert _adapter._get_tool_id(tc, "openai") == "c1"
|
||||
assert _adapter._get_tool_input(tc, "openai") == {}
|
||||
|
||||
|
||||
def test_get_tool_input_survives_null_arguments():
|
||||
# json.loads(None) raises TypeError, not JSONDecodeError.
|
||||
tc = {"function": {"name": "memory_save", "arguments": None}}
|
||||
assert _adapter._get_tool_input(tc, "openai") == {}
|
||||
|
||||
|
||||
def test_get_tool_helpers_still_parse_real_calls():
|
||||
tc = {"function": {"name": "memory_save", "arguments": '{"content": "hi"}'}}
|
||||
assert _adapter._get_tool_name(tc, "openai") == "memory_save"
|
||||
assert _adapter._get_tool_input(tc, "openai") == {"content": "hi"}
|
||||
Reference in New Issue
Block a user