Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(grounding): preserve generic evidence timestamps

Lanre Shittu875ff9084c95
diff --git a/agent/src/agent/grounding.py b/agent/src/agent/grounding.py
index 8ae4adf06..d13969f46 100644
--- a/agent/src/agent/grounding.py
+++ b/agent/src/agent/grounding.py
@@ -1968,8 +1968,9 @@ class GroundingLedger:
)
source = str(payload.get("source") or tool_name)
remaining = _MAX_GENERIC_EVIDENCE
+ timestamp_fields = (*_TIMESTAMP_FIELDS, "as_of")
- def visit(value: Any, path: str) -> None:
+ def visit(value: Any, path: str, timestamp: str | None = None) -> None:
nonlocal remaining
if remaining <= 0:
return
@@ -1980,7 +1981,7 @@ class GroundingLedger:
tool=tool_name,
symbol=symbol,
source=source,
- timestamp=None,
+ timestamp=timestamp,
field=path or "value",
value=value,
status="observed",
@@ -1991,11 +1992,25 @@ class GroundingLedger:
remaining -= 1
return
if isinstance(value, dict):
+ local_timestamp = next(
+ (
+ str(value[key])
+ for key in timestamp_fields
+ if value.get(key) is not None
+ ),
+ timestamp,
+ )
for key, item in value.items():
- visit(item, f"{path}.{key}" if path else str(key))
+ if str(key).casefold() in timestamp_fields:
+ continue
+ visit(
+ item,
+ f"{path}.{key}" if path else str(key),
+ local_timestamp,
+ )
elif isinstance(value, list):
for index, item in enumerate(value):
- visit(item, f"{path}[{index}]")
+ visit(item, f"{path}[{index}]", timestamp)
visit(payload, "")