Skip to content

Add scoped LM selection and configuration overrides - #133

Open
arthurianresolve wants to merge 17 commits into
krypticmouse:mainfrom
arthurianresolve:fix-lm-configuration-overrides
Open

arthurianresolve wants to merge 17 commits into
krypticmouse:mainfrom
arthurianresolve:fix-lm-configuration-overrides

Conversation

@arthurianresolve

@arthurianresolve arthurianresolve commented Nov 10, 2026 •

Copy link
Copy Markdown

Summary of Fix

Includes the resolved #131 and #132 branches. Merge those first, then this PR before #121/#134.

  • Add explicit call-time LM overrides for predictors, conversations, and modules. Resolve the LM as explicit call override > predictor LM > scoped/module default > global configuration.

  • Add task-local with_lm scopes and module defaults through Module::with_lm. Restore scopes on success, error, panic, and cancellation, while preserving predictor discovery on wrapped modules.

  • Add LM::copy_with and Predict::call_with_config to merge changes over the resolved configuration. Retain the provider client for generation-only changes, rebuild it when the model, endpoint, or credentials change, and start copies with fresh caches.

  • Honor scoped defaults when generated IR modules bind their default model.

  • Classify typed HTTP errors before retrying: retry 429/5xx and transient transport failures; fail immediately on permanent HTTP errors and request-construction failures. Preserve bounded exponential backoff and the zero-retry setting.

  • Document the APIs, precedence, copy semantics, retry behavior, and spawned-task scope boundaries.

  • Preserve configured token limits on the OpenAI-compatible HTTP transport. The pinned Rig Chat Completions converter drops the generic limit; bridge it into the appropriate wire parameter while preserving explicit provider parameters. This also makes copy_with token budgets effective on local Ollama endpoints.

  • Introduce CompletionProvider for built-in, test and third-party providers. LMClient::custom accepts external implementations; all run through the same LM configuration, retry, tool, cache and history wrapper.

  • Expose typed LM failure categories and retryability through LmError::call_error(). Preserve concrete provider causes through Predict and IR error chains.

Fixes #69
Fixes #77

Why

Per-predictor LMs and retry/backoff already exist, but callers cannot temporarily select a different LM or merge configuration changes for one call without constructing their own replacement plumbing. Scoped defaults and explicit overrides provide those choices without mutating the global LM or predictor state.

Changing a config's model or endpoint alone does not replace its initialized client. copy_with rebuilds the client when provider identity changes, while retaining injected clients for generation-only changes. Each copy has independent cache state.

The existing retry classifier also treated every HTTP error as transient. Rig retains the HTTP status in a typed error, allowing 400/401 and other permanent responses to fail immediately while 429/5xx responses remain retryable.

The real-provider profiling work for #23 exposed a transport gap: max_tokens was present in the generic request but absent from the HTTP body. The adapter now sends max_tokens for local/legacy model names and max_completion_tokens for o-series and GPT models from version 5 onward. Explicit additional-parameter limits remain intact.

Related work

Testing

  • Existing configuration and HTTP suites cover override precedence, nested scopes, cancellation/panic restoration, concurrency, endpoint/credential changes, cache isolation, and permanent versus transient failures.
  • Three provider-contract regressions verify a generic real/mock interface, external provider injection with scoped/call-time configuration, and nested typed causes plus retry counts for HTTP 400/401/403/429/503.
  • The resolved stack at 2b4590f0174dc05582347b8da75b6b58fbce9ca0 passed 209 tests with --no-default-features and 247 with default data/cache features (2 live tests ignored in each offline run). These are focused library and integration suites, not the full workspace test suite. Later ancestry-only integration merges preserve the validated source trees.
  • Native parsing, history, tools and scoped configuration are tested together on that resolved stack.
  • The token-limit follow-up passed all 21 local HTTP tests and three provider-contract tests in a release build with --no-default-features. They inspect actual serialized requests, copied limits, explicit parameter preservation, duplicate-key avoidance and typed invalid-request errors; the model names are endpoint fixtures, not live hosted-model calls.
  • After propagating the correction into the integrated profiling/runtime stack at bda64b29974cdd22e4e8004976a7e5c8f4d2263c, eight release integration suites passed 62 tests with --no-default-features (three live tests ignored). Coverage includes the HTTP wire budget, provider contract, native rendering/scalar output, typed special fields, storage, tool-loop limits and trace/replay.
  • Targeted rustfmt and git diff --check — passed.

AI Disclosure

  • OpenAI Codex assisted with implementation, tests, and PR drafting.
  • all fixes and drafts have been human-architected, human-directed and human-reviewed before publication of PR requests.

@mintlify

mintlify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit a864145.

Approve preview

arthurianresolve added a commit to arthurianresolve/DSRs that referenced this pull request Nov 19, 2026
Integrate krypticmouse#133 — Add scoped LM selection and configuration overrides

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DummyLM should share a trait with LM LM layer: per-module LM, config merging, retry/backoff

1 participant