Skip to content

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

style: fix ruff lint errors and formatting

xf gong722d904fe2f8
diff --git a/cubepi/middleware/goal.py b/cubepi/middleware/goal.py
index e9209d2..9dbd0e0 100644
--- a/cubepi/middleware/goal.py
+++ b/cubepi/middleware/goal.py
@@ -96,9 +96,7 @@ class GoalMiddleware(Middleware):
self._condition = condition
self._evaluations = 0
- rewritten = last.model_copy(
- update={"content": [TextContent(text=condition)]}
- )
+ rewritten = last.model_copy(update={"content": [TextContent(text=condition)]})
# Mutate ctx.messages so the stripped form is what gets stored in
# agent state — the /goal prefix is a one-way control signal that
# should not persist in the conversation history.
diff --git a/cubepi/providers/base.py b/cubepi/providers/base.py
index 37eebc0..9103c6b 100644
--- a/cubepi/providers/base.py
+++ b/cubepi/providers/base.py
@@ -855,7 +855,9 @@ class BoundModel:
"Do NOT respond with plain text."
)
full_system = (
- f"{system_prompt}\n\n{default_hint}".strip() if system_prompt else default_hint
+ f"{system_prompt}\n\n{default_hint}".strip()
+ if system_prompt
+ else default_hint
)
attempt_messages = list(messages)
diff --git a/tests/providers/test_tool_choice.py b/tests/providers/test_tool_choice.py
index d6edfcc..8ecafed 100644
--- a/tests/providers/test_tool_choice.py
+++ b/tests/providers/test_tool_choice.py
@@ -10,7 +10,6 @@ methods and ``tool_choice`` parameter are implemented (TDD red phase).
from __future__ import annotations
-import pytest
from cubepi.providers.anthropic import AnthropicProvider
from cubepi.providers.base import Model, UserMessage, TextContent
diff --git a/tests/test_goal.py b/tests/test_goal.py
index c304ed2..49451b4 100644
--- a/tests/test_goal.py
+++ b/tests/test_goal.py
@@ -2,11 +2,10 @@
from __future__ import annotations
-import pytest
from cubepi import Agent
from cubepi.middleware.goal import GoalMiddleware
-from cubepi.providers.base import TextContent, UserMessage
+from cubepi.providers.base import UserMessage
from cubepi.providers.faux import FauxProvider, faux_assistant_message, faux_tool_call
@@ -47,7 +46,8 @@ async def test_goal_achieved_first_eval() -> None:
[
faux_assistant_message(
faux_tool_call(
- "structured_output", {"achieved": True, "reason": "All tests passing"}
+ "structured_output",
+ {"achieved": True, "reason": "All tests passing"},
)
)
]
diff --git a/tests/test_structured_output.py b/tests/test_structured_output.py
index 386e280..45f7e7b 100644
--- a/tests/test_structured_output.py
+++ b/tests/test_structured_output.py
@@ -28,7 +28,11 @@ async def test_generate_structured_happy_path() -> None:
faux_assistant_message(
faux_tool_call(
"structured_output",
- {"title": "Inception", "rating": 9, "summary": "Mind-bending heist film."},
+ {
+ "title": "Inception",
+ "rating": 9,
+ "summary": "Mind-bending heist film.",
+ },
),
stop_reason="tool_use",
)
@@ -49,9 +53,7 @@ async def test_generate_structured_no_tool_call_raises() -> None:
provider = FauxProvider()
model = provider.model("faux-1")
provider.set_responses(
- [
- faux_assistant_message("Here is my review: it was great.", stop_reason="stop")
- ]
+ [faux_assistant_message("Here is my review: it was great.", stop_reason="stop")]
)
messages = [UserMessage(content=[TextContent(text="Review a movie")])]
@@ -87,7 +89,11 @@ async def test_generate_structured_custom_tool_name() -> None:
faux_assistant_message(
faux_tool_call(
"my_output",
- {"title": "The Matrix", "rating": 10, "summary": "Reality-bending classic."},
+ {
+ "title": "The Matrix",
+ "rating": 10,
+ "summary": "Reality-bending classic.",
+ },
),
stop_reason="tool_use",
)
@@ -95,7 +101,9 @@ async def test_generate_structured_custom_tool_name() -> None:
)
messages = [UserMessage(content=[TextContent(text="Review The Matrix")])]
- result = await model.generate_structured(MovieReview, messages, tool_name="my_output")
+ result = await model.generate_structured(
+ MovieReview, messages, tool_name="my_output"
+ )
assert isinstance(result, MovieReview)
assert result.title == "The Matrix"