"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(tests): accept LLM timeout kwargs in loop stubs; fix order-level test encoding
Will Liao86d04222dac7
diff --git a/agent/tests/test_agent_goal_context.py b/agent/tests/test_agent_goal_context.pyindex ce7c56074..84b663156 100644--- a/agent/tests/test_agent_goal_context.py+++ b/agent/tests/test_agent_goal_context.py@@ -30,6 +30,8 @@ class _CapturingLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _AnswerResponse:del tools, on_text_chunk, on_reasoning_chunkdiff --git a/agent/tests/test_agent_grounding.py b/agent/tests/test_agent_grounding.pyindex b06e5a843..2c81c5373 100644--- a/agent/tests/test_agent_grounding.py+++ b/agent/tests/test_agent_grounding.py@@ -948,6 +948,8 @@ class _CorrectingLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _Response:response = self.responses.pop(0)@@ -2210,8 +2212,8 @@ def test_in_text_decimal_survives_list_marker_mask(def test_order_level_prices_are_not_observed_quotes(tmp_path: Path) -> None:"""GTC order limits (100 @ $3.50) are prospective, not observed prices.- Regression for the RXRX run: the draft "两档 GTC (100 @ $3.50 / 100 @ $4.00)- 凿œªè§¦å‘ (周高 $3.42 < $3.50)" was rejected with numeric_claim_conflict for+ Regression for the RXRX run: the draft "两档 GTC (100 @ $3.50 / 100 @ $4.00)+ 均未触发 (周高 $3.42 < $3.50)" was rejected with numeric_claim_conflict for100, 3.5 and 4.0 against the observed OHLC range. Order levels are levels,like targets/stops, and share counts are quantities - neither is a claimabout an observed quote.@@ -2226,7 +2228,7 @@ def test_order_level_prices_are_not_observed_quotes(tmp_path: Path) -> None:)ledger = GroundingLedger(run_dir=tmp_path,- user_message="è¯·åˆ†æž RXRX.US 并更新周报",+ user_message="请分析 RXRX.US 并更新周报",)ledger.ingest_tool_result(tool_name="search_symbol",@@ -2245,18 +2247,17 @@ def test_order_level_prices_are_not_observed_quotes(tmp_path: Path) -> None:)answer = (- "RXRX.US(yahoo,USD)本周高 $3.42。订å•: 两档 GTC (100 @ $3.50 / 100 @ $4.00) "- "凿œªè§¦å‘ (周高 $3.42 < $3.50) — ä»·æ ¼æŽ¨æ–æœªæˆäº¤ã€‚"+ "RXRX.US(yahoo,USD)本周高 $3.42。订单: 两档 GTC (100 @ $3.50 / 100 @ $4.00) "+ "均未触发 (周高 $3.42 < $3.50) — 价格推断未成交。")result = ledger.validate_final_answer(answer)assert result.valid is True, result.issues# A genuinely fabricated close is still rejected.fabricated = ledger.validate_final_answer(- "RXRX.US(yahoo,USD)本周高 $3.42。å¦: 收盘 2.50 已确认。"+ "RXRX.US(yahoo,USD)本周高 $3.42。另: 收盘 2.50 已确认。")assert fabricated.valid is Falseassert any(issue["code"] == "numeric_claim_conflict" for issue in fabricated.issues)-diff --git a/agent/tests/test_agent_loop_content_filter.py b/agent/tests/test_agent_loop_content_filter.pyindex c6a05fbfd..e9284ff55 100644--- a/agent/tests/test_agent_loop_content_filter.py+++ b/agent/tests/test_agent_loop_content_filter.py@@ -33,6 +33,8 @@ class _ContentFilterLoopLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> LLMResponse:self.calls += 1@@ -63,6 +65,8 @@ class _EmptyResponseLoopLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> LLMResponse:self.calls += 1@@ -202,6 +206,8 @@ def test_single_empty_response_recovers_with_nudge(tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> LLMResponse:self.calls += 1@@ -256,6 +262,8 @@ class _RatioFilterLoopLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> LLMResponse:self.calls += 1diff --git a/agent/tests/test_agent_loop_no_assistant_prefill.py b/agent/tests/test_agent_loop_no_assistant_prefill.pyindex 69cf2707d..66f003e6a 100644--- a/agent/tests/test_agent_loop_no_assistant_prefill.py+++ b/agent/tests/test_agent_loop_no_assistant_prefill.py@@ -44,6 +44,8 @@ class _StubLLM:tools: Any = None,on_text_chunk: Any = None,on_reasoning_chunk: Any = None,+ timeout: Any = None,+ idle_timeout_s: Any = None,should_cancel: Any = None,) -> Any:messages = [m for m in messages]diff --git a/agent/tests/test_agent_loop_stream_retry.py b/agent/tests/test_agent_loop_stream_retry.pyindex 79cb781f2..df742cbb9 100644--- a/agent/tests/test_agent_loop_stream_retry.py+++ b/agent/tests/test_agent_loop_stream_retry.py@@ -40,6 +40,8 @@ class _FlakyLoopLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> LLMResponse:"""Raise the next queued error or return the final response.diff --git a/agent/tests/test_agent_loop_terminal_state.py b/agent/tests/test_agent_loop_terminal_state.pyindex f18e6789c..3784f30b2 100644--- a/agent/tests/test_agent_loop_terminal_state.py+++ b/agent/tests/test_agent_loop_terminal_state.py@@ -45,6 +45,8 @@ class _StubLLMNoFinal:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:return _StubLLMResponse()@@ -62,6 +64,8 @@ class _StubLLMWithUsage:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:response = _StubLLMResponse()@@ -85,6 +89,8 @@ class _StubLLMSuccess:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:self.calls += 1@@ -112,6 +118,8 @@ class _StubLLMCancelMidStream:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:# Set _cancelled on the bound agent so the next loop iteration check@@ -213,6 +221,8 @@ class _StubLLMCancelWithToolCalls:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:self._agent_ref[0]._cancel_event.set()@@ -301,6 +311,8 @@ class _StubLLMAlwaysToolCalls:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:resp = _StubLLMResponse()@@ -328,6 +340,8 @@ class _StubLLMIgnoresForcedTextOnly:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:resp = _StubLLMResponse()@@ -348,6 +362,8 @@ class _StubLLMStreamFailure:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:raise ProviderStreamError(diff --git a/agent/tests/test_agent_loop_trace.py b/agent/tests/test_agent_loop_trace.pyindex 7e291de53..8fb2e785d 100644--- a/agent/tests/test_agent_loop_trace.py+++ b/agent/tests/test_agent_loop_trace.py@@ -97,6 +97,8 @@ class _LongAnswerLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _LongAnswerResponse:del messages, tools, on_reasoning_chunkdiff --git a/agent/tests/test_content_filter_e2e.py b/agent/tests/test_content_filter_e2e.pyindex 44d5e7fa3..2ec909cce 100644--- a/agent/tests/test_content_filter_e2e.py+++ b/agent/tests/test_content_filter_e2e.py@@ -49,6 +49,8 @@ class _InterleavedFilterLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> LLMResponse:self.calls += 1@@ -92,6 +94,8 @@ class _CleanRunLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> LLMResponse:self.calls += 1diff --git a/agent/tests/test_grounding_recovery.py b/agent/tests/test_grounding_recovery.pyindex d89a759e9..a1ea60c9a 100644--- a/agent/tests/test_grounding_recovery.py+++ b/agent/tests/test_grounding_recovery.py@@ -333,6 +333,8 @@ class _FailingDraftLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> LLMResponse:self.calls += 1diff --git a/agent/tests/test_reasoning_delta_throttle.py b/agent/tests/test_reasoning_delta_throttle.pyindex c18d518b0..df581b05a 100644--- a/agent/tests/test_reasoning_delta_throttle.py+++ b/agent/tests/test_reasoning_delta_throttle.py@@ -36,6 +36,8 @@ class _ReasoningBurstLLM:tools: list[Any] | None = None,on_text_chunk: Callable[[str], None] | None = None,on_reasoning_chunk: Callable[[str], None] | None = None,+ timeout: int | None = None,+ idle_timeout_s: float | None = None,should_cancel: Callable[[], bool] | None = None,) -> _StubLLMResponse:assert on_reasoning_chunk is not None