Loading…
Reference in a new issue
No description provided.
Delete branch "feat/350-351-provider-contracts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Opens v4.2.0. Four commits, reviewable in order — the contracts, the defect they exposed, the operator-facing field, and the ASR wiring.
The defect this turned up
_warn_if_prompt_truncatedwas called from exactly one site, the Ollama path. llama.cpp, Anthropic and OpenAI all parsedusagefor completion tokens and never looked at the prompt side, so a front-truncated prompt on three of four providers produced no signal at all — the input-side half of the failure #331/#336 exist to prevent, live on most deployments.Usage reading now goes through
provider.read_usage, normalising four different shapes (prompt_eval_count,usage.prompt_tokens,usage.input_tokens), and one_check_usageruns both truncation checks so a new transport cannot forget one.It is skipped rather than fired-and-ignored where a low count is genuinely ambiguous. Anthropic and OpenAI cache prompt prefixes and report only newly evaluated tokens, so "truncated" and "cache hit" are indistinguishable from here. Ollama and llama.cpp neither cache nor reject an over-long prompt, so there a low count has one meaning — and those are the deployments most likely to have the window misconfigured. That declaration is what the abstraction buys; the docstring had been asking for it since #331.
Provider identity stops being a guess
Dispatch was URL-substring matching —
anthropic.com,openai.com,:11434/ollama, else llama.cpp — and the four_qa_*functions repeated it independently. A self-hoster behind a gateway on their own domain was read as llama.cpp regardless of what was behind it, and got that provider's schema spelling, truncation semantics and window defaults.Provider is now configuration, with a validated select in Admin → Bot Settings. The old heuristic survives as a named, logged fallback so nothing changes on upgrade, and the log line names the field to set.
Two structural guarantees worth reviewing as such
TranscriptionResulthas no speaker field. Not "the echo is ignored" — there is nowhere to put one. Identity comes from Discord track ownership, so an adapter that wanted to relabel a track has no channel through which to do it. #342 came back through that door once; this closes it in the type rather than by convention. There is a test asserting the field's absence.Association is by
track_id, never list position. Echoed through untouched.Deliberate scope limits, flagged for review
LocalWhisperProviderdeclaresword_timestamps=Falseand interpolates spans across each segment by character length, marking every wordinterpolated=Trueand the result degraded. Consumers read words either way and none branch on provider; #358 surfaces the gap. Nothing downstream consumes words yet — on this provider they would add no precision, and pushing a new shape through the merge and segment rows is worth doing when #352 makes them real.transcribe_track.vocabularymaps for the local adapter only — #350 asks for one managed adapter too, which wants #360.preflight_promptstays a warning, not a raise. #351 makes a hard check possible (a declared tokenizer, a declaredfront_truncates), but flipping it should wait for #359 proving the tokenizer.One thing I want a second opinion on
llm_provideris threaded alongsidecontext_tokensthrough every generation path — 19 signatures, 25 pass-throughs, 14 origin sites. Partial adoption would be worse than none (a self-hoster is misread on every path, so half-right routing is harder to diagnose than none), and omitting it falls back to the sniff, which is safe.But this is the exact pattern
DEFAULT_CONTEXT_TOKENS' comment warns about — "the eighteenth, written next month, unprotected again". It holds only because the fallback is benign. The real fix is to stop destructuringLLMConfiginto four loose parameters at every boundary, which would kill both threading problems permanently. That is a refactor worth its own issue rather than one smuggled into this one — happy to file it.Verification
getattr— a double that silently diverges is exactly the test that passes while production breaks (#441).test_llm_transportcaught a regression on the first run — a junk context window raising instead of falling back. Exactly what it was written for; fixed in the registry, since raising would trade #337's silent hole for a dead pipeline.