Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix: swarm template variable fallback and frontend timeout reset

warren61859fb021c5863
diff --git a/README.md b/README.md
index 24300363c..f78cb7792 100644
--- a/README.md
+++ b/README.md
@@ -51,13 +51,12 @@
## πŸ“° News
-- **2026-04-13** 🌐 **Cross-Market Composite Backtest**: New `CompositeEngine` enables backtesting portfolios that span multiple markets (e.g. A-shares + crypto) in a single run with a **shared capital pool**. Per-market rules (T+1, funding fees, swap) enforced per symbol, signals aligned on each symbol's own trading calendar. Use `source: "auto"` with mixed codes like `["000001.SZ", "BTC-USDT"]`. Includes volatility-adjusted weighting skill and calendar-day annualization for accurate cross-market Sharpe.
+- **2026-04-13** 🌐 **Cross-Market Composite Backtest & Swarm Fixes**: New `CompositeEngine` enables backtesting portfolios that span multiple markets (e.g. A-shares + crypto) in a single run with a **shared capital pool**. Per-market rules (T+1, funding fees, swap) enforced per symbol, signals aligned on each symbol's own trading calendar. Use `source: "auto"` with mixed codes like `["000001.SZ", "BTC-USDT"]`. Also fixed two Swarm bugs: preset prompt templates with missing variables (e.g. `{market}`, `{target}`) now auto-infer from context instead of crashing workers; frontend safety timeout no longer kills swarm runs prematurely.
- **2026-04-12** 🌍 **Multi-Platform Indicator Export**: `/pine` now exports strategies to **TradingView (Pine Script v6)**, **ι€šθΎΎδΏ‘/同花鑺/δΈœζ–Ήθ΄’ε―Œ (TDX formula)**, and **MetaTrader 5 (MQL5)** in a single file β€” covering international equities, China A-shares, and global forex/CFD markets. One command, three platforms.
- **2026-04-11** πŸ›‘οΈ **Reliability & DX**: `vibe-trading init` interactive .env bootstrap ([#19](https://github.com/HKUDS/Vibe-Trading/pull/19)), startup preflight checks for LLM & data sources, runtime data-source fallback when primary returns empty, hardened backtest engine with data validation & error isolation, date/time context injection into agent & swarm prompts. Multi-language README (zh/ja/ko) via community PR [#21](https://github.com/HKUDS/Vibe-Trading/pull/21).
- **2026-04-10** πŸ“¦ **v0.1.4**: Fix Docker build ([#8](https://github.com/HKUDS/Vibe-Trading/issues/8)), add `web_search` MCP tool (17 total), `akshare`/`ccxt` in deps & MCP. 11 LLM providers (DeepSeek, Groq, Gemini, Ollama, etc.), all tuning params via `.env`. Hardened `ml-strategy` skill. Published to PyPI and ClawHub.
- **2026-04-09** πŸ“Š **Backtest Wave 2 β€” multi-asset engines**: added ChinaFutures (CFFEX/SHFE/DCE/ZCE, 50+ contracts), GlobalFutures (CME/ICE/Eurex, 30+ contracts), Forex (24 pairs, spread + swap), Options v2 (American exercise, IV smile). Statistical validation: Monte Carlo permutation test, Bootstrap Sharpe CI, Walk-Forward analysis.
- **2026-04-08** πŸ”§ **Multi-market backtest** with per-market rules; **Pine Script v6 export** for TradingView. **Data source expansion**: 5 sources with auto-fallback, `web_search` tool, skill categorization (7 categories).
-- **2026-04-01** πŸš€ **v0.1.0** β€” Initial release: ReAct agent, 64 skills, 29 swarm presets, cross-market backtest, CLI + Web UI + MCP server.
---
diff --git a/agent/src/swarm/worker.py b/agent/src/swarm/worker.py
index 56fd22ed3..8a034735c 100644
--- a/agent/src/swarm/worker.py
+++ b/agent/src/swarm/worker.py
@@ -227,11 +227,18 @@ def run_worker(
skill_desc = _filter_skill_descriptions(skills_loader, agent_spec.skills)
system_prompt = build_worker_prompt(agent_spec, upstream_summaries, skill_desc)
- # 4. Resolve prompt template with user vars
+ # 4. Resolve prompt template with user vars (missing vars β†’ LLM infers)
+ class _FallbackDict(dict):
+ """Dict that hints LLM to infer missing template variables."""
+ def __missing__(self, key: str) -> str:
+ return f"(determine the appropriate {key} based on the objective)"
+
+ template_vars = _FallbackDict(user_vars)
+
try:
- user_prompt = task.prompt_template.format(**user_vars)
- except KeyError as exc:
- error_msg = f"Missing variable in prompt template: {exc}"
+ user_prompt = task.prompt_template.format_map(_FallbackDict(template_vars))
+ except (KeyError, ValueError) as exc:
+ error_msg = f"Failed to render prompt template: {exc}"
_emit(event_callback, "worker_failed", agent_id, task_id, {"error": error_msg})
return WorkerResult(
status="failed", summary="", iterations=0, error=error_msg,
diff --git a/frontend/src/pages/Agent.tsx b/frontend/src/pages/Agent.tsx
index b59254807..7a073605d 100644
--- a/frontend/src/pages/Agent.tsx
+++ b/frontend/src/pages/Agent.tsx
@@ -330,7 +330,7 @@ export function Agent() {
return dash.agents[agentId];
};
- const flush = () => { swarmDashRef.current = dash; setSwarmDash({ ...dash }); scrollToBottom(); };
+ const flush = () => { lastEventRef.current = Date.now(); swarmDashRef.current = dash; setSwarmDash({ ...dash }); scrollToBottom(); };
try {
const result = await api.createSwarmRun(presetName, { goal: prompt });