Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/484-llm-target"
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?
Closes #484. Closes #488.
Every LLM generation path now takes the configured target as one parameter,
target: LLMConfig, instead of the looseendpoint_url, api_key, model, context_tokens, llm_providerquintet destructured at the origin and re-threaded by hand. A new call site can no longer omit a field of an object it is already holding, and adding a sixth attribute to the config is one edit rather than ~58.What changed
LLMConfigmoves toapp/providers/llm.py(frozen), withDEFAULT_CONTEXT_TOKENSand its rationale block. It had to move:settings_serviceimports fromllm_service, so the transport could not import the config from settings without a cycle, andapp.providersis the leaf package.settings_servicere-exports the name sosettings_service.LLMConfigstill resolves.registry.llm_provider_for(target)— the one-object form ofresolve_llm_provider.generate_structured_text(prompt, target, *, ...)— loose form removed outright, no shim. All four_structured_*transports taketargettoo, so the destructuring does not just move one frame down.audio_service: 24 LLM-taking functions converted, including the eight hand-rolled_qa_*/_summarise_*transports andtest_llm. The eight Whisper ASR functions are untouched (#350's territory)._FALLBACK_CONTEXT_TOKENSdeleted; the two callees applyresolve_window(target.context_tokens)themselves, which is the same number.beat_service,generation_service,lore_service,reminder_tasks,planning_tasks,routers/bot.py,routers/users.py: origin sites passllm_cfgwhole.evals/:LiveProvidercarries anLLMConfiginstead of re-assembling four fields per call — the one caller theapp/+tests/greps missed, with no test covering it. GainedQB_EVAL_PROVIDERso the harness can name the provider rather than being stuck on URL-guessing forever, and--context-tokensnow reaches the request as well as the window sizing (previously it moved only one of the two).The bug fix (#488), its own commit
1b0e273_dispatch_prose(the session-summary prose path) andtest_llm(the admin test button) accepted the explicit provider from #351 and ignored it, still branching on"anthropic.com" in endpoint_urland friends. An operator who pinnedanthropicon a gateway of their own got structured generation and/askrouted correctly and session summaries sent to the llama.cpp transport. Both now resolve once through the registry and dispatch onprovider.capabilities.name, the wayanswer_questionalready did. Two tests setprovider="anthropic"on a non-anthropic URL and assert the Anthropic transport is the one awaited; both were verified red against the pre-fix file. Changelog entry under Fixed.No behaviour change elsewhere
An AST walk over
9a0cc4bfound zero production call sites reaching the transport withcontext_tokensomitted (45 in tests, all migrated), so no production path's effective window moves. The three places the window is now read fromprovider.capabilities.context_tokensrather thanresolve_window(...)of the same value are identical for any positive int, andget_llm_configalways resolves one.After-counts
app/declaringendpoint_url: strllm_provider=inapp/Verification
ruff format --check/ruff check: clean.scripts/check_version_sync.py: OK.LLMConfiginstances throughout (noSimpleNamespacelook-alikes), plus aninspect.signatureguard so the loose form cannot creep back.🤖 Generated with Claude Code
Every stand-in for the LLM config — SimpleNamespace, an ad-hoc `type("LLM", (), {...})()`, a dict — becomes a real LLMConfig. A double that diverges from the dataclass is a test that keeps passing while production breaks, and these doubles were already one field behind more than once (see the note in test_recap_email). Call sites move to the single target argument. The assertions are untouched: they were on the wire body all along — options.num_ctx, the schema spelling, the max_tokens cap — which is the request, and still is. Adds a guard in test_llm_transport asserting from the signature itself that generate_structured_text takes `target` and none of the five loose fields, so the shape this issue removed cannot come back unnoticed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>