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:
javis-bot
2026-11-11 21:55:45 +09:00
parent 4bb3895ca0
commit 3ec430fd25
15 changed files with 255 additions and 79 deletions

View File

@@ -194,6 +194,32 @@ class TestPlanQuery:
)
assert steps == ["Reply to user."]
def test_planner_sees_live_context(self):
"""The planner is told what the live context knows (time, location),
so it can plan a memory lookup for a fact about the user, such as
where they are, only when the live context lacks it."""
cfg = _cfg()
with patch.object(
planner_mod, "call_llm_direct", return_value="Reply to user."
) as llm:
plan_query(
cfg,
"how is the weather today",
"",
[("getWeather", "Weather. (args: location)")],
live_context="Current local time: Monday 09:00. Location: Unknown",
)
assert "Location: Unknown" in llm.call_args.kwargs["user_content"]
def test_prompt_plans_memory_for_user_facts_missing_from_live_context(self):
"""The prompt must tie the searchMemory directive to a user fact
(where they are) that the live context does not give, so a
location-dependent tool still gets the user's place from memory
when auto-detection is off."""
prompt = planner_mod._PROMPT_TEMPLATE
assert "LIVE CONTEXT" in prompt
assert "Location: Unknown" in prompt
def test_prompt_warns_against_fabricating_optional_arguments(self):
"""The planner prompt must explicitly tell the model to omit
optional arguments when the user didn't supply a value, and warn