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 stay valid after construction
cyh0dfd46693438
diff --git a/core/agent_core/messages.py b/core/agent_core/messages.pyindex dbfe00e6c..9d7eb409f 100644--- a/core/agent_core/messages.py+++ b/core/agent_core/messages.py@@ -8,6 +8,7 @@ rows, so the field names here are a shipped surface.from __future__ import annotations+import copyimport refrom dataclasses import dataclass, fieldfrom typing import Any, Literal, Mapping, Optional, Union@@ -107,6 +108,8 @@ class ToolCallBlock:_require(self.name, str, "tool name")_require(self.arguments, dict, "arguments")require_json_value(self.arguments, "arguments")+ # Detach from the caller's object so later mutation of the input cannot reach this block.+ object.__setattr__(self, "arguments", copy.deepcopy(self.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:@@ -306,7 +309,9 @@ def _block_to_dict(block: Any) -> dict[str, Any]:out["redacted"] = Truereturn outif isinstance(block, ToolCallBlock):- out = {"type": "tool_call", "id": block.id, "name": block.name, "arguments": dict(block.arguments)}+ # Arguments are a mutable dict on a frozen block; check again at the write boundary.+ require_json_value(block.arguments, "arguments")+ out = {"type": "tool_call", "id": block.id, "name": block.name, "arguments": copy.deepcopy(block.arguments)}_put(out, "native_id", block.native_id)_put(out, "signature", block.signature)return outdiff --git a/tests/agent_core/test_messages.py b/tests/agent_core/test_messages.pyindex e67ae40a3..fc93f6635 100644--- a/tests/agent_core/test_messages.py+++ b/tests/agent_core/test_messages.py@@ -157,3 +157,16 @@ def test_construction_refuses_what_the_reader_would_refuse(build):with pytest.raises(ValueError):build()++def test_tool_arguments_cannot_become_invalid_after_construction():+ source = {"items": [1, 2]}+ block = ToolCallBlock(id="c", name="bash", arguments=source)+ source["items"].append((3, 4)) # the caller's object no longer reaches the block+ message = AssistantMessage(+ content=(block,), origin=Origin(provider="anthropic", api="anthropic", model="m"), stop_reason="tool_use"+ )+ assert message_to_dict(message)["content"][0]["arguments"] == {"items": [1, 2]}+ block.arguments["late"] = b"raw" # a consumer mutating the block itself is refused at the writer+ with pytest.raises(ValueError):+ message_to_dict(message)+