Commit Graph

56 Commits

Author SHA1 Message Date
MagMueller e0737a614f fix(vercel): preserve provider error status 2026-08-30 23:23:18 -07:00
MagMueller fb916aec56 fix(vercel): require gateway credentials 2026-08-30 23:16:08 -07:00
MagMueller 7d123b7628 Merge branch 'main' into agency/fix-openrouter-5598 2026-08-30 23:16:08 -07:00
Magnus Müller 90eb2b42de Merge branch 'main' into fix/bedrock-zero-retries 2026-08-30 19:14:28 -07:00
MagMueller b2507091aa test: cover aliased schema keyword fields 2026-08-30 14:56:47 -07:00
MagMueller c48b1c9928 fix(llm): preserve schema-keyword field names 2026-08-30 14:48:44 -07:00
MagMueller edfccc4078 test(openrouter): assert request parameters are forwarded 2026-08-29 11:08:31 -07:00
MagMueller f356f2ed3e fix(openrouter): validate client and response inputs 2026-08-29 10:57:03 -07:00
Aniket Wagh a266399645 fix(llm/google): keep the first user message when include_system_in_user is set 2026-08-29 20:27:38 +05:30
Magnus Müller 56b76ddbad Merge branch 'main' into fix/5543-ignore-empty-reasoning-models 2026-08-27 17:38:05 -07:00
MagMueller ed5f467957 fix(llm): handle Ollama chat params and JSON fences 2026-08-27 12:20:20 -07:00
Burak Keskin 1b2f2bb4f5 fix(llm): stop putting format/stream inside Ollama options
Ollama treats those as top-level chat() parameters. Forwarding them in ollama_options broke structured JSON from vision models, which is the failure in #5017.
2026-08-27 12:20:20 -07:00
ECD5A 6cd3fffca3 fix(llm): ignore empty reasoning model patterns 2026-08-25 12:21:42 +05:00
Saurav Panda 5953df7d2f fix(llm): make bu-2-0 the default again, keep mini opt-in
0.13.8 shipped bu-2-0-mini-preview as the ChatBrowserUse default, which
means Agent(task=...) with no llm - and every bare ChatBrowserUse() -
silently moved onto a preview model on upgrade, with no code change on
the caller's side.

Two problems with that. A preview id can change behaviour or be renamed,
so it is the wrong thing to reach by omission. And per-token price is the
wrong yardstick for an agent: total cost is tokens-per-step times steps,
and steps is a function of model quality, so a cheaper-per-token model
that needs more steps to finish can cost more and take longer. We do not
yet have a per-task benchmark number for mini to say which way that goes.

bu-2-0-mini-preview stays a first-class option: still accepted, still
priced, still what the examples demonstrate. It is just opted into by
name now rather than landed on by default. Revisit once the benchmark
number exists.
2026-08-17 09:19:26 -07:00
cosin2077 5ec35bea56 fix(llm): preserve zero retries for Anthropic Bedrock 2026-08-15 10:41:54 +08:00
Saurav Panda d762a8359e test: cover the llm.bu_2_0_mini_preview attribute, not just the factory
The shortcut test called get_llm_by_name directly, which bypasses the
module __getattr__ and __all__ that the shortcut actually goes through -
so dropping the name from __all__ would not have failed anything.
2026-08-13 11:33:53 -07:00
Saurav Panda b1d1794a93 fix(tokens): bill bu-1-0 at bu-2-0 rates
bu-1-0 is redirected to bu-2-0 at the gateway, so requests naming it are
served and billed as bu-2-0. The pricing table still carried the retired
bu-1-0 rates, which under-reported cost by 3x on input and 3x on cached
reads for anyone still passing that id.

Aliases it to the bu-2-0 entry rather than duplicating the numbers, same
as bu-latest, so the three cannot drift apart.
2026-08-13 11:16:52 -07:00
Saurav Panda 9be28bcea1 feat(llm): default ChatBrowserUse to bu-2-0-mini-preview
Adds bu-2-0-mini-preview as an accepted model id and makes it the
constructor default, so a bare ChatBrowserUse() now routes there.

bu-2-0 is unchanged: still accepted, still documented as the premium
option, and bu-latest still resolves to it. Keeping 'latest' on the
stable line means existing callers pinned to that alias do not silently
move onto a preview model; only the bare-constructor default moves.

Pricing is registered alongside the model so cost tracking does not
silently report $0 for what is now the default. This model has no cache
discount, so cached reads bill at the input rate.

