feat: add persistent model-aware reasoning effort settings
This commit is contained in:
+16
-3
@@ -46,6 +46,10 @@ Chat upload limits:
|
||||
- Gemini model lists are loaded from Google's native Models API and filtered to Gemini `generateContent` model ids.
|
||||
- The backend loads provider model lists at startup and refreshes them about once every 24 hours. If a later provider refresh fails, the response keeps the last loaded model list for that provider and sets `error` to the latest failure message.
|
||||
|
||||
Each provider also includes `reasoningCapabilities`, a map keyed by exact model ID. For example, OpenAI includes `"gpt-5.2": { "efforts": ["none", "low", "medium", "high", "xhigh"], "defaultEffort": "none" }`. This metadata comes from a conservative backend allowlist verified against [OpenAI model documentation](https://developers.openai.com/api/docs/models/gpt-5.2) and the [reasoning guidance](https://developers.openai.com/api/docs/guides/deployment-checklist#set-up-reasoningeffort), independently of model-list refreshes. It describes capabilities, not account access. `defaultEffort: null` means the provider default has not been established; it does not mean `none`. Defaults vary by model (for example GPT-5.2 uses `none`, [GPT-5.5 uses `medium`](https://developers.openai.com/api/docs/models/gpt-5.5)).
|
||||
|
||||
Clients must use the returned effort levels for the selected provider/model. Missing entries, missing metadata from an older server, unknown aliases/snapshots, and other providers fall back to **Model default**, with no effort sent to the provider. Do not infer support from a `gpt-` prefix or from an OpenAI-compatible endpoint. The full web Chat Settings slider includes Model default plus the supported levels; choices are saved per chat and remembered per provider/model in browser storage for new chats.
|
||||
|
||||
## Chat Tools
|
||||
|
||||
### `GET /v1/chat-tools`
|
||||
@@ -103,6 +107,7 @@ Behavior notes:
|
||||
"initiatedModel": "gpt-4.1-mini",
|
||||
"lastUsedProvider": "openai",
|
||||
"lastUsedModel": "gpt-4.1-mini",
|
||||
"reasoningEffort": null,
|
||||
"additionalSystemPrompt": null,
|
||||
"enabledTools": ["web_search", "fetch_url"]
|
||||
},
|
||||
@@ -149,6 +154,7 @@ History search (`q`) notes:
|
||||
"title": "optional title",
|
||||
"provider": "optional openai|anthropic|xai|gemini",
|
||||
"model": "optional model id",
|
||||
"reasoningEffort": null,
|
||||
"additionalSystemPrompt": "optional stored system prompt",
|
||||
"enabledTools": ["web_search", "fetch_url"],
|
||||
"messages": [
|
||||
@@ -165,6 +171,7 @@ History search (`q`) notes:
|
||||
|
||||
Behavior notes:
|
||||
- `provider` and `model` must be supplied together when present.
|
||||
- `reasoningEffort` is optional: `null` (the default) or `none|minimal|low|medium|high|xhigh|max`. The server stores only an effort supported by that exact provider/model; unsupported combinations become `null`. A string outside this enum is rejected. `null` means omit the provider parameter, whereas `"none"` explicitly disables reasoning on models that support it.
|
||||
- Newly created non-fork chats have `parentChatId: null` and `titleGenerationPending: false`.
|
||||
- When `provider`/`model` are supplied, the new chat initializes `initiatedProvider`/`initiatedModel` and `lastUsedProvider`/`lastUsedModel`.
|
||||
- `additionalSystemPrompt` is trimmed and stored on the chat; blank values are stored as `null`.
|
||||
@@ -181,18 +188,19 @@ Behavior notes:
|
||||
Behavior notes:
|
||||
- With no `messageId`, the server copies the complete source transcript. With an assistant response `messageId`, it copies the transcript through that response, inclusive.
|
||||
- The source chat is unchanged. Copied messages receive new ids while retaining their role, content, name, creation time, order, and metadata except for the source request's transport-only `clientRequestId`. Attachments, tool-call metadata, and per-response `metadata.generation` are retained. For older replies with an exact call-log match, generation metadata is recovered before copying. LLM call logs, star/project memberships, and other child threads are not copied.
|
||||
- The fork inherits the source chat's user, initiated/last-used provider and model, additional system prompt, and enabled tool settings.
|
||||
- The fork inherits the source chat's user, initiated/last-used provider and model, supported reasoning effort, additional system prompt, and enabled tool settings.
|
||||
- A fork of a root or another fork always sets `parentChatId` to the single root chat id. Root chats keep `parentChatId: null`.
|
||||
- A whole-chat fork starts with `Fork of <source title>` (or `Fork of Untitled chat`). A message fork starts with `Fork of '<message snippet>'`.
|
||||
- The placeholder title is returned with `titleGenerationPending: true`. After the first new prompt, call `POST /v1/chats/title/suggest`; the placeholder is eligible for replacement exactly once.
|
||||
|
||||
### `PATCH /v1/chats/:chatId`
|
||||
- Body: any subset of `{ "title": string, "additionalSystemPrompt": string|null, "enabledTools": string[] }`
|
||||
- Body: any subset of `{ "title": string, "provider": Provider, "model": string, "reasoningEffort": ReasoningEffort|null, "additionalSystemPrompt": string|null, "enabledTools": string[] }`
|
||||
- Response: `{ "chat": ChatSummary }`
|
||||
- Blank titles are rejected. The server trims surrounding whitespace before storing the title.
|
||||
- Setting a title clears `titleGenerationPending`, preventing an in-flight or later automatic suggestion from replacing the manual title.
|
||||
- `additionalSystemPrompt: null` clears the stored prompt. Blank string values are also stored as `null`.
|
||||
- `enabledTools: []` disables Sybil-managed tools for this chat. Omitted settings are left unchanged.
|
||||
- `provider` and `model` must be supplied together. They update `lastUsedProvider`/`lastUsedModel` immediately, atomically with `reasoningEffort`, without changing the original `initiatedProvider`/`initiatedModel`. Changing the model/provider without an effort clears the old effort. Keeping the same model without an effort preserves it. An effort-only patch uses the saved model. `reasoningEffort: null` resets to Model default; unsupported combinations normalize to `null` as on creation.
|
||||
- Updating chat fields changes the returned chat's `updatedAt`.
|
||||
- Not found: `404 { "message": "chat not found" }`
|
||||
|
||||
@@ -317,7 +325,8 @@ Notes:
|
||||
"additionalSystemPrompt": "optional one-off system prompt",
|
||||
"enabledTools": ["web_search", "fetch_url"],
|
||||
"temperature": 0.2,
|
||||
"maxTokens": 256
|
||||
"maxTokens": 256,
|
||||
"reasoningEffort": null
|
||||
}
|
||||
```
|
||||
- Response:
|
||||
@@ -345,6 +354,8 @@ Behavior notes:
|
||||
- Saved ordinary assistant responses also store the completion's provider/model in `metadata.generation`, exposed by `GET /v1/chats/:chatId`; changing the chat selection does not relabel previous responses.
|
||||
- `additionalSystemPrompt`, when present directly or loaded from stored chat settings, is prepended to the provider request as a `system` message and is not inserted into the persisted chat transcript by this endpoint.
|
||||
- `enabledTools` limits Sybil-managed tools for this request. When omitted for a saved chat, the stored chat setting is used; otherwise all available tools are enabled by default. An empty array disables Sybil-managed tools.
|
||||
- Optional `reasoningEffort` uses the enum/null contract above. Omission inherits the saved effort only when the request provider/model exactly matches the saved pair; otherwise it uses Model default. Explicit `null` resets it. The effective validated value is persisted alongside the last-used model on ordinary persisted calls, including failed calls. Inline `@sybil` calls use the separate Agent configuration.
|
||||
- The backend checks support again before sending OpenAI requests: Responses uses `reasoning: { effort }`; Chat Completions uses `reasoning_effort`. Defaults and unsupported combinations omit both fields. With an explicit effort other than `none`, OpenAI `temperature` is omitted to avoid incompatible sampling parameters. For allowlisted reasoning models, Chat Completions maps `maxTokens` to `max_completion_tokens`; Responses uses `max_output_tokens`.
|
||||
- `maxTokens` is optional. For `anthropic`, when omitted the backend requests the selected model's maximum output token limit from Anthropic's Models API and uses that as `max_tokens`; if the model limit cannot be loaded, the fallback is 128000. For other providers, omitted `maxTokens` is not sent as an explicit cap.
|
||||
- Server persists final assistant output and call metadata (`LlmCall`) in DB.
|
||||
- Server updates chat-level model metadata on each call: `lastUsedProvider`/`lastUsedModel`; first successful/failed call also initializes `initiatedProvider`/`initiatedModel` if unset.
|
||||
@@ -497,6 +508,7 @@ Saved selections for unsupported provider IDs are returned as `null` for both th
|
||||
"initiatedModel": "string|null",
|
||||
"lastUsedProvider": "openai|anthropic|xai|gemini|null",
|
||||
"lastUsedModel": "string|null",
|
||||
"reasoningEffort": "none|minimal|low|medium|high|xhigh|max|null",
|
||||
"additionalSystemPrompt": null,
|
||||
"enabledTools": ["web_search", "fetch_url"]
|
||||
}
|
||||
@@ -551,6 +563,7 @@ Saved selections for unsupported provider IDs are returned as `null` for both th
|
||||
"initiatedModel": "string|null",
|
||||
"lastUsedProvider": "openai|anthropic|xai|gemini|null",
|
||||
"lastUsedModel": "string|null",
|
||||
"reasoningEffort": "none|minimal|low|medium|high|xhigh|max|null",
|
||||
"additionalSystemPrompt": null,
|
||||
"enabledTools": ["web_search", "fetch_url"],
|
||||
"messages": [Message]
|
||||
|
||||
@@ -58,7 +58,8 @@ Web presentation note: `/lite` uses these same chat streams and existing search
|
||||
"additionalSystemPrompt": "optional one-off system prompt",
|
||||
"enabledTools": ["web_search", "fetch_url"],
|
||||
"temperature": 0.2,
|
||||
"maxTokens": 256
|
||||
"maxTokens": 256,
|
||||
"reasoningEffort": null
|
||||
}
|
||||
```
|
||||
|
||||
@@ -73,6 +74,8 @@ Notes:
|
||||
- For persisted streams, backend stores only new non-assistant input history rows to avoid duplicates.
|
||||
- `additionalSystemPrompt`, when present directly or loaded from stored chat settings, is prepended to the provider request as a `system` message and is not inserted into the persisted chat transcript by this endpoint.
|
||||
- `enabledTools` limits Sybil-managed tools for this request. When omitted for a saved chat, the stored chat setting is used; otherwise all available tools are enabled by default. An empty array disables Sybil-managed tools.
|
||||
- Optional `reasoningEffort` accepts `null` or `none|minimal|low|medium|high|xhigh|max`. Load the selected provider/model's supported levels from `GET /v1/models` → `reasoningCapabilities` ([REST contract](./rest.md#models)). Omission inherits the chat's saved effort only for the exact same provider/model; `null` explicitly selects Model default. Unknown models and unsupported combinations normalize to `null`; invalid enum strings are rejected. The backend omits the effort parameter for Model default and unsupported combinations, letting the provider choose its model-specific default. `"none"` is an explicit setting and differs from `null`.
|
||||
- Ordinary persisted streams save the effective effort with the last-used provider/model. Non-persistent streams and Quick Questions do not save it. Inline `@sybil` turns use the separate Agent settings. OpenAI Responses requests use `reasoning: { effort }`, and Chat Completions requests use `reasoning_effort`, including subsequent tool rounds. Explicit reasoning efforts other than `none` omit `temperature`; allowlisted reasoning models use Chat Completions `max_completion_tokens` for `maxTokens`. SSE event shapes are unchanged.
|
||||
- `maxTokens` is optional. For `anthropic`, when omitted the backend requests the selected model's maximum output token limit from Anthropic's Models API and uses that as `max_tokens`; if the model limit cannot be loaded, the fallback is 128000. For other providers, omitted `maxTokens` is not sent as an explicit cap.
|
||||
- Attachments are optional and are persisted under `message.metadata.attachments` on stored user messages when `persist` is `true`.
|
||||
- For a persisted ordinary chat, a literal case-insensitive `@sybil` token in the latest user message invokes the existing persistent Sybil Agent instead of the selected provider. Email addresses, code spans/fences, indented code, and Markdown quote lines do not trigger it. The visible user message and inline Agent reply remain in the ordinary chat and are marked with backend-owned `metadata.agentAside`; the backend excludes both from later selected-provider context without deleting the visible rows. This routing does not apply to the special Agent tab or Quick Questions.
|
||||
@@ -112,7 +115,8 @@ Request body:
|
||||
"enabledTools": ["web_search", "fetch_url"],
|
||||
"userLocation": "optional city, region, country",
|
||||
"temperature": 0.2,
|
||||
"maxTokens": 256
|
||||
"maxTokens": 256,
|
||||
"reasoningEffort": null
|
||||
}
|
||||
```
|
||||
|
||||
@@ -122,7 +126,7 @@ Behavior notes:
|
||||
- The server prepends a Quick Question system prompt that asks for a succinct, direct, self-contained answer without follow-up questions. Clients do not send or maintain this prompt.
|
||||
- Quick Questions are always non-persistent. The endpoint does not create a chat or store messages, tool-call logs, assistant output, or `LlmCall` metadata.
|
||||
- The response uses the same `meta`, `tool_call`, `delta`, `done`, and `error` SSE events as chat completion streams. The `meta` event has `chatId: null` and `callId: null`.
|
||||
- `enabledTools`, `temperature`, and `maxTokens` are optional and behave as they do for chat completion streams. When `enabledTools` is omitted, all available Sybil-managed tools are enabled by default.
|
||||
- `enabledTools`, `temperature`, `maxTokens`, and `reasoningEffort` are optional and behave as they do for chat completion streams. When `enabledTools` is omitted, all available Sybil-managed tools are enabled by default. Omitted/null `reasoningEffort` uses the model default; Quick Questions never inherit ordinary chat settings. Existing Quick Question clients omit it.
|
||||
- User location is inferred from the same request headers as chat completion streams when `userLocation` is omitted.
|
||||
|
||||
## Event Stream Contract
|
||||
|
||||
Reference in New Issue
Block a user