latest_prices: add include_expired passthrough for historical data
ag-monitor now drops expired delivery months from /api/data/latest by default (current + future only). Expose the opt-in through the MCP so the advisor can fetch past months when a farmer explicitly asks for history, while the default stays current + future. - client.latest(include_expired=False): forwards include_expired=true only when set (None is dropped), so the default query string is unchanged. - latest_prices tool: new include_expired arg with a description steering the model to set it only on an explicit historical request. Tests: client passthrough (default omits the param; opt-in forwards it). 43 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,30 @@ def test_get_drops_none_params(monkeypatch):
|
||||
assert captured["params"] == {"commodity": "corn"}
|
||||
|
||||
|
||||
def test_latest_include_expired_passthrough(monkeypatch):
|
||||
client = _reload_client(monkeypatch)
|
||||
captured = {}
|
||||
|
||||
class FakeResp:
|
||||
status_code = 200
|
||||
text = ""
|
||||
def json(self): return {"count": 0, "rows": []}
|
||||
|
||||
def fake_get(url, params=None, timeout=None, headers=None):
|
||||
captured["params"] = dict(params or {})
|
||||
return FakeResp()
|
||||
|
||||
monkeypatch.setattr(client.httpx, "get", fake_get)
|
||||
|
||||
# Default: not sent, so the API applies its current+future filter.
|
||||
client.latest(commodity="corn")
|
||||
assert "include_expired" not in captured["params"]
|
||||
|
||||
# Opt in: forwarded so the API returns expired months too.
|
||||
client.latest(commodity="corn", include_expired=True)
|
||||
assert captured["params"] == {"commodity": "corn", "include_expired": True}
|
||||
|
||||
|
||||
def test_futures_endpoint_params(monkeypatch):
|
||||
client = _reload_client(monkeypatch)
|
||||
captured = {}
|
||||
|
||||
Reference in New Issue
Block a user