fix(reply): stop models answering past an available tool
M0 on Strata caught both v2 models skipping a tool they had been given: the recommended model made up "24 degrees, sunny" instead of calling the weather tool, and the fast model said "timer set" without calling the timer tool (3 of 3 each). qwen2.5:7b does the same through the engine. - Prompt: TOOL_HONESTY_RULES in the persona (live facts only from a tool result this turn, actions only claimed after a tool reports success, no answer text next to a tool call), restated at the end of the system message by tool_honesty_reminder() with the turn's real tool names. - Engine: skipped-tool guard. When a native-tool model answers before any tool has run and the plan names a callable tool as a concrete call, the answer is dropped and the plan steps are direct-executed, then the model answers from the results. Only literal, schema-valid steps run (regex fast path, no LLM repair); otherwise the held-back answer is delivered. - Planner: the AVAILABLE TOOLS lines now carry argument names (planner_tool_catalog), so concrete steps use the tool's real keys. - Eval evals/test_tool_skip_confabulation.py; on qwen2.5:7b, 3 runs each, available-tool cases went from 0/12 to 9/12 calling the tool. - M0 kit: tools_fast / tools_recommended stages (run_m0_tools.bat) rerun tool calling before and after the fix on the real models, loading the production system_prompt.py and planner.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ Every distinct LLM call in Jarvis, what feeds it, what consumes it, and how it i
|
||||
- Redacted user query
|
||||
- Recent dialogue (last 5 minutes), including in-loop tool-call + tool-role messages from prior replies within the active conversation (tool carryover, `DialogueMemory.record_tool_turn` / `get_recent_turns_with_tools` in [src/jarvis/memory/conversation.py](src/jarvis/memory/conversation.py); per-prompt cap via `cfg.tool_carryover_max_turns` / `tool_carryover_per_entry_chars`; storage cap `_tool_turns_max_storage = 16`; cleared on `stop` signal AND on new-conversation entry; UNTRUSTED WEB EXTRACT fence markers preserved on truncation; both `content` and `tool_calls[*].function.arguments` scrubbed on write)
|
||||
- Unified system prompt from [src/jarvis/system_prompt.py](src/jarvis/system_prompt.py) + ASR note + tool-protocol guidance. Reply language is resolved by `reply_language_directive(lang, cfg.tts_engine)` where `lang = _resolve_output_language()` — the single source of truth that prefers the settings-web UI value (config JSON `output_language`) over the compose `OUTPUT_LANGUAGE` env, so changing the language in the settings page takes effect. An explicit lock wins (forces "reply only in `<language>`", also forbidding other scripts so small models stop leaking trailing CJK/Hanja); else a Piper/Chatterbox TTS forces English (English-only voices); else (multilingual TTS, no lock) the assistant replies in the user's own language. The directive is inserted near the FRONT of the guidance list so a small model gives it primacy, and the SAME resolved `lang` feeds `build_system_prompt()`, which rewrites the persona's "in the user's language" clause to the locked language so the persona cannot contradict the directive (previously the persona read the raw env while the directive read the config value, so a settings-UI change was honoured by one and ignored by the other). Gated in `_build_initial_system_message()` at [engine.py](src/jarvis/reply/engine.py).
|
||||
- **Tool honesty rules**: `TOOL_HONESTY_RULES` inside the persona, plus `tool_honesty_reminder(allowed_tools)` appended after every context block (just before the closing reply-language lock) naming the turn's tools. Added after M0 (2026-11-10) caught models answering past an available tool.
|
||||
- **Operator instructions** (two sources, both framed "Additional instructions from the operator:" and appended near the end of the guidance list): the settings-UI `llm_instructions` config field, and every `*.md` file in `AGENTS_DIR` (default `/app/agents`, bind-mounted from `./agents`). The file-based set is read once per turn by `load_agent_instructions()` in [src/jarvis/system_prompt.py](src/jarvis/system_prompt.py) and concatenated in filename order, so dropping/editing a `.md` applies on the next reply with no rebuild/restart; fail-open to `""` when the folder is absent/empty/unreadable.
|
||||
- **Warm profile block** (query-agnostic User + Directives excerpt from the knowledge graph, composed by `build_warm_profile()` / `format_warm_profile_block()` in [src/jarvis/memory/graph_ops.py](src/jarvis/memory/graph_ops.py) at Step 3.5 of `reply()`; no LLM call, pure SQLite read; injected unconditionally so personalisation is the default; result cached in `DialogueMemory._hot_cache` under `DialogueMemory.WARM_PROFILE_CACHE_KEY` for the lifetime of the active conversation. Invalidated on `stop`, on new-conversation entry, AND on User/Directives graph mutations via the listener registered in [src/jarvis/daemon.py](src/jarvis/daemon.py) against `register_graph_mutation_listener` in [src/jarvis/memory/graph.py](src/jarvis/memory/graph.py); World-branch writes are ignored)
|
||||
- Digested memory enrichment (optional, see #4)
|
||||
@@ -153,7 +154,7 @@ Every distinct LLM call in Jarvis, what feeds it, what consumes it, and how it i
|
||||
- **File**: [src/jarvis/reply/planner.py](src/jarvis/reply/planner.py) — `plan_query()`.
|
||||
- **Trigger**: once per reply, **after the tool router and before memory search**. Skipped when `cfg.planner_enabled = False`, when the query is shorter than `MIN_QUERY_CHARS` (4), or when no model / base URL is available.
|
||||
- **Model / gating**: resolution chain `planner_model (override) → ollama_chat_model`. The planner tracks the chat model so upgrading the chat model (via setup wizard or config) automatically upgrades plan quality.
|
||||
- **Inputs**: user query, dialogue context, **router-narrowed** tool catalogue (names + one-line descriptions) — not the full 30+ list. When the carry-over guard from #7 fires, the previous turn's failed tool name is unioned into this catalogue before the planner sees it, so the planner can plan a re-call without `toolSearchTool` round-tripping. **No** memory context — the planner decides *whether* memory is needed.
|
||||
- **Inputs**: user query, dialogue context, **router-narrowed** tool catalogue (names + one-line descriptions + argument names, built by `planner_tool_catalog()`) — not the full 30+ list. When the carry-over guard from #7 fires, the previous turn's failed tool name is unioned into this catalogue before the planner sees it, so the planner can plan a re-call without `toolSearchTool` round-tripping. **No** memory context — the planner decides *whether* memory is needed.
|
||||
- **System prompt**: `_PROMPT_TEMPLATE` in `planner.py`. Teaches the `searchMemory topic='...'` directive for prior-conversation lookups, short imperative tool steps, angle-bracket entity placeholders, final synthesis step, same-language output, no numbering.
|
||||
- **Output**: list of plan steps (max `MAX_STEPS` = 5). Gates memory enrichment (#3 / #4) and augments the tool router (#7 — planner's picks are unioned in, not replacing). Single-step `["Reply to the user."]` plans are the planner's positive "no memory, no tools" signal. An empty list is fail-open — the engine reverts to running #3 unconditionally. Consumed further by the engine to build the `ACTION PLAN:` system-message block and drive the direct-exec loop (#13) for small models.
|
||||
- **Limits**: `planner_timeout_sec` (6s). Fail-open → `[]`.
|
||||
@@ -161,7 +162,7 @@ Every distinct LLM call in Jarvis, what feeds it, what consumes it, and how it i
|
||||
## 13. Plan Step Resolver (per direct-exec turn, small models)
|
||||
|
||||
- **File**: [src/jarvis/reply/planner.py](src/jarvis/reply/planner.py) — `resolve_next_tool_call()`.
|
||||
- **Trigger**: top of each agentic-loop iteration when `use_text_tools` is True AND the plan from #12 still has unexecuted tool steps. Runs instead of the chat model for that turn. **Fast path skips the LLM entirely** when the step is fully concrete (tool name + `key='value'` args, no `<placeholder>`); the LLM call only fires when entity substitution or key remapping is needed.
|
||||
- **Trigger**: top of each agentic-loop iteration when `use_text_tools` is True AND the plan from #12 still has unexecuted tool steps. The native-mode skipped-tool guard (see `planner.spec.md`) reuses the direct-exec path but only with the regex fast path (`parse_concrete_tool_step`), so it never calls this LLM. Runs instead of the chat model for that turn. **Fast path skips the LLM entirely** when the step is fully concrete (tool name + `key='value'` args, no `<placeholder>`); the LLM call only fires when entity substitution or key remapping is needed.
|
||||
- **Model**: same chain as #12.
|
||||
- **Inputs**: next planned step text, prior tool calls (name + args + result excerpt), per-turn tool schema.
|
||||
- **System prompt**: `_STEP_RESOLVER_SYSTEM` at [planner.py:300](src/jarvis/reply/planner.py:300). Teaches one-JSON-object output, placeholder substitution from prior results, `null` for synthesis steps.
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
| STT | large-v3-turbo, `int8_float16`(1.3GB). `float16`과 정확도가 같았음 |
|
||||
| LLM | 빠름 모델(Qwen3.6-35B-A3B) 기본, 동시 요청 2개, 이미지는 GPU 처리, 화질 1280x720, 음성 답변은 생각 모드 끔. 권장 모델(Qwen3.8-Flash-Next Q2_0, MTP 보조 모델)은 다시 재서 동작 확인, 선택지로 둠. 출력 속도는 131 tok/s로 빠름 모델(82 tok/s)보다 빠르지만, 음성 답변 첫 문장(0.58초 대 0.36초), 맥락 8천 토큰 첫 토큰(2.1초 대 1.6초), 이미지 1장 답변 시작(1.3초 대 0.6초)이 모두 느리고, 한국어 답에 한자(礼貌)가 한 번 섞임. 음성은 첫 소리까지가 중요하므로 빠름 모델을 기본으로 유지 |
|
||||
| 지난 대화 맥락 | 약 8천 토큰에서 시작(텍스트 첫 문장 1.8초). 상한은 M4에서 왕복 지연을 실측해 정함 |
|
||||
| 도구 호출 | Strata에서 동작(빠름 12번 중 9번, 권장 12번 중 8번). 둘 다 도구를 부르지 않고 한 척하는 경우가 있음: 빠름 모델은 "5분 타이머 맞춰 줘"에서 "설정했습니다"라고만 답하고(3번 모두), 권장 모델은 "서울 날씨 어때?"에서 날씨를 지어내 답함(3번 모두). M3 평가에 두 경우를 넣어 고침 |
|
||||
| 도구 호출 | Strata에서 동작(빠름 12번 중 9번, 권장 12번 중 8번). 둘 다 도구를 부르지 않고 한 척하는 경우가 있음: 빠름 모델은 "5분 타이머 맞춰 줘"에서 "설정했습니다"라고만 답하고(3번 모두), 권장 모델은 "서울 날씨 어때?"에서 날씨를 지어내 답함(3번 모두). 두뇌 코드에서 고침(2026-11-10): (1) 지시문에 "바뀌는 정보(날씨·뉴스·가격·화면)는 이번 턴 도구 결과로만 말하고, 동작은 도구가 성공했을 때만 했다고 말한다"는 규칙을 넣고, 지시문 끝에 이번 턴에 쓸 수 있는 도구 이름을 다시 적음. (2) 모델이 계획 단계가 고른 도구를 건너뛰고 답하면 그 답을 버리고 계획에 적힌 호출을 직접 실행한 뒤 결과로 다시 답하게 함(인자가 도구 형식에 맞을 때만, 아니면 원래 답 유지). (3) 계획 단계에 도구 인자 이름을 보여 줌. 측정 키트 `tools_fast`/`tools_recommended` 단계로 두 모델에서 다시 확인 |
|
||||
| 분리된 화면공유 창 | 분리 창은 하나뿐이고 그 안에서 볼 화면공유를 고름. 창 제목에는 음성 채널 이름만 있어 누구 화면인지 모름. 누가 공유 중인지는 음성 채널 상태로 확인. 물어본 사람이 공유 중이 아니면 그렇다고 답함. 공유 중이면 공유자가 여러 명이어도 따로 묻지 않고 분리 창을 바로 캡처(사용자가 이미 그 사람 화면을 보고 있음). 가려져도 영상은 계속 그려짐 |
|
||||
| 게임 감지 | 발로란트(테두리 없는 창)를 게임으로, 브라우저 전체화면 영상을 게임 아님으로 바르게 판단. 안티치트 Vanguard 실행 감지 |
|
||||
| 게임 모드 VRAM 비우기 | Strata 0.1.59에서 빠름 모델은 VRAM 줄이기를 지원하지 않아 LLM을 껐다 켜는 방식(약 52초). 권장 모델은 껐다 켜지 않고 바로 줄어듦(0.03초, 사용 VRAM 약 15GB에서 약 10GB로, 줄인 동안 출력 72 tok/s). 엔진이 빠름 모델도 지원하면 다시 측정 |
|
||||
|
||||
@@ -43,7 +43,7 @@ M0~M4는 "더 빠르고 똑똑한 음성 대화"의 핵심이고, M5~M8은 "설
|
||||
|
||||
| 위험 | 대응 |
|
||||
|---|---|
|
||||
| Strata가 도구 호출이나 동시 요청을 지원하지 않음 | M0에서 둘 다 지원 확인. 다만 빠름 모델이 "5분 타이머 맞춰 줘"에서 3번 모두 도구를 부르지 않고 "설정했습니다"라고만 답함(12번 중 9번 성공). M3 평가(evals)에 이 경우를 넣고, 안 되면 플래너(JSON) 방식으로 도구를 고르게 함 |
|
||||
| Strata가 도구 호출이나 동시 요청을 지원하지 않음 | M0에서 둘 다 지원 확인. 다만 빠름 모델이 "5분 타이머 맞춰 줘"에서 3번 모두 도구를 부르지 않고 "설정했습니다"라고만 답함(12번 중 9번 성공). 지시문 규칙과 "건너뛴 도구 직접 실행" 장치로 고쳤고 평가(`evals/test_tool_skip_confabulation.py`)에 넣음. 게임PC 두 모델 재측정은 측정 키트 `tools_fast`/`tools_recommended` 단계 |
|
||||
| 게임과 VRAM 경쟁 | 게임 모드(RAM 위주/빠름 모델/일시정지 각각 켜기), VRAM 사용량 실시간 표시 |
|
||||
| 테두리 없는 창 게임을 놓치거나 일반 프로그램을 게임으로 잘못 봄 | 창 모양 + GPU 사용량 + 게임 폴더를 같이 보고, 게임 목록·"게임 아님" 목록으로 바로잡음. 감지 이유를 대시보드에 표시 |
|
||||
| 안티치트 목록에 없는 게임에서 자동 입력 | GUI에서 직접 추가, 앱 업데이트로 목록 확장. 독점 전체화면 게임 중에는 자동 입력 기본 차단 유지 |
|
||||
|
||||
Reference in New Issue
Block a user