fix(providers): tighten tool calls and compatibility fallbacks
Require structured tool calls and explicit unsupported-feature errors. Preserve supported SDK compaction requests and add compatibility coverage. Co-authored-by: Xubin Ren <52506698+Re-bin@users.noreply.github.com>
This commit is contained in:
1 parent
3e40684112
commit
8b37976d36
16 files changed
+406
-168
No files matched your search
@@ -419,6 +419,8 @@ Providers that use the Responses API can keep reasoning context across a convers
|
||||
|
||||
nanobot preserves Responses conversation state automatically for OpenAI Responses, OpenAI Codex, Azure OpenAI, DeepSeek V4, and compatible GitHub Copilot models. Native compaction is also automatic when the provider supports it. The threshold is derived from the active model's context window and reserved output headroom; no provider configuration is required.
|
||||
|
||||
An explicit rejection of a native compaction field or input type disables that capability for the current provider instance. Invalid threshold values and other request errors do not disable it. For OpenAI and Azure Responses requests, an unsupported compaction field permits one retry without that field; a validation error is returned for correction. Codex compaction required to fit the input budget must succeed before the conversation can continue.
|
||||
|
||||
<details>
|
||||
<summary><b>Azure OpenAI</b></summary>
|
||||
|
||||
@@ -1508,7 +1510,7 @@ To configure presets in `config.json`:
|
||||
|
||||
`supportedApis` must contain at least one of `chat_completions`, `responses`, or `anthropic_messages`. `preferredApi` must belong to that list and defaults to its first entry. Omit `api` or set it to `null` for Auto. An explicit preset declaration overrides the OpenAI connection default; for custom connections, it must stay within the connection's supported APIs.
|
||||
|
||||
A Responses-only preset never falls back to Chat Completions. To allow Chat fallback for Responses compatibility errors, include both `responses` and `chat_completions` with `preferredApi: "responses"`. Other errors do not trigger this API fallback. Provider-hosted search uses Responses when the preset allows it.
|
||||
A Responses-only preset never falls back to Chat Completions. To allow Chat fallback for Responses compatibility errors, include both `responses` and `chat_completions` with `preferredApi: "responses"`. Fallback requires an explicit rejection of the Responses API, a Responses-specific parameter, or the `input_image` input type. Invalid parameter values, missing conversation state, authentication failures, rate limits, and server errors do not trigger this API fallback or count toward temporarily bypassing Responses. Provider-hosted search uses Responses when the preset allows it.
|
||||
|
||||
Declare `anthropic_messages` alone in a preset. Requests use the same provider connection settings and go to `/v1/messages`; `apiBase` may include a trailing `/v1`. Automatic API fallback between Anthropic Messages and OpenAI formats is not supported; use separate [fallback presets](#model-fallbacks) when needed.
|
||||
|
||||
|
||||
@@ -78,6 +78,10 @@ You usually omit `apiBase` for hosted built-in providers such as OpenRouter, Ant
|
||||
|
||||
Use `proxy` when one provider must send HTTP traffic through a proxy without changing process-wide `HTTP_PROXY` / `HTTPS_PROXY`. Supported providers include `openai`, `custom`, named custom providers, OpenRouter-style gateways, local OpenAI-compatible servers, Anthropic Messages, `openai_codex`, and `xai_grok`. For OAuth providers, this also covers exchanging and refreshing tokens. `bedrock`, `azure_openai`, and `github_copilot` reject `proxy`; use their endpoint-specific configuration instead.
|
||||
|
||||
Tool execution requires the API's structured tool-call fields. OpenAI-compatible services that put `<tool_call>` markup in assistant text must expose structured tool calls to use nanobot's tools; nanobot preserves that markup as text.
|
||||
|
||||
If a reply contains raw `<function=...>` or `<parameter=...>` tags, check the model and serving endpoint's tool-calling support. For self-hosted models, configure the server's tool-call parser for that model. For hosted services, ask the provider to return structured `tool_calls`, or use a compatible model and endpoint. Code examples remain text and are not executed. Changing the chat channel or hiding tags does not repair an upstream tool-calling format error.
|
||||
|
||||
## Inline Image Requests
|
||||
|
||||
Before sending a large inline image batch, providers prepare smaller copies while keeping the attachment files intact. This applies to Responses, Chat Completions, Anthropic Messages, and Bedrock Converse requests, including images returned by tools and images in Responses history replay. Preparation first re-encodes at the original dimensions, then reduces each dimension by at most 25% if needed, with JPEG quality at least 65. PNG transparency is preserved. The shared 1 MB image data URL budget is a best-effort transport target; small image blocks, animated images, and remote references keep their original payloads. Gateway logs report image sizes and byte counts.
|
||||
|
||||
Reference in new issue
Block a user