perf(llm): short one-shot calls say so to Strata

Every call that no later request continues (call_llm_direct,
call_llm_streaming, the warm-up and the v1 intent judge) now sends
"strata_checkpoint": false on the OpenAI-compatible path. Strata's
Qwen3.6 engine then gives that call's session away first, so with two or
more requests at once a reply's tool turn keeps its session through the
short calls made between its steps. The reply loop's chat_with_messages
is not marked (its next step continues it); the Ollama API gets no new
field. With one request at once nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-17 07:06:25 +09:00
parent 07615ee7a1
commit 8c61d7a821
4 changed files with 50 additions and 4 deletions

View File

@@ -231,3 +231,41 @@ def test_dictation_clean_up_uses_chat_completions():
out = _llm_clean_dictation("um hello there", V1, model="qwen")
assert out == "hello there"
assert post.call_args.args[0] == f"{V1}/chat/completions"
# One-shot calls (docs/llm_contexts.md, transport note): a call no later request continues says so
# ("strata_checkpoint": false), so Strata gives its session away first and a reply's tool turn keeps
# its own session through the short calls made between its steps.
def test_short_calls_are_marked_one_shot():
from jarvis.listening.intent_judge import IntentJudge, IntentJudgeConfig, warm_up_ollama_model
from jarvis.listening.transcript_buffer import TranscriptSegment
answer = json.dumps({"directed": True, "query": "q", "stop": False, "confidence": "high", "reasoning": "r"})
seg = TranscriptSegment(text="jarvis q", start_time=1.0, end_time=2.0)
calls = {
"direct": lambda: call_llm_direct(V1, "qwen", "s", "u"),
"streaming": lambda: call_llm_streaming(V1, "qwen", "s", "u"),
"warm-up": lambda: warm_up_ollama_model(V1, "qwen", timeout=5),
"intent judge": lambda: IntentJudge(IntentJudgeConfig(ollama_base_url=V1, model="qwen")).judge([seg], wake_timestamp=1.0),
}
for name, call in calls.items():
resp = _sse({"choices": [{"delta": {"content": "x"}}]}) if name == "streaming" else _response(_completion(answer))
with patch("jarvis.llm.requests.post", return_value=resp) as post:
call()
assert post.call_args.kwargs["json"].get("strata_checkpoint") is False, name
def test_the_reply_loop_is_not_marked_one_shot():
# its next step continues this one, so its session must be kept
with patch("jarvis.llm.requests.post", return_value=_response(_completion("ok"))) as post:
chat_with_messages(V1, "qwen", [{"role": "user", "content": "hi"}],
tools=[{"type": "function", "function": {"name": "getWeather"}}])
assert "strata_checkpoint" not in post.call_args.kwargs["json"]
def test_ollama_api_gets_no_one_shot_field():
with patch("jarvis.llm.requests.post", return_value=_response({"message": {"content": "ok"}})) as post:
call_llm_direct("http://127.0.0.1:11434", "m", "s", "u")
assert "strata_checkpoint" not in post.call_args.kwargs["json"]