Examples, README and the model reference are updated to the new default.
The model reference also claimed bu-latest resolved to bu-1-0, which has
not been true since bu-2-0 shipped; corrected here.
2026-08-13 11:05:57 -07:00
Magnus Müller 8b56f3c759 Merge branch 'main' into fix/bedrock-anthropic-empty-content-indexerror 2026-08-02 15:23:19 -07:00
Magnus Müller 0a59008f6a Merge branch 'main' into fix/groq-tool-calling-structured-output 2026-08-02 15:20:55 -07:00
VenkateswarluNagineni a223ff289e fix(llm): preserve ModelProviderError status code in Groq ainvoke
The structured-output guards raise ModelProviderError with status_code=500,
but ainvoke's final `except Exception` re-wrapped them with the default 502
and a stringified message. Let our own ModelProviderError through unchanged so
the status code and message reported to callers stay accurate. This also fixes
the pre-existing 'No content in response' guard on the JSON-schema path.
2026-07-31 18:34:17 -05:00
VenkateswarluNagineni 81526cd337 fix(llm): read structured output from tool calls for Groq tool-calling models
_invoke_structured_output branches to _invoke_with_tool_calling for models in
ToolCallingModels, which sends tool_choice='required'. Groq then returns the
payload in tool_calls[0].function.arguments and leaves message.content empty,
but the content guard ran for both branches, so structured output raised
ModelProviderError('No content in response') for every tool-calling model.

Parse the payload from the tool call on that branch, mirroring the deepseek
provider, and keep the content guard on the JSON-schema branch. An empty
tool_calls list now reports a provider error rather than reading content that
is never populated.

Fixes #4945
2026-07-31 18:34:17 -05:00
Ryan Loney ae9d11cc1b Fix Cerebras GLM alias resolution 2026-07-30 17:02:46 -04:00
Mark McDonald a567c6dacf Merge branch 'main' into gemini-params 2026-07-20 08:48:31 +05:30
Andrew Chen 21dcbaa29c Fix ChatAnthropicBedrock.ainvoke() IndexError on an empty response.content list
ainvoke() unconditionally indexes response.content[0] to extract the reply
text. Bedrock can legitimately return an empty content list for certain
stop-reason edge cases (e.g. the turn ends before any content block is
produced) -- when that happens, this raises IndexError, which the
surrounding try/except then re-raises as an opaque ModelProviderError,
crashing the caller instead of returning empty text.

