fix(wiki): a merge draft merges or fails, never a silent append (#1195) #1196

Merged
claude-bot merged 2 commits from fix/1195-merge-draft into main 2026-10-14 20:15:48 +00:00
Collaborator

This is the backend half of #1195.

  • The merge reply is uncapped. merge_lore_entry_body asked for at most 2,048 tokens, and on prod Gemma 4 spent all 2,048 thinking (finish_reason='length', empty content). It now uses max_tokens=None, like every other wiki rewrite in audio_service.
  • A failed merge draft fails. A new keyword, fallback_append (default True), controls what happens when the AI call fails or returns nothing.
    • The draft task passes False, so the draft goes to failed with its seed untouched and the GM can start it over.
    • Before, the draft read as merged while holding existing + "\n\n" + new.
  • The direct approval path is unchanged. lore_service.approve_lore_proposal keeps its logged append (#287).

Tests (new, in tests/test_lore_drafts.py):

  • the request is uncapped (asserted on the call's kwargs);
  • the default still appends, on both an empty reply and an error;
  • fallback_append=False raises in both cases;
  • a merge draft whose model returns nothing ends failed with its body unchanged.

All 146 tests across the lore, LLM-policy and unidentified-item modules pass on docker-test, and ruff format and check are clean.

The other half, a line on the draft screen saying the GM-only text is kept, waits for the owner's wording.

🤖 Generated with Claude Code

This is the backend half of #1195. - **The merge reply is uncapped.** `merge_lore_entry_body` asked for at most 2,048 tokens, and on prod Gemma 4 spent all 2,048 thinking (`finish_reason='length'`, empty content). It now uses `max_tokens=None`, like every other wiki rewrite in `audio_service`. - **A failed merge draft fails.** A new keyword, `fallback_append` (default True), controls what happens when the AI call fails or returns nothing. - The draft task passes False, so the draft goes to **failed** with its seed untouched and the GM can start it over. - Before, the draft read as merged while holding `existing + "\n\n" + new`. - **The direct approval path is unchanged.** `lore_service.approve_lore_proposal` keeps its logged append (#287). Tests (new, in `tests/test_lore_drafts.py`): - the request is uncapped (asserted on the call's kwargs); - the default still appends, on both an empty reply and an error; - `fallback_append=False` raises in both cases; - a merge draft whose model returns nothing ends **failed** with its body unchanged. All 146 tests across the lore, LLM-policy and unidentified-item modules pass on docker-test, and ruff format and check are clean. The other half, a line on the draft screen saying the GM-only text is kept, waits for the owner's wording. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merge_lore_entry_body capped the reply at 2048 tokens; Gemma 4 spent them
thinking, the answer came back empty, and the draft fell back to
existing + new while reading as a merge. Uncapped like the other wiki
rewrites; the draft path passes fallback_append=False so a failed merge
fails the draft. The direct proposal approval keeps its logged append.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests: ruff format (#1195)
All checks were successful
CI / Which journeys does this change need? (pull_request) Successful in 13s
CI / Does this change touch the recording path? (pull_request) Successful in 14s
CI / Bot/backend version sync (pull_request) Successful in 22s
CI / Backend lint (ruff) (pull_request) Successful in 1m20s
CI / Feedback site tests (pull_request) Successful in 1m41s
CI / Summarisation accuracy eval harness (stub provider) (pull_request) Successful in 1m58s
CI / Bot tests and audit (pull_request) Successful in 3m15s
CI / Docker image build (pull_request) Successful in 4m39s
CI / Frontend (shard 1/2) (pull_request) Successful in 8m15s
CI / Synthetic session harness (no GPU, no LLM) (pull_request) Successful in 9m51s
CI / Frontend (shard 2/2) (pull_request) Successful in 11m55s
CI / End-to-end journeys (desktop) (desktop) (pull_request) Successful in 11m35s
CI / Backend migration, tests, and audit (pull_request) Successful in 45m59s
c5e3b7ee3e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude-bot deleted branch fix/1195-merge-draft 2026-10-14 20:15:48 +00:00
Sign in to join this conversation.
No description provided.