mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 10:08:46 +02:00
Agent: add get_daily_spending for day-scoped questions
Prod showed the failure mode after the date fix: get_current_date returned the right day, but the model answered "¿cuánto he gastado hoy?" from cycle-level aggregates (the only spend tools it had) and concluded ₡0. Give it a day-grained tool — per-day CRC totals mirroring /analytics/daily-spending (COMPRA only, no installment anchors, no future cuotas) — and a prompt rule to match tool to time grain. Verified: fresh thread now calls get_current_date → get_daily_spending(2026-07-04, 2026-07-05) and answers correctly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -183,3 +183,34 @@ def test_get_current_date_is_costa_rica_and_cycle_consistent():
|
||||
start, end = out["cycle_range"]
|
||||
assert start <= out["date"] < end
|
||||
assert start.endswith("-18") and end.endswith("-18")
|
||||
|
||||
|
||||
def test_daily_spending_day_scoped(bound_session):
|
||||
from datetime import timedelta
|
||||
|
||||
from app.timeutil import today_cr
|
||||
|
||||
today = datetime.combine(today_cr(), datetime.min.time())
|
||||
bound_session.add(
|
||||
Transaction(amount=Decimal("100"), merchant="TODAY-A", date=today.replace(hour=9))
|
||||
)
|
||||
bound_session.add(
|
||||
Transaction(amount=Decimal("50"), merchant="TODAY-B", date=today.replace(hour=15))
|
||||
)
|
||||
bound_session.add(
|
||||
Transaction(
|
||||
amount=Decimal("999"),
|
||||
merchant="FUTURE CUOTA",
|
||||
date=today + timedelta(days=40),
|
||||
)
|
||||
)
|
||||
bound_session.commit()
|
||||
|
||||
out = tools.get_daily_spending(
|
||||
start_date=today.date().isoformat(),
|
||||
end_date=(today.date() + timedelta(days=60)).isoformat(),
|
||||
)
|
||||
assert len(out) == 1
|
||||
assert out[0]["date"] == today.date().isoformat()
|
||||
assert out[0]["total_crc"] == 150.0
|
||||
assert out[0]["count"] == 2
|
||||
|
||||
Reference in New Issue
Block a user