Local AI
•
2026-07-27
Treat Model Routing as Untrusted Request Data
The problem
A request-scoped model override is easy to implement as a mutation on a shared adapter. That shortcut works in the happy path and fails under concurrency, cancellation, retries, or a thrown provider error. The next request can inherit the previous request’s route without an explicit decision to do so.
This is the same class of failure as leaked authentication or tenant state: the value is not necessarily secret, but it has authority. It changes where work runs and can change which data leaves a boundary.
The mental frame
Treat provider selection, filesystem paths, model identifiers, and hardware preferences as untrusted inputs until they are validated and bound to one request. A local machine is not automatically a single-user trust domain once multiple tools, workers, or sessions share a process.
This framing also improves AI-assisted development. Ask the model to reason about ownership and cleanup before asking it to add another adapter option. The important question is not whether the override can be set. It is who can observe it after the request ends.
How to work with an AI tool
Give the model a small state-isolation brief: identify the mutable object, list every request exit path, define the default path, and write the cross-request test before implementation. Have it explain why the cleanup belongs in a `finally` path and what happens if validation, inference, cancellation, or serialization fails.
- Validate paths and identifiers before they reach the adapter.
- Keep the managed/default route unchanged when no override is present.
- Clear request mutations on success, error, timeout, and cancellation.
- Run two requests with different routes and force the first to fail.
- Inspect logs and receipts without exposing raw filesystem details or provider secrets.
The implementation pattern
The useful boundary is a request envelope that carries the override, a validator that narrows it to an allowed capability, and an adapter call wrapped by guaranteed cleanup. The default path remains the source of truth for ordinary requests; the override is an explicit exception with a bounded lifetime.
That pattern composes well with local-first systems because it keeps routing authority near the operator while preventing a local adapter from becoming an ambient global switch.
What this proves—and what it does not
The current development record supports the isolation design and its targeted implementation claim. It does not by itself prove every provider path, worker concurrency mode, or production filesystem posture. Those need focused tests and a live runtime receipt on the supported deployment path.
Field Notes Used
Codexify Dev Log · 2026-07-27
External adapter path binding and registry allowlist work.
Codexify Dev Log · 2026-07-13
Transport-only and forced-dry-run boundaries for delegated work.
Next Step
Need implementation support for this topic? Resonant Constructs offers consultation services for practical AI adoption, private knowledge systems, local deployment, and human-reviewed automation.
Archive Note
This Insights surface currently uses a structured in-repo content model. As publishing expands, tag routing will continue mapping each topic to the most relevant consulting landing page.