feat(webui): add session-scoped reasoning effort (#6441)
* feat(webui): add session-scoped model options Extend the composer preset menu with inherited reasoning effort and Codex Fast mode overrides. Persist choices with ordinary inputs, isolate captured runtimes, and restore browser preferences without changing shared presets. Add regression coverage for pending preset ordering, settings initialization, session and host isolation, queue edits, Codex request mapping, and narrow-screen controls. * feat(webui): refine session model options and add Codex Ultrafast Fit the composer options into a compact single row and preview reasoning effort only during a drag. Add Fast/Ultrafast controls for eligible Codex models, preserve explicit session choices across reloads, and document the speed tiers. * fix(webui): add Codex speed control to the component gallery * fix(webui): preserve saved model options after preset rename Use the session options for display when a browser preference no longer matches the preset. Omit model options from the next message unless the browser has a matching choice, so stale preferences cannot overwrite options the gateway already saved.
This commit is contained in:
1 parent
2b232c9133
commit
0f45d74fec
82 files changed
+2289
-113
No files matched your search
@@ -1493,3 +1493,72 @@ async def test_codex_request_preserves_optional_tool_fields(monkeypatch):
|
||||
assert response.content == "ok"
|
||||
assert captured["tools"][0]["strict"] is False
|
||||
assert captured["tools"][0]["parameters"] == parameters
|
||||
|
||||
|
||||
@pytest.mark.parametrize("configured", [None, "priority"])
|
||||
async def test_codex_session_fast_mode_overrides_inherited_body_without_mutating_provider(
|
||||
monkeypatch, configured,
|
||||
) -> None:
|
||||
from nanobot.providers.model_options import ModelOptions
|
||||
|
||||
_mock_codex_token(monkeypatch)
|
||||
bodies: list[dict[str, Any]] = []
|
||||
|
||||
async def fake_request(_url, _headers, body, **_kwargs):
|
||||
bodies.append(body)
|
||||
return provider_base.LLMResponse(content="synthetic answer")
|
||||
|
||||
monkeypatch.setattr("nanobot.providers.openai_codex_provider._request_codex", fake_request)
|
||||
extra_body: dict[str, Any] = {"text": {"verbosity": "low"}}
|
||||
if configured is not None:
|
||||
extra_body["service_tier"] = configured
|
||||
provider = OpenAICodexProvider(extra_body=extra_body)
|
||||
for choice in (None, True, False, None):
|
||||
await provider.chat(
|
||||
[{"role": "user", "content": "synthetic prompt"}],
|
||||
reasoning_effort="low",
|
||||
provider_context=provider_base.ProviderCallContext(
|
||||
model_options=ModelOptions(codex_fast_mode=choice),
|
||||
),
|
||||
)
|
||||
assert [body.get("service_tier") for body in bodies] == [configured, "priority", None, configured]
|
||||
assert all(body["reasoning"]["effort"] == "low" for body in bodies)
|
||||
assert all(body["text"] == {"verbosity": "low"} for body in bodies)
|
||||
assert extra_body == {"text": {"verbosity": "low"}, **({"service_tier": configured} if configured else {})}
|
||||
await provider.aclose()
|
||||
|
||||
|
||||
async def test_codex_session_overrides_preset_wire_fields_without_changing_other_options(monkeypatch):
|
||||
from nanobot.providers.model_options import ModelOptions
|
||||
|
||||
_mock_codex_token(monkeypatch)
|
||||
bodies: list[dict[str, Any]] = []
|
||||
|
||||
async def fake_request(_url, _headers, body, **_kwargs):
|
||||
bodies.append(body)
|
||||
return provider_base.LLMResponse(content="synthetic answer")
|
||||
|
||||
monkeypatch.setattr("nanobot.providers.openai_codex_provider._request_codex", fake_request)
|
||||
config = Config.model_validate({
|
||||
"providers": {"openaiCodex": {"extraBody": {"service_tier": "priority"}}},
|
||||
"modelPresets": {
|
||||
"standard": {"model": "gpt-6.2-sol", "provider": "openai_codex", "codexFastMode": "ultrafast",
|
||||
"extraBody": {"reasoning": {"effort": "high", "summary": "detailed"}}},
|
||||
},
|
||||
})
|
||||
provider = make_provider(config, preset_name="standard")
|
||||
try:
|
||||
for options in (ModelOptions(), ModelOptions("low", True), ModelOptions(codex_fast_mode=False),
|
||||
ModelOptions(codex_fast_mode="ultrafast"), ModelOptions()):
|
||||
await provider.chat(
|
||||
[{"role": "user", "content": "synthetic prompt"}],
|
||||
reasoning_effort=options.reasoning_effort,
|
||||
provider_context=provider_base.ProviderCallContext(model_options=options),
|
||||
)
|
||||
finally:
|
||||
await provider.aclose()
|
||||
assert [body.get("service_tier") for body in bodies] == ["ultrafast", "priority", None, "ultrafast", "ultrafast"]
|
||||
assert "service_tier" not in bodies[2]
|
||||
assert [body["reasoning"] for body in bodies] == [
|
||||
{"effort": effort, "summary": "detailed"} for effort in ["high", "low", "high", "high", "high"]
|
||||
]
|
||||
Reference in new issue
Block a user