Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(agent): name rejected values in correction prompt; DSL reason; heredoc hint

Will Liaoa3f6b9df4be9
diff --git a/agent/src/agent/grounding.py b/agent/src/agent/grounding.py
index 8a094bb65..173665ef7 100644
--- a/agent/src/agent/grounding.py
+++ b/agent/src/agent/grounding.py
@@ -1232,12 +1232,44 @@ class GroundingLedger:
]
for issue in validation.issues[:12]:
lines.append(f"- {issue.get('message', issue.get('code', 'grounding error'))}")
+ # Name the exact values that must be REMOVED, not rephrased. The model
+ # tends to restate a rejected figure in a new format; the gate then
+ # rejects it again and the run burns iterations until the fallback.
+ banned: list[str] = []
+ for issue in validation.issues:
+ code = issue.get("code")
+ value = issue.get("value")
+ if code in {"numeric_claim_conflict", "numeric_claim_unavailable", "unsourced_symbol_figures"} and value is not None:
+ symbol = issue.get("symbol") or ""
+ label = f"{value:g}" if isinstance(value, (int, float)) else str(value)
+ banned.append(f"{label} ({symbol})" if symbol else label)
+ if banned:
+ deduped = list(dict.fromkeys(banned))
+ lines.append(
+ "REMOVE these rejected value(s) entirely - do NOT restate, rephrase, "
+ "or recompute them in any other format: " + ", ".join(deduped) + "."
+ )
+ repeated: list[str] = []
+ for prior in self._validations:
+ for prior_issue in prior.get("issues", []):
+ prior_value = prior_issue.get("value")
+ if isinstance(prior_value, (int, float)):
+ mark = f"{prior_value:g}"
+ if any(entry.startswith(mark) for entry in deduped):
+ repeated.append(mark)
+ if repeated:
+ lines.append(
+ "These value(s) have now been rejected repeatedly across drafts: "
+ + ", ".join(dict.fromkeys(repeated))
+ + ". Repeating them in any form keeps failing; drop them, or show "
+ "the full derivation from the observed inputs."
+ )
lines.extend(
[
- "Remove or reword every rejected claim above instead of repeating it; an",
- "unsupported figure in a table row invalidates the whole draft.",
+ "If a value is a derived or prospective level (stop, target, entry, etc.), "
+ "you must EITHER show the full derivation with the observed inputs and the "
+ "formula, OR omit it from the draft.",
"Reuse the exact locked symbol and venue.",
- "For every derived number, label it as derived and show the source inputs and formula.",
"Do not attach figures to a symbol no tool call in this session handled; "
"report it as not retrieved instead.",
]
diff --git a/agent/tests/artifacts/grounding_evidence.json b/agent/tests/artifacts/grounding_evidence.json
index 3ab748489..79ad2bc83 100644
--- a/agent/tests/artifacts/grounding_evidence.json
+++ b/agent/tests/artifacts/grounding_evidence.json
@@ -1,8 +1,26 @@
{
"evidence": [],
"identity": {
- "authorized_symbols": [],
- "records": [],
+ "authorized_symbols": [
+ "META.TO"
+ ],
+ "records": [
+ {
+ "candidates": [],
+ "currency": "CAD",
+ "instrument_type": "listed_security",
+ "query": "META.TO",
+ "source": [
+ "user_message"
+ ],
+ "source_tool_call_id": "user_message",
+ "status": "locked",
+ "symbol": "META.TO",
+ "updated_at": "2026-08-15T19:03:44.293010Z",
+ "venue": "toronto",
+ "version": 1
+ }
+ ],
"recovery": {
"max_price_evidence_attempts": 3,
"max_rounds": 6,
@@ -11,12 +29,14 @@
"rounds": 0,
"symbol_resolution_attempts": 0
},
- "status": "not_required"
+ "status": "locked"
},
"schema_version": 1,
"session_symbol_roots": [],
- "session_symbols": [],
+ "session_symbols": [
+ "META.TO"
+ ],
"tool_failures": [],
- "updated_at": "2026-08-15T18:15:36.590075Z",
+ "updated_at": "2026-08-15T19:03:44.293226Z",
"validations": []
}