feat(core): harden the local provider for multimodal agent loops#212
Merged
Conversation
Make provider="local" usable as a first-class agent backend against self-hosted OpenAI-compatible servers: - Inline image and audio inputs through Chat Completions content parts (uploads=True) and inline text files; reject unsupported MIME types with specific guidance instead of blanket "text-only" errors. - Allow Config.model to be omitted for single-model local servers; the model field is left out of local payloads. Cloud providers still require model, and cache()/defer() raise clearly when it is missing. - Add Config.request_timeout_s (default 300s) for providers that own their transport, plumbed through to LocalProvider. Docs: document optional model and request_timeout_s in configuration.md.
This was referenced Jun 17, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
seanbrar
added a commit
that referenced
this pull request
Jun 17, 2026
## Summary Two agent-loop ergonomics improvements that build on the hardened local provider (#212): a richer error taxonomy and OpenAI Chat Completions message interop. **Error taxonomy** - `ContextOverflowError` (an `APIError` subclass) classifies context-window rejections and best-effort extracts requested/allowed token counts from provider messages. - `ToolCallParseError` classifies unparseable model tool calls. `ToolCall.arguments_dict()` now raises it (carrying `tool_name`/`tool_call_id`/`arguments_text`), and the local provider maps server-side tool-call JSON parser failures, both HTTP errors and streamed error payloads, to the same recoverable type. **OpenAI message interop** - `Continuation.from_openai_messages` / `to_openai_messages` and `Message`/`ToolCall` `.from_openai` / `.to_openai` let harnesses that already store OpenAI Chat Completions transcripts replay them through Pollux. ## Related issue None ## Test plan `just check` passes (ruff format, ruff check, mypy, 435 tests). New tests: - `tests/providers/test_errors.py`: context-overflow wrapping with token-count extraction. - `tests/interaction/test_tools.py`: `arguments_dict()` raises `ToolCallParseError` with metadata. - `tests/interaction/test_continuation.py`: OpenAI message import + tool-call round-trip. - `tests/providers/test_local_contract.py` / `test_local_stream.py`: local tool-call-parse classification for HTTP and SSE error payloads. ## Notes Second of a 3-PR stack for v2 RC. **Stacked on #212** - review/merge that first. The `Session` runtime + readiness probes follow in the next PR.
seanbrar
added a commit
that referenced
this pull request
Jun 17, 2026
## Summary Make multi-turn agent loops first-class without re-creating a provider per call. - **`Session`** owns one provider instance across many `interact()` / `stream()` / `run_many()` turns and closes it on exit. The one-shot module helpers now delegate to a single-use `Session`, so their behavior is unchanged. - **Readiness probes**: a `ReadinessProvider` protocol + `ProviderReadiness` result let a provider expose a fast preflight. `Session.check_ready()` and the module-level `check_ready()` probe before packing context. The local provider implements it against `/health` and `/v1/models`, verifying the configured model when one is set. - **`local_reasoning()`** helper returns the scoped `provider_options` for local servers that honor `enable_thinking`. ## Related issue None ## Test plan `just check` passes (ruff format, ruff check, mypy, 443 tests). New tests: - `tests/interaction/test_interact_frontdoor.py`: `Session` reuses and closes its provider; module-level `check_ready()` uses the provider probe; `local_reasoning()` shape. - `tests/providers/test_local_contract.py`: local `check_ready` health-endpoint path, models fallback, missing-model reporting, model-unset skip, and model-verification requirement. ## Notes Third and final PR in the v2 RC stack. **Stacked on #213 (which is on #212)**.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make
provider="local"a first-class agent backend against self-hosted, OpenAI-compatible servers. Local now accepts multimodal input, supports single-model servers that don't take amodelfield, and exposes a configurable request timeout.uploads=True) and inline text files; unsupported MIME types raise specific guidance instead of a blanket "text-only" error.Config.modelmay be omitted for single-model local servers; themodelfield is then left out of local payloads. Cloud providers still requiremodel, andcreate_cache()/defer()raise clearly when it is missing.Config.request_timeout_s(default300.0) for providers that own their transport, plumbed through toLocalProvider.Related issue
None
Test plan
just checkpasses (ruff format, ruff check, mypy on 88 source files, 429 tests). New/updated tests:tests/providers/test_local_contract.py: multimodal content parts, unsupported-MIME rejection,upload_fileinlining,model-omitted payload, custom timeout,uploads=Truecapability.tests/pipeline/test_cache_and_uploads.py: local file sources are inlined for Chat Completions.tests/test_config.py: optionalmodelfor local, cloudmodelrequired,request_timeout_svalidation.Notes
First of a 3-PR stack hardening Pollux for v2 RC agent loops. Stacked PRs follow: error taxonomy + OpenAI interop, then the
Sessionruntime + readiness probes. This PR targetsmainand stands alone.just checkpasses