The sibling direct-Anthropic implementation (browser_use/llm/anthropic/
chat.py's _extract_content_blocks) already guards this exact case with
`elif response.content: ... else: completion = ''` -- strong evidence this
is a real, previously-encountered scenario for the underlying Claude
message API, just missing from the Bedrock-transport variant of the same
contract.

Fix: mirror the sibling's guard -- only index into response.content when
it's non-empty, otherwise fall back to an empty string.

Added tests/ci/models/test_chat_anthropic_bedrock_empty_content.py, which
constructs a real anthropic.types.Message with content=[] (no mocking of
the SDK's own types, only the network-boundary client per this repo's
"mock only the LLM" testing convention) and confirms ainvoke() returns an
empty completion instead of raising. Confirmed red -> green: reverting only
the source change reproduces `ModelProviderError: list index out of range`;
reapplying passes.

ruff check / ruff format / pyright: clean.

xref: open PR #5053 also touches this file, but a different function
entirely (_get_usage's total_tokens calculation, ~line 152) -- no overlap
with this change (ainvoke's content extraction, ~line 187).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-15 15:08:10 +08:00
Alexander Yue 4b1cc6375a feat: accept bu-qa-1 model alias in ChatBrowserUse 2026-07-14 12:46:07 -07:00
Mark McDonald 8b38ec09d8 fix: dont send default params in gemini genconfig
Gemini 3+ models may throw errors if a default value is set for
parameters like temperature, top-p, etc.

The 3-series models use 1.0 as the default temperature, so this
should be a backwards-compatible change.
2026-07-08 17:47:10 +08:00
Saurav Panda e29cdeae06 fix(tests): bump retired claude-sonnet-4-0 to claude-sonnet-4-6
Anthropic retired Claude Sonnet 4 (claude-sonnet-4-0 /
claude-sonnet-4-20250514) on 2026-06-15. The live-API model test in
tests/ci/models/test_llm_anthropic.py pinned that alias, so every CI run
now gets a 404 not_found_error and the agent never completes the task,
failing the models/test_llm_anthropic job on all branches.

Bump the test to the current GA Sonnet (claude-sonnet-4-6).
2026-06-26 12:22:17 +08:00
Saurav Panda 47a52790a6 chore(llm): remove bu-3 / bu-3-max, default beta example to openai/gpt-5.5
Drop the bu-3 and bu-3-max model ids everywhere they were surfaced:
- ChatBrowserUse no longer lists them as valid bu-* aliases (provider-prefixed
  ids like openai/gpt-5.5 are still accepted by the gateway).
- Remove their custom pricing entries and the README pricing blocks.
- Update docstrings, README quickstart, and the beta_agent example to use
  openai/gpt-5.5 as the default, with bu-2-0 shown as a commented alternative.
- Drop the tests that asserted bu-3/bu-3-max acceptance and pricing.
2026-06-11 22:50:30 +05:30
Saurav Panda 4cbc5dfa4d feat(llm): accept provider-prefixed models in ChatBrowserUse
ChatBrowserUse now accepts provider-prefixed model ids (anthropic/*,
openai/*, google/*) alongside the bu-* aliases and browser-use/* models,
so a single BROWSER_USE_API_KEY can reach them. bu-* aliases and the
bu-latest -> bu-2-0 normalization are unchanged; bare ids are rejected
with guidance toward the provider/model form.

Also matches provider-prefixed Claude Sonnet ids in the Agent
llm_screenshot_size auto-config, so the screenshot optimization isn't
lost when Claude is reached via ChatBrowserUse.

Adds an example, a README FAQ entry, and tests.

ENG-5060
2026-06-10 12:03:51 +05:30
Magnus Müller 65f6b3493f Expose terminal SDK tools by default 2026-06-05 18:33:03 +00:00
Magnus Müller 474a06b0c1 Deduplicate Rust SDK history usage 2026-06-05 18:18:23 +00:00
Magnus Müller 1474c60da1 Merge remote-tracking branch 'upstream/main' into magnus/browser-use-rust-core-integration
# Conflicts:
#	browser_use/__init__.py
#	browser_use/agent/service.py
#	browser_use/browser/watchdogs/downloads_watchdog.py
#	browser_use/code_use/utils.py
#	browser_use/llm/models.py
#	browser_use/tokens/service.py
#	browser_use/utils.py
2026-06-04 16:14:57 +00:00
Magnus Müller 9c9fa4d722 Resolve Anthropic default LLM names 2026-06-03 17:00:36 +00:00
MagMueller 22939a2580 Revert "feat(llm/google): forward cached_content into generate_content (#4889)"
This reverts commit 5a745a8502, reversing
changes made to 640360e9b7.
2026-05-23 12:03:38 -07:00
Saurav Panda df063f9068 feat(llm/google): forward cached_content into generate_content
Adds a cached_content field on ChatGoogle (and a per-call kwarg on
ainvoke) that gets threaded into the GenerateContentConfigDict before
each generate_content call. This lets callers point Gemini at an
explicit CachedContent resource (e.g. "cachedContents/abc123") instead
of relying on implicit caching, which is constrained by the ~5-minute
TTL window.

Token accounting already pulls cached_content_token_count from
response.usage_metadata into ChatInvokeUsage.prompt_cached_tokens, so
the savings show up in usage stats without further work.

Cache creation itself (client.caches.create) is left to the caller —
this PR only adds the forwarding hook so explicit caching becomes
opt-in usable. A follow-up can wire agent-side cache lifecycle if
useful.
2026-05-22 17:54:04 -07:00
Saurav Panda b00c41b66b chore(llm): recommend gemini-3-flash-preview in examples and tests
- add gemini-3-flash-preview-lite to VerifiedGeminiModels and token mappings
- list both gemini-3-flash-preview[-lite] alongside existing -latest aliases in CLOUD.md and api-v2.md SupportedLLMs
- swap example code and recommendations (examples/, AGENTS.md, quickstart.md, bug report placeholder) to gemini-3-flash-preview / -lite
- update Google CI test + evaluate_tasks judge LLM to gemini-3-flash-preview / -lite
2026-05-22 10:47:58 -07:00
Mark McDonald 115199d2ba fix: handle types.HttpOptionsDict better, add more tests 2026-05-22 14:30:40 +08:00
Mark McDonald 2eb3e3cded feat: add client header to GoogleChat
Added header per integration
[guidelines](https://ai.google.dev/gemini-api/docs/partner-integration).
2026-05-22 14:20:24 +08:00
Saurav Panda 29c9f1a416 feat: add support for openai responses model 2025-12-22 22:16:56 -08:00
matt-greathouse d3f60a76fe Remove stripping of required fields from gemini optimized schema 2025-10-31 15:54:51 -04:00
Magnus Müller 3a1db137bb api key not required 2025-10-25 18:00:18 -07:00
Magnus Müller 9313097a84 Remove openrouter 2025-10-25 10:27:06 -07:00
Magnus Müller 16d8833048 Api key rename 2025-10-25 10:24:40 -07:00
Magnus Müller 3742377fa3 Linter 2025-10-25 10:20:40 -07:00
Magnus Müller f60fedb01d Env 2025-10-25 10:20:31 -07:00
Magnus Müller 6e31a05acd Split model tests 2025-10-25 10:16:46 -07:00
Magnus Müller 5b481ac5ee Linter 2025-10-25 09:59:37 -07:00
Magnus Müller ba79f4df88 Linter 2025-10-25 09:59:30 -07:00
Magnus Müller a991e19d75 Remove some models 2025-10-25 09:58:59 -07:00