Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Fix more

mertunsall1c9a87b98f63
diff --git a/browser_use/llm/schema.py b/browser_use/llm/schema.py
index 5477cc4b7..8ecd60f61 100644
--- a/browser_use/llm/schema.py
+++ b/browser_use/llm/schema.py
@@ -57,9 +57,9 @@ class SchemaOptimizer:
if value: # Only include non-empty descriptions
optimized[key] = value
- # Handle type field
+ # Handle type field - must recursively process in case value contains $ref
elif key == 'type':
- optimized[key] = value
+ optimized[key] = value if not isinstance(value, (dict, list)) else optimize_schema(value, defs_lookup)
# FLATTEN: Resolve $ref by inlining the actual definition
elif key == '$ref' and defs_lookup:
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index 1fbeacc18..95739f49b 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -1,5 +1,4 @@
import asyncio
-import enum
import json
import logging
import os
@@ -1282,12 +1281,8 @@ Validated Code (after quote fixing):
)
async def done(params: StructuredOutputAction):
# Exclude success from the output JSON since it's an internal parameter
- output_dict = params.data.model_dump()
-
- # Enums are not serializable, convert to string
- for key, value in output_dict.items():
- if isinstance(value, enum.Enum):
- output_dict[key] = value.value
+ # Use mode='json' to properly serialize enums at all nesting levels
+ output_dict = params.data.model_dump(mode='json')
return ActionResult(
is_done=True,