fix(reply): known user location reaches getWeather; retries are not blocked by the previous reply
- Drop the engine's deterministic Korean weather shortcut. It bypassed the chat model and the tool runner, so a location the user had stated could never be used. The tool already returns one clean Korean sentence. - getWeather and the tool-argument prompts pass the place the user has said they are (conversation or memory) and leave the argument empty otherwise, so the detected location is not copied into it. - getWeather retries a "district, city, country" name with its leading parts dropped when the geocoder finds nothing. - The planner gets the live time/location line and plans searchMemory topic='where the user lives' only when the location is unknown or disabled. - The per-reply repeat guard counts only this reply's tool messages, so calls carried over from the previous reply no longer block a retry the user asks for. - Memory extractor: the context block sits after the examples and the no-location example uses a different query, so a location already in context is not asked for again. New counterpart eval checks that it is still asked for when the context has none. - Tool retry eval fails every call in turn 1, so a model that retries by itself inside turn 1 still exercises the user's "try again". - Specs (planner, reply), docs/llm_contexts.md and the roadmap updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -163,6 +163,40 @@ class TestWeatherTool:
|
||||
# The romanised name must be what the second geocode actually queried.
|
||||
assert mock_get.call_args_list[1].kwargs["params"]["name"] == "Seoul"
|
||||
|
||||
@patch('requests.get')
|
||||
def test_run_comma_place_falls_back_to_wider_area(self, mock_get):
|
||||
"""A "district, city, country" name the geocoder can't match is retried
|
||||
without its leading parts, so a location taken from the context (e.g.
|
||||
a detected "Gangnam-gu, Seoul, South Korea") still gets weather."""
|
||||
known = {
|
||||
"Seoul, South Korea": {
|
||||
"latitude": 37.566, "longitude": 126.9784,
|
||||
"name": "Seoul", "country": "South Korea", "admin1": "Seoul",
|
||||
},
|
||||
}
|
||||
|
||||
def fake_get(url, params=None, timeout=None):
|
||||
resp = Mock()
|
||||
resp.raise_for_status = Mock()
|
||||
if "geocoding" in url:
|
||||
place = known.get(params["name"])
|
||||
resp.json.return_value = {"results": [place]} if place else {}
|
||||
else:
|
||||
resp.json.return_value = {
|
||||
"current": {
|
||||
"temperature_2m": 12.0, "apparent_temperature": 11.0,
|
||||
"weather_code": 0,
|
||||
},
|
||||
}
|
||||
return resp
|
||||
|
||||
mock_get.side_effect = fake_get
|
||||
|
||||
result = self.tool.run({"location": "Gangnam-gu, Seoul, South Korea"}, self.context)
|
||||
|
||||
assert result.success is True
|
||||
assert "Seoul" in result.reply_text
|
||||
|
||||
def test_romanise_place_skips_ascii_names(self):
|
||||
"""ASCII names already geocode, so no LLM round-trip is spent on them."""
|
||||
cfg = Mock()
|
||||
|
||||
Reference in New Issue
Block a user