perf(reply): v2 tool turns get the tool guidance in short, and a shorter reply-language default
Strata reads every reply prompt from the start in 2,048-token steps. The v2 compact prompt carried v1's full tool guidance and constraints (about 900 Qwen3.6 tokens) on every turn with a data tool, and the reply-language default (about 120 tokens) twice. COMPACT_TOOL_GUIDANCE keeps the same rules (act instead of refusing, facts only from the result, look up named things, auto-derived and self-contained arguments) in about a quarter of the tokens, without English examples; the reply-language default says the same in half. v1's prompts are unchanged. Measured on Strata (Qwen3.6, 20 lines of recent conversation): a weather turn's prompt 3,436 -> 2,722 tokens, a search turn's second call 4,096 -> 3,383. Evals (compact prompt + intent judge, Qwen3.6): 24/24 before, 30/30 twice after (weather location, follow-up arguments, tool-skip confabulation, search language, reply language, Possessor fidelity, reply length, multi-turn context). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
Strata reads every prompt from the start, so prompt length is reply latency. Behaviour: the compact
|
||||
prompt is far shorter than v1's for the same turn, still carries the tool honesty rules and the
|
||||
reply-language default, and brings the full tool guidance only on turns that offer a data tool.
|
||||
reply-language default, and brings the (short) tool guidance only on turns that offer a data tool.
|
||||
"""
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
@@ -13,7 +13,9 @@ from src.jarvis.memory.conversation import DialogueMemory
|
||||
from src.jarvis.memory.history import HistoryContext
|
||||
from src.jarvis.reply.engine import run_reply_engine
|
||||
from src.jarvis.reply.prompts.model_variants import TOOL_CONSTRAINTS_LARGE
|
||||
from src.jarvis.system_prompt import COMPACT_ACTION_RULE, TOOL_HONESTY_RULES, default_language_directive
|
||||
from src.jarvis.system_prompt import (
|
||||
COMPACT_ACTION_RULE, COMPACT_TOOL_GUIDANCE, TOOL_HONESTY_RULES, default_language_directive,
|
||||
)
|
||||
|
||||
from tests.test_ollama_num_predict import _mock_cfg
|
||||
|
||||
@@ -46,11 +48,20 @@ def test_the_compact_prompt_is_far_shorter_and_keeps_the_rules(routed):
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_the_full_tool_guidance_comes_only_with_a_data_tool():
|
||||
def test_the_tool_guidance_comes_only_with_a_data_tool():
|
||||
chatty = _system_prompt(True, [])
|
||||
assert COMPACT_ACTION_RULE in chatty and TOOL_CONSTRAINTS_LARGE not in chatty
|
||||
assert COMPACT_ACTION_RULE in chatty and COMPACT_TOOL_GUIDANCE not in chatty
|
||||
weather = _system_prompt(True, ["getWeather"])
|
||||
assert TOOL_CONSTRAINTS_LARGE in weather and COMPACT_ACTION_RULE not in weather
|
||||
assert COMPACT_TOOL_GUIDANCE in weather and COMPACT_ACTION_RULE not in weather
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_a_data_tool_turn_gets_the_short_tool_guidance_not_v1s():
|
||||
# v1 keeps its full guidance; the compact prompt says the same rules in a fraction of it.
|
||||
assert TOOL_CONSTRAINTS_LARGE in _system_prompt(False, ["getWeather"])
|
||||
weather = _system_prompt(True, ["getWeather"])
|
||||
assert TOOL_CONSTRAINTS_LARGE not in weather
|
||||
assert len(COMPACT_TOOL_GUIDANCE) < len(TOOL_CONSTRAINTS_LARGE) / 2
|
||||
|
||||
|
||||
def _intent_turn(prepared, routed=("getWeather",), first=None):
|
||||
|
||||
Reference in New Issue
Block a user