"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(agent): report DSL-withheld answers with accurate degraded reason
Will Liaoc9bbc5698f77
diff --git a/agent/src/agent/loop.py b/agent/src/agent/loop.pyindex 6be612c2d..88ae5d6b7 100644--- a/agent/src/agent/loop.py+++ b/agent/src/agent/loop.py@@ -780,6 +780,7 @@ class AgentLoop:self._has_run = Falseself._grounding: GroundingLedger | None = Noneself._released_fallback = False+ self._released_fallback_reason: str | None = Noneself._written_files: set[str] = set()def cancel(self) -> None:@@ -869,6 +870,7 @@ class AgentLoop:self._called_ok = set()self._previous_summary = ""self._released_fallback = False+ self._released_fallback_reason = Noneself._written_files = set()run_started_wall = _time.time()@@ -1281,6 +1283,10 @@ class AgentLoop:"Please ask me to continue.")self._released_fallback = True+ self._released_fallback_reason = (+ "final answer withheld: it contained tool-call syntax on "+ "the forced-text iteration"+ )self._emit("text_delta",{"delta": final_content, "iter": current_iter},@@ -1502,7 +1508,7 @@ class AgentLoop:state_store.mark_success(run_dir)final_status = "success"if self._released_fallback:- final_reason = (+ final_reason = self._released_fallback_reason or ("final answer degraded to the deterministic fallback after "f"{self._grounding.validation_count if self._grounding else 0} ""rejected drafts could not be corrected within the iteration budget"diff --git a/agent/src/tools/bash_tool.py b/agent/src/tools/bash_tool.pyindex 4c82b1e4d..dbd50cd18 100644--- a/agent/src/tools/bash_tool.py+++ b/agent/src/tools/bash_tool.py@@ -3,6 +3,7 @@from __future__ import annotationsimport json+import reimport subprocessfrom typing import Any@@ -21,7 +22,9 @@ class BashTool(BaseTool):"Execute a shell command in the working directory. On Windows the ""shell is cmd.exe, not PowerShell. Use for installing packages, ""running scripts, or inspecting files. Never kill Python processes "- "by name; stop a background_run task with cancel_background."+ "by name; stop a background_run task with cancel_background. "+ "Heredocs (<<) are NOT supported on cmd.exe - write your script to "+ "a file with write_file first, then run it (e.g. python script.py).")parameters = {"type": "object",@@ -50,6 +53,25 @@ class BashTool(BaseTool):{"status": "error", "error": safety_error},ensure_ascii=False,)+ # cmd.exe has no heredocs; return a clear message instead of the+ # cryptic "<< was unexpected at this time." stderr. Only multi-line+ # commands with a heredoc delimiter are flagged, so a single-line+ # bit shift (python -c "print(1 << 2)") is unaffected.+ if "\n" in command and re.search(+ r"<<\s*['\"]?[A-Za-z_][A-Za-z0-9_]*", command+ ):+ return json.dumps(+ {+ "status": "error",+ "error_code": "heredoc_unsupported",+ "message": (+ "Heredoc syntax (<<) is not supported on Windows cmd.exe. "+ "Write your script to a file first (write_file), then run "+ "it, e.g. python path\\to\\script.py."+ ),+ },+ ensure_ascii=False,+ )try:result = subprocess.run(