MT5 broker symbols (e.g. XAUUSD) can never be locked by `search_symbol`, so the identity gate blocks `trading_quote` / `trading_history` / `get_market_data` and rejects backtest answers

Author: mrgfx303Created Sep 25, 2026Updated Sep 25, 2026

Environment: vibe-trading-ai 0.1.15 (pip), Windows Server 2022, Python 3.12, MetaTrader5 5.0.6180, profile mt5-paper-sdk against an Exness MT5 demo account. trading_check succeeds.

What happens Asking the agent for an XAUUSD quote fails instantly (0 ms, "blocked": true):

trading_quote {"symbol":"XAUUSD","connection":"mt5-paper-sdk"}
-> error_code "identity_required": "A canonical, non-conflicting identity was not locked
   before this assistant tool-call batch started. ..."

The agent then calls search_symbol, which returns no candidates for every spelling tried (XAUUSD, XAU/USD, XAUUSD=X, XAUUSD.FX):

{"ok": true, "data": {"query": "XAUUSD=X", "count": 0, "candidates": [],
 "sources": {"eastmoney": "eastmoney search failed: Expecting value: line 1 column 1 (char 0)", "yahoo": "ok"}}}

From then on identity is invalidated, every symbol-taking tool is blocked with identity_conflict, and every final answer is rejected with identity_not_locked, including after the user confirms the symbol and venue.

Root cause (0.1.15)

  • src/agent/grounding.py: _RESOLVER_TOOL = "search_symbol" is the only way to lock identity, and any tool with a code/codes/symbol/symbols/ticker/tickers/underlying/underlyings argument is gated (31 tools, including get_market_data, trading_history, trading_quote, technical_indicators).
  • src/tools/symbol_search_tool.py::_search_selected_connector only resolves against the selected connector when it is binance (crypto pairs). An mt5 profile gets no broker-side resolution.
  • src/market_data.canonical_fx_pair returns None for XAUUSD / XAU/USD / XAUUSD=X (metals are not treated as FX pairs), while EURUSD maps to EURUSD=X.
  • Meanwhile the data layer does support these symbols: src/market_data.py routes XAU/USD and XAUUSD.FX to mt5, and backtest/loaders/mt5_loader.py::_resolve_broker_symbol already maps them to the broker's name via symbol_info / symbols_get.

Impact: With an MT5 connector, broker-only instruments (metals, CFDs, broker-suffixed FX) cannot be quoted, fetched or charted by the agent. A backtest on them can run, but its answer is rejected once the agent has called search_symbol. Reproduced offline by driving GroundingLedger directly with the empty search_symbol payload above.

Expected: When the selected profile's connector is mt5, search_symbol should be able to return a lockable candidate that the terminal confirms exists.

Suggested fix: Mirror the Binance path. In _search_selected_connector, when profile.connector == "mt5", resolve the query through the connector (reusing the symbol_info / symbols_get(group=f"{base}*") logic in mt5_loader._resolve_broker_symbol) and return candidates carrying the broker symbol and venue. Optionally, also recognise XAU/XAG/XPT/XPD in canonical_fx_pair.