Skip to content

"Vibe-Trading: Your Personal Trading Agent"

test(swarm): pin the incomplete path to the message log

cgycoreyc57dcfd1330e
diff --git a/agent/tests/test_swarm_worker_message_log.py b/agent/tests/test_swarm_worker_message_log.py
index a08c42b22..81eac50be 100644
--- a/agent/tests/test_swarm_worker_message_log.py
+++ b/agent/tests/test_swarm_worker_message_log.py
@@ -4,7 +4,8 @@
for: the assistant message carries ``function.arguments`` verbatim, while the
event stream redacts ``run_dir`` from the argument preview. A terminal path
that reports a summary must also write the log, so a completed run, a token
-limit and a content-filter trip all leave the same two files.
+limit, a content-filter trip and an output-contract rejection all leave the
+same two files.
"""
from __future__ import annotations
@@ -79,6 +80,20 @@ class _ContentFilteredLLM:
"""No-op: the scripted stub owns no HTTP client."""
+class _AnswersWithoutToolCallsLLM:
+ """A final answer and nothing else, for a data agent that never probed."""
+
+ def stream_chat(self, messages, tools=None, timeout=None, on_text_chunk=None):
+ return LLMResponse(
+ content="The market looks range-bound, so no further analysis is needed.",
+ tool_calls=[],
+ finish_reason="stop",
+ )
+
+ def close(self) -> None:
+ """No-op: the scripted stub owns no HTTP client."""
+
+
def _run_worker_to_terminal(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
@@ -157,6 +172,21 @@ def test_content_filter_circuit_breaker_persists_the_message_log(
assert (artifact_dir / "messages.json").is_file()
+def test_incomplete_run_persists_the_message_log(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """A data agent that answers without calling a tool must leave a log too."""
+ result = _run_worker_to_terminal(
+ tmp_path, monkeypatch, llm_factory=_AnswersWithoutToolCallsLLM
+ )
+ artifact_dir = agent_artifact_dir(tmp_path, "analyst")
+
+ assert result.status == "incomplete", result.error
+ assert "no tool calls" in (result.error or "")
+ assert (artifact_dir / "summary.md").is_file()
+ assert (artifact_dir / "messages.json").is_file()
+
+
def test_message_log_carries_the_tool_call_arguments(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None: