Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix output format for AWS Bedrock#4217

Open
DenDark77 wants to merge 6 commits intobrowser-use:mainfrom
DenDark77:fix-aws-nova-validation
Open

Fix output format for AWS Bedrock#4217
DenDark77 wants to merge 6 commits intobrowser-use:mainfrom
DenDark77:fix-aws-nova-validation

Conversation

@DenDark77
Copy link

@DenDark77 DenDark77 commented Feb 26, 2026

Fix: AWS Bedrock Nova validation for browser-use action schemas

Problem

Issue: #3371

AWS Bedrock’s converse() API does not properly handle browser-use’s complex union-type action schemas, especially when using Nova Lite models.

Expected behavior

The agent should be able to call actions (e.g. click, input, navigate) with the correct field names.

Actual behavior

  • Wrong field names: AWS Bedrock returns {"click": {"element": 9}} instead of {"click": {"index": 9}}.
  • Incomplete schema: Only the first action type (done) appears in the schema sent to Bedrock.
  • Union types: anyOf / oneOf are not converted correctly for the Bedrock API.

Example error

WARNING  [Agent] ⚠️ LLM error (ModelProviderError: Failed to validate structured output: 48 validation errors for AgentOutput
  plan_update
    Input should be a valid list [type=list_type, input_value='["Check for cookie conse...ick on Explore button"]', input_type=str]
  action.0.DoneActionModel.done
    Field required [type=missing, input_value={'click': {'element': 11}}, input_type=dict]
  action.0.DoneActionModel.click
    Extra inputs are not permitted [type=extra_forbidden, input_value={'element': 11}, input_type=dict]
  action.0.ClickActionModel.click.index
    Field required [type=missing, input_value={'element': 11}, input_type=dict]
  ...
) but no fallback_llm configured

The model returns element instead of index for click, and the full union of action types is not represented in the schema, leading to many Pydantic validation errors.


Fix

Use SchemaOptimizer to resolve the problem with $ref and $defs so that the schema sent to Bedrock correctly represents all action types and field names.


Verification

After applying the fix, the agent runs without these validation errors:

INFO     [Agent] 📍 Step 1:
INFO     [Agent]   🧠 Memory: Initial page loaded at https://boosterprep.com. Detected a cookie consent modal with an 'Accept' button. Need to handle cookie consent before proceeding with test steps.
INFO     [Agent]   🎯 Next goal: Handle cookie consent modal by clicking the 'Accept' button
INFO     [Agent]   ▶️   click: index: 119
INFO     [tools] 🖱️ Clicked button "Accept"
INFO     [Agent] 📋 Plan updated with 2 steps

INFO     [Agent] 📍 Step 2:
INFO     [Agent]   🧠 Memory: Handled cookie consent modal by clicking 'Accept' button. Page now shows main content with navigation menu and 'Explore' button visible.
INFO     [Agent]   🎯 Next goal: Click on Explore button
INFO     [Agent]   ▶️   click: index: 25
INFO     [tools] 🖱️ Clicked button "Explore"
INFO     [Agent] 📋 Plan updated with 2 steps

Actions like click now use the correct index field and execute successfully.


Summary by cubic

Fix AWS Bedrock Nova/Nova Lite structured output by sending the full optimized JSON schema for actions. This restores correct field names and stops validation errors.

  • Bug Fixes

    • Use SchemaOptimizer.create_optimized_json_schema and pass it to toolSpec.inputSchema.json, preserving $ref/$defs and anyOf/oneOf.
    • Ensure action payloads use correct field names (index instead of element).
  • Refactors

    • Simplified tool schema building and cleaned up imports in chat_bedrock.py.

Written for commit 9a62f5e. Summary will update on new commits.

@CLAassistant
Copy link

CLAassistant commented Feb 26, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@DenDark77 DenDark77 changed the title Fix output format Fix output format for AWS Bedrock Feb 26, 2026
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