CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.
Python agent-frameworkagent-harnessagent-runtimeagentic-aiai-agentsai-frameworkanthropicharnessharness-engineeringharness-frameworklanggraphlanggraph-alternativellmmcpopenaipi-agentpi-agent-corepythonpython-agent
fix(agent): honor AgentToolResult.is_error from tool bodies
Claude070d121afea4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4a0cc9d..054ff9a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0content, or a full `AgentToolResult`. The longhand `AgentTool(...)` remainsfully supported.+### Fixed++- **Tool results that set `is_error=True` are now reported as errors.** A tool+ body that returned `AgentToolResult(is_error=True)` without raising was+ surfaced to the model as a successful result; the flag is now honored on the+ execution path (affects both `@tool` and longhand `AgentTool` tools).+## [0.7.0] - 2026-06-05### Addeddiff --git a/cubepi/agent/tools.py b/cubepi/agent/tools.pyindex 9dce9b3..ab22ed2 100644--- a/cubepi/agent/tools.py+++ b/cubepi/agent/tools.py@@ -242,7 +242,11 @@ async def _execute_prepared(),),)- return result, False+ # Honor an explicit is_error set by the tool body: the pipeline+ # tracks error state as a separate bool, so a tool returning+ # AgentToolResult(is_error=True) without raising must surface here+ # (otherwise the model sees a successful result).+ return result, bool(result.is_error)except HitlControlException:raiseexcept Exception as exc:diff --git a/tests/agent/test_tool_decorator.py b/tests/agent/test_tool_decorator.pyindex c694600..6e2604c 100644--- a/tests/agent/test_tool_decorator.py+++ b/tests/agent/test_tool_decorator.py@@ -183,3 +183,19 @@ class TestEngineIntegration:assert batch.messages[0].tool_call_id == "t1"assert not batch.messages[0].is_errorassert batch.messages[0].content[0].text == "5"++ async def test_is_error_result_surfaces_through_engine(self):+ """A tool that returns is_error=True (without raising) is an error."""++ @tool+ async def flaky(value: str) -> AgentToolResult:+ "Return an explicit error result."+ return AgentToolResult(content=[TextContent(text="nope")], is_error=True)++ ctx = _ctx([flaky])+ msg = _assistant([ToolCall(id="t1", name="flaky", arguments={"value": "x"})])+ batch = await execute_tool_calls(+ ctx, msg, tool_execution="sequential", emit=lambda e: None+ )++ assert batch.messages[0].is_error