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(examples,docs): only skip resume when AssistantMessage has no pending tool calls
xf gongbc4b9bad8445
diff --git a/examples/resumable_tasks.py b/examples/resumable_tasks.pyindex ae6fd3c..3392d61 100644--- a/examples/resumable_tasks.py+++ b/examples/resumable_tasks.py@@ -89,10 +89,14 @@ async def main(thread_id: str, start: bool) -> None:last_type = type(last).__name__ if last else "none"print(f"Resuming thread {thread_id!r} ({len(agent.state.messages)} messages, last={last_type})")if last_type == "AssistantMessage":- # Run already completed naturally — nothing to resume.- # In a real workflow you'd ask the user for the next prompt.- print("Run already completed. Nothing to resume (last turn was a model reply).")- return+ from cubepi.providers.base import ToolCall+ has_pending_tools = any(isinstance(c, ToolCall) for c in last.content)+ if not has_pending_tools:+ # Run completed normally — no pending tool calls to execute.+ # In a real workflow you'd ask the user for the next prompt.+ print("Run already completed. Nothing to resume.")+ return+ # Has unresolved tool calls — resume() will execute them.await agent.resume()diff --git a/website/docs/recipes/resumable-tasks.md b/website/docs/recipes/resumable-tasks.mdindex 1192577..00b2159 100644--- a/website/docs/recipes/resumable-tasks.md+++ b/website/docs/recipes/resumable-tasks.md@@ -128,10 +128,14 @@ async def main(thread_id: str, initial_prompt: str | None):# AssistantMessage with no queued steer/follow_up → raiseslast = agent.state.messages[-1]if type(last).__name__ == "AssistantMessage":- # Job finished normally before the crash — nothing to resume.- # Ask the user for the next prompt instead.- print("Last run completed. Nothing to resume.")- return+ from cubepi.providers.base import ToolCall+ has_pending_tools = any(isinstance(c, ToolCall) for c in last.content)+ if not has_pending_tools:+ # Job finished normally — no pending tool calls.+ # Ask the user for the next prompt instead.+ print("Last run completed. Nothing to resume.")+ return+ # Has unresolved tool calls — resume() will execute them.await agent.resume()diff --git a/website/versioned_docs/version-0.8/recipes/resumable-tasks.md b/website/versioned_docs/version-0.8/recipes/resumable-tasks.mdindex 1192577..00b2159 100644--- a/website/versioned_docs/version-0.8/recipes/resumable-tasks.md+++ b/website/versioned_docs/version-0.8/recipes/resumable-tasks.md@@ -128,10 +128,14 @@ async def main(thread_id: str, initial_prompt: str | None):# AssistantMessage with no queued steer/follow_up → raiseslast = agent.state.messages[-1]if type(last).__name__ == "AssistantMessage":- # Job finished normally before the crash — nothing to resume.- # Ask the user for the next prompt instead.- print("Last run completed. Nothing to resume.")- return+ from cubepi.providers.base import ToolCall+ has_pending_tools = any(isinstance(c, ToolCall) for c in last.content)+ if not has_pending_tools:+ # Job finished normally — no pending tool calls.+ # Ask the user for the next prompt instead.+ print("Last run completed. Nothing to resume.")+ return+ # Has unresolved tool calls — resume() will execute them.await agent.resume()