Skip to content

Forward GPT reasoning effort through LiteLLM - #112

Merged
waple0820 merged 1 commit into
lexmount:mainfrom
XuweiDing04:agent/forward-gpt-reasoning-effort
Jul 27, 2026
Merged

Forward GPT reasoning effort through LiteLLM#112
waple0820 merged 1 commit into
lexmount:mainfrom
XuweiDing04:agent/forward-gpt-reasoning-effort

Conversation

@XuweiDing04

Copy link
Copy Markdown
Contributor

Summary

Fix GPT reasoning-effort requests through the LiteLLM 1.93 gateway.

The browser-use adapter already forwarded reasoning_effort and registered custom
gateway model aliases as reasoning models. However, LiteLLM rejected the request
before forwarding it:

UnsupportedParamsError: azure does not support parameters: ['reasoning_effort']

LiteLLM's documented per-request escape hatch is
allowed_openai_params. This change:

  • adds allowed_openai_params: [reasoning_effort] to the GPT-5.6 Sol example;
  • reads that setting when _create_llm builds an OpenAI Chat Completions model;
  • injects the allowlist through OpenAI SDK extra_body on every request, because
    the pinned browser-use ChatOpenAI does not expose extra_body as a
    constructor option;
  • preserves and de-duplicates any request-level allowlist instead of overwriting it;
  • reuses the same request wrapper for the existing Claude-thinking path;
  • rejects Azure/Responses model types explicitly because this wrapper targets
    client.chat.completions.create.

Reference: LiteLLM parameter handling.

Contribution type

  • Agent adapter
  • Browser backend
  • Benchmark task or data
  • Leaderboard/result submission
  • Evaluation or judge strategy
  • Documentation/example
  • Bug fix

Reproduction or validation

Tests and static checks:

uv run pytest tests/browseruse_bench/test_browser_use_agent.py
# 40 passed

uv run pytest tests/
# 825 passed, 2 skipped

uv run ruff check browseruse_bench/agents/browser_use.py tests/browseruse_bench/test_browser_use_agent.py
# All checks passed

Focused real gateway smoke through the changed _create_llm and ainvoke path:

llm = BrowserUseAgent()._create_llm(
    "OPENAI",
    "gpt-5.6-sol",
    {
        "api_key": os.environ["OPENAI_API_KEY"],
        "base_url": os.environ["OPENAI_BASE_URL"],
        "reasoning_effort": "xhigh",
        "allowed_openai_params": ["reasoning_effort"],
        "max_tokens": 64,
    },
    config_info,
)
response = await llm.ainvoke([UserMessage(content="Reply with exactly OK.")])

Observed:

response='OK'
config={'reasoning_effort': 'xhigh', 'max_tokens': 64,
        'allowed_openai_params': ['reasoning_effort'], ...}

This validation deliberately exercises the actual model construction, browser-use
request serialization, LiteLLM gateway, and upstream response without launching a
browser task; no credentials or unredacted request logs are included.

Result artifacts

Not applicable.

Self-review (mandatory)

See Mandatory Self-Review.
PRs with unticked boxes are returned without review. / 以下勾选项未完成的 PR 会被直接打回。

  • I read every line of my diff and every change is intentional
    / 我逐行读完了自己的 diff,每处改动都是有意为之
  • The diff passes the hard rules in CONTRIBUTING.md (logger not print, specific exceptions,
    no hardcoded config, imports at top) / diff 符合 CONTRIBUTING.md 的硬性红线
  • I ran a local /code-review and fixed or justified every finding
    / 本地跑过 /code-review,findings 已全部修复或说明理由
  • uv run pytest tests/ passes and behavior changes have targeted tests
    / 测试通过,行为变更配了针对性测试
  • Agent-touching change: real smoke run evidence is included above, or this PR does not
    touch any agent runtime path / 涉及 agent 运行路径的改动已附真实 smoke run 证据,或本
    PR 不涉及 agent 运行路径
  • No secrets, cookies, or unredacted logs in the diff / diff 中无密钥、cookie、未脱敏日志

Notes for reviewers

The passthrough setting is intentionally limited to OPENAI Chat Completions
models. Azure SDK models default to the Responses path in the pinned browser-use
version, so advertising this Chat Completions wrapper there would be misleading.

@waple0820
waple0820 marked this pull request as ready for review July 27, 2026 04:08
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@waple0820
waple0820 merged commit 09999b1 into lexmount:main Jul 27, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants