Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

fix(middleware): use get not pop for _todos_snapshot to survive all parallel after_tool_call invocations

xf gong747d03055f5b
diff --git a/cubepi/middleware/todo.py b/cubepi/middleware/todo.py
index 0208565..9559b32 100644
--- a/cubepi/middleware/todo.py
+++ b/cubepi/middleware/todo.py
@@ -577,7 +577,9 @@ class TodoListMiddleware(Middleware):
if len(parallel_calls) <= 1:
return None
# Restore pre-turn state and mark every parallel write as an error.
- extra["todos"] = extra.pop("_todos_snapshot", extra.get("todos"))
+ # Use get (not pop) so the snapshot remains available for every
+ # duplicate call's after_tool_call invocation.
+ extra["todos"] = extra.get("_todos_snapshot", extra.get("todos"))
return AfterToolCallResult(
content=[
TextContent(