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:
@@ -203,8 +203,11 @@ class WeatherTool(Tool):
|
||||
"Weather only (current + forecast). NOT for time-of-day, date, or "
|
||||
"location questions — those are already in the assistant's context. "
|
||||
"Use for ANY weather question: now, later today, tomorrow, this week. "
|
||||
"Call with {} — user location is auto-detected. Do NOT ask the user "
|
||||
"where they are or request a city; just call this tool with empty args."
|
||||
"Set location to the place the user asked about. If they named none, "
|
||||
"set it to where the user has said they are, from the conversation or "
|
||||
"what you remember about them. Otherwise leave it empty: the tool "
|
||||
"auto-detects the user's location (do not copy the detected location "
|
||||
"into it). Do NOT ask the user where they are; just call this tool."
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -214,7 +217,7 @@ class WeatherTool(Tool):
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "OPTIONAL. City name or location (e.g., 'London', 'New York', 'Tokyo'). Only set this if the user explicitly named a place different from their own location. If omitted, the tool auto-uses the user's current detected location — never ask the user for this argument."
|
||||
"description": "City name or location (e.g., 'London', 'New York', 'Tokyo'): the place the user asked about, or else where the user has said they are (the conversation or your memory of them). Omit otherwise; the tool then auto-detects the user's location. Never ask the user for this argument."
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
@@ -364,6 +367,20 @@ class WeatherTool(Tool):
|
||||
if geo_data.get("results"):
|
||||
location_str = romanised
|
||||
|
||||
# A "district, city, country" name (often the detected location
|
||||
# copied from the context) may not match as a whole. Retry
|
||||
# without the leading parts, narrowest area first.
|
||||
parts = [p.strip() for p in location_str.split(",") if p.strip()]
|
||||
for i in range(1, len(parts)):
|
||||
if geo_data.get("results"):
|
||||
break
|
||||
wider = ", ".join(parts[i:])
|
||||
debug_log(f" 🌤️ geocode empty; retrying wider area '{wider}'", "tools")
|
||||
geocode_params["name"] = wider
|
||||
geo_response = requests.get(geocode_url, params=geocode_params, timeout=10)
|
||||
geo_response.raise_for_status()
|
||||
geo_data = geo_response.json()
|
||||
|
||||
if not geo_data.get("results"):
|
||||
return ToolExecutionResult(
|
||||
success=False,
|
||||
@@ -442,8 +459,7 @@ class WeatherTool(Tool):
|
||||
|
||||
# The reply is the clean Korean sentence ONLY — no English/°C source
|
||||
# for the model to echo ("25도 Celsius"), no forecast firehose to
|
||||
# ramble over. The deterministic weather path in the engine returns
|
||||
# this verbatim; on the LLM path the model just echoes one sentence.
|
||||
# ramble over. The model just echoes this one sentence.
|
||||
lines = [ko_sentence]
|
||||
|
||||
reply_text = "\n".join(lines)
|
||||
|
||||
Reference in New Issue
Block a user