Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(grounding): preserve pipes in field refs

zeus229464689f464e5
diff --git a/agent/src/agent/grounding/figures.py b/agent/src/agent/grounding/figures.py
index 861540556..6dbfc1d35 100644
--- a/agent/src/agent/grounding/figures.py
+++ b/agent/src/agent/grounding/figures.py
@@ -643,12 +643,12 @@ def parse_figures_block(content: str) -> FiguresBlock:
stripped = line.strip().replace("|", "|")
if not stripped:
continue
- parts = stripped.split("|")
+ # Four logical columns; a literal pipe may belong to the ref itself.
if stripped.startswith("|"):
- parts = parts[1:]
- if len(parts) > 1 and stripped.endswith("|"):
- parts = parts[:-1]
- parts = [part.strip() for part in parts]
+ stripped = stripped[1:].lstrip()
+ if stripped.endswith("|"):
+ stripped = stripped[:-1].rstrip()
+ parts = [part.strip() for part in stripped.split("|", 3)]
if _is_header_or_rule(parts):
continue
parsed = _parse_value(parts[0], document_reading) if parts else None
diff --git a/agent/tests/test_grounding_figures_ref_parser.py b/agent/tests/test_grounding_figures_ref_parser.py
new file mode 100644
index 000000000..edc67d3c2
--- /dev/null
+++ b/agent/tests/test_grounding_figures_ref_parser.py
@@ -0,0 +1,15 @@
+"""Regression coverage for figures refs containing provider call-id separators."""
+
+from src.agent.grounding.figures import parse_figures_block
+
+
+def test_figures_ref_keeps_pipe_inside_call_id() -> None:
+ block = parse_figures_block(
+ "```figures\n"
+ "2.96% | observed | VaR 95% | call_alpha|fc_beta::data.tail_risk.var_95\n"
+ "```"
+ )
+
+ assert block.malformed == ()
+ assert len(block.declarations) == 1
+ assert block.declarations[0].ref == "call_alpha|fc_beta::data.tail_risk.var_95"