Agent Zero AI framework
Add Codex response defaults to OAuth settings
Alessandro4884e26a15fd
diff --git a/plugins/_oauth/AGENTS.md b/plugins/_oauth/AGENTS.mdindex 5264e0820..f7d10aa12 100644--- a/plugins/_oauth/AGENTS.md+++ b/plugins/_oauth/AGENTS.md@@ -45,6 +45,7 @@- Local proxy routes must remain loopback or token protected and must not add broad CORS access.- Codex Responses proxy requests must include Codex client metadata and compatibility headers such as `client_metadata`, `x-codex-installation-id`, `originator`, `session-id`, and `thread-id`, and must forward `input` as a list for upstream Codex compatibility.- Codex Responses proxy requests must translate the legacy top-level `reasoning_effort` field to `reasoning.effort`; an explicit native `reasoning` field takes precedence.+- Codex Responses proxy defaults for reasoning effort, reasoning summary, and text verbosity come from the `codex` plugin config; explicit native request values take precedence.## Work Guidancediff --git a/plugins/_oauth/README.md b/plugins/_oauth/README.mdindex 4833d6d22..6ebc68eef 100644--- a/plugins/_oauth/README.md+++ b/plugins/_oauth/README.md@@ -18,6 +18,7 @@ OAuth-backed model providers do not require users to enter API keys. Agent Zero- Writes Codex-compatible credentials to an Agent Zero-owned `auth.json` file.- Refreshes local tokens when needed.- Exposes the local OpenAI-compatible wrapper at `/oauth/codex/v1`.+- Lets users choose default reasoning effort, visible reasoning summaries, and answer verbosity while preserving explicit per-request settings.### GitHub Copilot (`github_copilot_oauth`)diff --git a/plugins/_oauth/default_config.yaml b/plugins/_oauth/default_config.yamlindex e0be463e4..9bce8b09c 100644--- a/plugins/_oauth/default_config.yaml+++ b/plugins/_oauth/default_config.yaml@@ -25,6 +25,11 @@ codex:models: []request_timeout_seconds: 120+ # Defaults for Codex Responses requests. Explicit model/request values win.+ reasoning_effort: "high"+ reasoning_summary: "auto"+ text_verbosity: "medium"+# The OpenAI-compatible wrapper is mounted at /oauth/codex/v1.# It is loopback-only by default and does not emit CORS headers.proxy_base_path: "/oauth/codex"diff --git a/plugins/_oauth/helpers/codex.py b/plugins/_oauth/helpers/codex.pyindex d79025af4..bc59b0100 100644--- a/plugins/_oauth/helpers/codex.py+++ b/plugins/_oauth/helpers/codex.py@@ -666,9 +666,38 @@ def fetch_models() -> list[str]:def prepare_responses_body(body: dict[str, Any], *, force_stream: bool) -> dict[str, Any]:normalized = dict(body)+ settings = codex_config()reasoning_effort = normalized.pop("reasoning_effort", None)- if reasoning_effort is not None and "reasoning" not in normalized:- normalized["reasoning"] = {"effort": reasoning_effort}+ reasoning = normalized.get("reasoning")+ if isinstance(reasoning, dict):+ reasoning = dict(reasoning)+ elif "reasoning" not in normalized:+ reasoning = {}+ effort = reasoning_effort or settings.get("reasoning_effort", "high")+ if effort != "default":+ reasoning["effort"] = effort+ else:+ reasoning = None+ if reasoning is not None:+ summary = settings.get("reasoning_summary", "auto")+ if summary != "off":+ reasoning.setdefault("summary", summary)+ if reasoning:+ normalized["reasoning"] = reasoning+ else:+ normalized.pop("reasoning", None)++ verbosity = normalized.pop("verbosity", None) or settings.get(+ "text_verbosity", "medium"+ )+ text_config = normalized.get("text")+ if isinstance(text_config, dict):+ text_config = dict(text_config)+ if verbosity != "default":+ text_config.setdefault("verbosity", verbosity)+ normalized["text"] = text_config+ elif "text" not in normalized and verbosity != "default":+ normalized["text"] = {"verbosity": verbosity}input_value = normalized.get("input")if isinstance(input_value, str):normalized["input"] = (diff --git a/plugins/_oauth/helpers/config.py b/plugins/_oauth/helpers/config.pyindex 965de1b12..39d958bb2 100644--- a/plugins/_oauth/helpers/config.py+++ b/plugins/_oauth/helpers/config.py@@ -19,6 +19,9 @@ DEFAULT_CODEX_SCOPES = ["api.connectors.read","api.connectors.invoke",]+CODEX_REASONING_EFFORTS = {"default", "minimal", "low", "medium", "high", "xhigh"}+CODEX_REASONING_SUMMARIES = {"off", "auto", "concise", "detailed"}+CODEX_TEXT_VERBOSITIES = {"default", "low", "medium", "high"}DEFAULT_GEMINI_API_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai"DEFAULT_GEMINI_API_SCOPES = ["openid",@@ -52,6 +55,15 @@ def codex_config(config: dict[str, Any] | None = None) -> dict[str, Any]:"codex_version": _as_str(raw.get("codex_version")),"models": _as_str_list(raw.get("models")),"request_timeout_seconds": _as_int(raw.get("request_timeout_seconds"), 120),+ "reasoning_effort": _as_choice(+ raw.get("reasoning_effort"), CODEX_REASONING_EFFORTS, "high"+ ),+ "reasoning_summary": _as_choice(+ raw.get("reasoning_summary"), CODEX_REASONING_SUMMARIES, "auto"+ ),+ "text_verbosity": _as_choice(+ raw.get("text_verbosity"), CODEX_TEXT_VERBOSITIES, "medium"+ ),"proxy_base_path": _normalize_base_path(raw.get("proxy_base_path"), "/oauth/codex"),"callback_path": _normalize_base_path(raw.get("callback_path"), "/auth/callback"),"require_proxy_token": _as_bool(raw.get("require_proxy_token"), False),@@ -104,6 +116,11 @@ def _as_bool(value: Any, default: bool) -> bool:return default+def _as_choice(value: Any, choices: set[str], default: str) -> str:+ normalized = _as_str(value).lower()+ return normalized if normalized in choices else default++def _as_str_list(value: Any) -> list[str]:if value is None:return []diff --git a/plugins/_oauth/webui/config.html b/plugins/_oauth/webui/config.htmlindex 124af270a..5df9c6415 100644--- a/plugins/_oauth/webui/config.html+++ b/plugins/_oauth/webui/config.html@@ -124,6 +124,43 @@</label></div>+ <div class="oauth-response-defaults" x-show="card.provider_id === 'codex_oauth'">+ <div class="oauth-response-defaults-head">+ <strong>Codex response defaults</strong>+ <span>Applied when an individual model request does not override them.</span>+ </div>+ <label class="oauth-provider-input">+ <span>Reasoning effort</span>+ <select x-model="$store.oauthConfig.codex().reasoning_effort" name="codex_reasoning_effort">+ <option value="default">Model default</option>+ <option value="minimal">Minimal</option>+ <option value="low">Low</option>+ <option value="medium">Medium</option>+ <option value="high">High</option>+ <option value="xhigh">Extra high</option>+ </select>+ </label>+ <label class="oauth-provider-input">+ <span>Reasoning summary</span>+ <select x-model="$store.oauthConfig.codex().reasoning_summary" name="codex_reasoning_summary">+ <option value="auto">Auto</option>+ <option value="concise">Concise</option>+ <option value="detailed">Detailed</option>+ <option value="off">Off</option>+ </select>+ </label>+ <label class="oauth-provider-input">+ <span>Answer verbosity</span>+ <select x-model="$store.oauthConfig.codex().text_verbosity" name="codex_text_verbosity">+ <option value="default">Model default</option>+ <option value="low">Low</option>+ <option value="medium">Medium</option>+ <option value="high">High</option>+ </select>+ </label>+ <p class="oauth-provider-note">Effort controls reasoning depth, summaries appear while the agent works, and verbosity shapes the final answer.</p>+ </div>+<div class="oauth-device" x-show="$store.oauthConfig.providerDevice(card.provider_id)?.user_code"><span>Enter this code</span><strong x-text="$store.oauthConfig.providerDevice(card.provider_id)?.user_code"></strong>@@ -588,6 +625,35 @@gap: 8px;}+ .oauth-response-defaults {+ display: grid;+ grid-template-columns: repeat(3, minmax(0, 1fr));+ gap: 10px;+ padding: 12px;+ border: 1px solid color-mix(in srgb, var(--color-border) 74%, transparent);+ border-radius: 8px;+ background: color-mix(in srgb, var(--color-panel) 82%, transparent);+ }++ .oauth-response-defaults-head,+ .oauth-response-defaults .oauth-provider-note {+ grid-column: 1 / -1;+ }++ .oauth-response-defaults-head {+ display: grid;+ gap: 2px;+ }++ .oauth-response-defaults-head strong {+ font-size: 0.84rem;+ }++ .oauth-response-defaults-head span {+ color: var(--color-text-secondary);+ font-size: 0.76rem;+ }+.oauth-manual-callback {grid-template-columns: minmax(0, 1fr) auto auto;align-items: center;@@ -611,6 +677,7 @@}.oauth-provider-input input,+ .oauth-provider-input select,.oauth-manual-callback input {width: 100%;min-width: 0;@@ -1162,6 +1229,7 @@@media (max-width: 720px) {.oauth-device,+ .oauth-response-defaults,.oauth-provider-row-detail,.oauth-provider-usage,.oauth-status-row,diff --git a/plugins/_oauth/webui/oauth-config-store.js b/plugins/_oauth/webui/oauth-config-store.jsindex bf8349570..36ebb64db 100644--- a/plugins/_oauth/webui/oauth-config-store.js+++ b/plugins/_oauth/webui/oauth-config-store.js@@ -51,6 +51,9 @@ function ensureConfig(config) {codex.proxy_token = String(codex.proxy_token || "");codex.codex_version = String(codex.codex_version || "");codex.models = Array.isArray(codex.models) ? codex.models : [];+ codex.reasoning_effort = String(codex.reasoning_effort || "high");+ codex.reasoning_summary = String(codex.reasoning_summary || "auto");+ codex.text_verbosity = String(codex.text_verbosity || "medium");config.gemini_api = config.gemini_api && typeof config.gemini_api === "object" ? config.gemini_api : {};const geminiApi = config.gemini_api;diff --git a/tests/test_oauth_codex.py b/tests/test_oauth_codex.pyindex 5d52734b1..ab0e71c9a 100644--- a/tests/test_oauth_codex.py+++ b/tests/test_oauth_codex.py@@ -204,16 +204,21 @@ def test_prepare_responses_body_adds_codex_client_metadata(monkeypatch):}assert body["input"] == [{"role": "user", "content": "hello"}]assert body["stream"] is True+ assert body["reasoning"] == {"effort": "medium", "summary": "auto"}assert body["include"] == ["output_text", "reasoning.encrypted_content"]@pytest.mark.parametrize(("request_reasoning", "expected"),[- ({"reasoning_effort": "xhigh"}, {"effort": "xhigh"}),+ ({"reasoning_effort": "xhigh"}, {"effort": "xhigh", "summary": "auto"}),({"reasoning": {"effort": "medium"}, "reasoning_effort": "xhigh"},- {"effort": "medium"},+ {"effort": "medium", "summary": "auto"},+ ),+ (+ {"reasoning": {"effort": "medium", "summary": "detailed"}},+ {"effort": "medium", "summary": "detailed"},),],)@@ -231,6 +236,55 @@ def test_prepare_responses_body_normalizes_reasoning_effort(assert "reasoning_effort" not in body+def test_prepare_responses_body_applies_codex_response_defaults(monkeypatch):+ monkeypatch.setattr(codex, "build_client_metadata", lambda: {})+ monkeypatch.setattr(+ codex,+ "codex_config",+ lambda: {+ "reasoning_effort": "high",+ "reasoning_summary": "concise",+ "text_verbosity": "low",+ },+ )++ defaults = codex.prepare_responses_body(+ {"model": "gpt-5.5", "input": "hello"}, force_stream=True+ )+ overrides = codex.prepare_responses_body(+ {+ "model": "gpt-5.5",+ "input": "hello",+ "reasoning": {"effort": "low", "summary": "detailed"},+ "text": {"verbosity": "high"},+ },+ force_stream=True,+ )++ assert defaults["reasoning"] == {"effort": "high", "summary": "concise"}+ assert defaults["text"] == {"verbosity": "low"}+ assert overrides["reasoning"] == {"effort": "low", "summary": "detailed"}+ assert overrides["text"] == {"verbosity": "high"}+++def test_codex_config_validates_response_defaults():+ from plugins._oauth.helpers.config import codex_config++ config = codex_config(+ {+ "codex": {+ "reasoning_effort": "invalid",+ "reasoning_summary": "DETAILED",+ "text_verbosity": "low",+ }+ }+ )++ assert config["reasoning_effort"] == "high"+ assert config["reasoning_summary"] == "detailed"+ assert config["text_verbosity"] == "low"++def test_prepare_responses_body_sends_empty_continuation_input_as_list(monkeypatch):monkeypatch.setattr(codex, "build_client_metadata", lambda: {})diff --git a/tests/test_oauth_static.py b/tests/test_oauth_static.pyindex 50a01ec91..00360b57d 100644--- a/tests/test_oauth_static.py+++ b/tests/test_oauth_static.py@@ -61,6 +61,10 @@ def test_oauth_settings_exposes_provider_specific_controls_and_generic_copy():assert "supports_quota_project" in config_html + store_jsassert "OAuth client ID" in config_htmlassert "quota_project_id" in config_html + store_js+ assert "Codex response defaults" in config_html+ assert "$store.oauthConfig.codex().reasoning_effort" in config_html+ assert "$store.oauthConfig.codex().reasoning_summary" in config_html+ assert "$store.oauthConfig.codex().text_verbosity" in config_htmlassert "providerDetailOpen(card.provider_id)" in config_html + store_jsassert "providerDevice(card.provider_id)?.user_code" in config_htmlassert "submitManualCallback(card.provider_id)" in config_html