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:
@@ -500,6 +500,39 @@ class TestMemoryEnrichment:
|
||||
assert not any("locat" in q or "where" in q for q in questions), \
|
||||
f"Should not ask about location when it's in context. Got: {questions}"
|
||||
|
||||
@pytest.mark.eval
|
||||
@requires_judge_llm
|
||||
def test_enrichment_asks_location_when_context_lacks_it(self, mock_config):
|
||||
"""
|
||||
Counterpart of the test above: when the live context has no location,
|
||||
a query that depends on where the user is still asks for it, so the
|
||||
memory lookup can find where the user said they live.
|
||||
"""
|
||||
from jarvis.reply.enrichment import extract_search_params_for_memory
|
||||
from helpers import JUDGE_MODEL
|
||||
|
||||
mock_config.ollama_base_url = JUDGE_BASE_URL
|
||||
mock_config.ollama_chat_model = JUDGE_MODEL
|
||||
|
||||
result = extract_search_params_for_memory(
|
||||
query="recommend a restaurant I'd enjoy",
|
||||
ollama_base_url=mock_config.ollama_base_url,
|
||||
ollama_chat_model=mock_config.ollama_chat_model,
|
||||
timeout_sec=15.0,
|
||||
context_hint=(
|
||||
"Current local time: Sunday, 2026-04-19 14:30 local. "
|
||||
"Location: Unknown"
|
||||
),
|
||||
)
|
||||
|
||||
questions = [q.lower() for q in result.get("questions", [])]
|
||||
print(f"\n📊 Questions without a location in context: {questions}")
|
||||
|
||||
assert result.get("keywords"), \
|
||||
f"Extractor returned no keywords. Result: {result}"
|
||||
assert any("locat" in q or "where" in q for q in questions), \
|
||||
f"Should ask where the user is when the context has no location. Got: {questions}"
|
||||
|
||||
@pytest.mark.eval
|
||||
def test_enrichment_provides_context_to_llm(self, mock_config, eval_db, eval_dialogue_memory):
|
||||
"""
|
||||
@@ -1030,24 +1063,27 @@ class TestHelpfulness:
|
||||
|
||||
is_small = detect_model_size(JUDGE_MODEL) == ModelSize.SMALL
|
||||
|
||||
call_count = {"n": 0}
|
||||
# Every call in turn 1 fails and every call in turn 2 succeeds. A
|
||||
# model that retries by itself inside turn 1 must not get the data
|
||||
# there, or turn 2 is answered from that result and the user's
|
||||
# "try again" is never tested.
|
||||
phase = {"turn": 1}
|
||||
|
||||
def mock_tool_run(db, cfg, tool_name, tool_args, **kwargs):
|
||||
"""First call returns error, second call succeeds."""
|
||||
"""Fails throughout turn 1, succeeds in turn 2."""
|
||||
from jarvis.tools.types import ToolExecutionResult
|
||||
capture.record(tool_name, tool_args or {})
|
||||
call_count["n"] += 1
|
||||
|
||||
if tool_name == "getWeather":
|
||||
if call_count["n"] <= 1:
|
||||
# First call: tool can't find the location
|
||||
if phase["turn"] == 1:
|
||||
# Turn 1: tool can't find the location
|
||||
return ToolExecutionResult(
|
||||
success=False,
|
||||
reply_text="",
|
||||
error_message="Could not find location 'Kazbegi'. Try a different spelling or a nearby city."
|
||||
)
|
||||
else:
|
||||
# Subsequent calls: tool succeeds
|
||||
# Turn 2: tool succeeds
|
||||
return ToolExecutionResult(
|
||||
success=True,
|
||||
reply_text="Current weather near Kazbegi (Stepantsminda), Georgia:\nConditions: Partly cloudy\nTemperature: 2.5°C\nWind: 25 km/h\n7-day: 2026-04-10: -1–5°C, Snow showers"
|
||||
@@ -1070,6 +1106,7 @@ class TestHelpfulness:
|
||||
|
||||
# Turn 2: User insists on retry — tool should succeed this time
|
||||
capture.clear()
|
||||
phase["turn"] = 2
|
||||
response = run_reply_engine(
|
||||
db=eval_db, cfg=mock_config, tts=None,
|
||||
text=follow_up,
|
||||
|
||||
Reference in New Issue
Block a user