Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(agent-core): tool-call arguments must be exact JSON
cyh07778d459f7e
diff --git a/core/agent_core/messages.py b/core/agent_core/messages.pyindex db2f5115c..dbfe00e6c 100644--- a/core/agent_core/messages.py+++ b/core/agent_core/messages.py@@ -97,7 +97,7 @@ class ThinkingBlock:class ToolCallBlock:id: strname: str- arguments: Mapping[str, Any] = field(default_factory=dict)+ arguments: dict[str, Any] = field(default_factory=dict)native_id: Optional[str] = Nonesignature: Optional[str] = None"""Opaque provider payload on the call itself (Gemini ``thoughtSignature``); same rules as a thinking signature."""@@ -105,7 +105,8 @@ class ToolCallBlock:def __post_init__(self) -> None:_require(self.id, str, "tool call id")_require(self.name, str, "tool name")- _require(self.arguments, Mapping, "arguments")+ _require(self.arguments, dict, "arguments")+ require_json_value(self.arguments, "arguments")_require(self.native_id, str, "native_id", optional=True)_require(self.signature, str, "signature", optional=True)if not self.id or not self.name:@@ -116,6 +117,31 @@ class ToolCallBlock:raise ValueError("a signature, when present, must not be empty")+def require_json_value(value: Any, what: str) -> None:+ """Refuse anything that would not survive a JSON round trip unchanged.++ Allowed: dict with str keys, list, str, int, finite float, bool, None. A tuple,+ bytes, a non-str key, or NaN would be coerced or rejected on persistence.+ """+ if value is None or isinstance(value, (str, bool, int)):+ return+ if isinstance(value, float):+ if value != value or value in (float("inf"), float("-inf")):+ raise ValueError(f"{what} must be a finite number")+ return+ if isinstance(value, list):+ for index, item in enumerate(value):+ require_json_value(item, f"{what}[{index}]")+ return+ if isinstance(value, dict):+ for key, item in value.items():+ if not isinstance(key, str):+ raise ValueError(f"{what} keys must be strings")+ require_json_value(item, f"{what}.{key}")+ return+ raise ValueError(f"{what} must be JSON (got {type(value).__name__})")++def _require_blocks(content: Any, allowed: tuple[type, ...], what: str) -> None:if not isinstance(content, tuple) or not all(isinstance(block, allowed) for block in content):raise ValueError(f"{what} content must be a tuple of {', '.join(k.__name__ for k in allowed)}")diff --git a/tests/agent_core/test_messages.py b/tests/agent_core/test_messages.pyindex 8d3f8f060..e67ae40a3 100644--- a/tests/agent_core/test_messages.py+++ b/tests/agent_core/test_messages.py@@ -108,6 +108,7 @@ def test_assistant_message_exposes_tool_calls_in_order():{**TOOL_RESULT, "tool_name": ""},{**ASSISTANT, "usage": {**ASSISTANT["usage"], "cache_read_tokens": -1}},{**ASSISTANT, "content": [{"type": "tool_call", "id": "t", "name": "bash", "arguments": {}, "signature": ""}]},+ {**ASSISTANT, "content": [{"type": "tool_call", "id": "t", "name": "bash", "arguments": {"x": float("nan")}}]},{**REDACTED, "content": [{"type": "thinking", "text": "", "redacted": True}]},{**REDACTED, "content": [{"type": "thinking", "text": "visible", "signature": "opaque", "redacted": True}]},],@@ -116,7 +117,7 @@ def test_assistant_message_exposes_tool_calls_in_order():"unknown-ref-field", "string-flag", "integer-flag", "string-redacted", "string-count", "boolean-count","string-arguments", "number-text", "content-not-list", "null-signature", "null-name", "null-error","null-usage", "explicit-not-redacted", "digest-newline", "empty-call-id", "empty-tool-name", "negative-count",- "empty-call-signature", "redacted-without-payload", "redacted-with-text",+ "empty-call-signature", "nan-argument", "redacted-without-payload", "redacted-with-text",],)def test_reader_refuses_shapes_it_does_not_know(payload):@@ -141,8 +142,15 @@ def test_text_block_holds_exactly_one_form():lambda: ToolCallBlock(id="c", name="bash", arguments=[]),lambda: UserMessage(content=[TextBlock(text="list, not tuple")]),lambda: Origin(provider="openai", api="openai_chat", model=5),+ lambda: ToolCallBlock(id="c", name="bash", arguments={"items": (1, 2)}),+ lambda: ToolCallBlock(id="c", name="bash", arguments={"data": b"raw"}),+ lambda: ToolCallBlock(id="c", name="bash", arguments={"n": {1: "x"}}),+ lambda: ToolCallBlock(id="c", name="bash", arguments={"x": float("nan")}),+ ],+ ids=[+ "bool-count", "float-count", "int-flag", "int-redacted", "list-arguments", "list-content", "int-model",+ "nested-tuple", "nested-bytes", "nested-int-key", "nested-nan",],- ids=["bool-count", "float-count", "int-flag", "int-redacted", "list-arguments", "list-content", "int-model"],)def test_construction_refuses_what_the_reader_would_refuse(build):# The writer must never produce a row its own reader rejects.