Skip to content

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

Fix #759

XxAlonexXba884a28f944
diff --git a/browser_use/agent/views.py b/browser_use/agent/views.py
index 15480eb64..a8be0bdc6 100644
--- a/browser_use/agent/views.py
+++ b/browser_use/agent/views.py
@@ -111,7 +111,11 @@ class AgentOutput(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
current_state: AgentBrain
- action: list[ActionModel]
+ action: list[ActionModel] = Field(
+ ..., # This means the field is required
+ description="List of actions to execute",
+ min_items=1, # Ensure at least one action is provided
+ )
@staticmethod
def type_with_custom_actions(custom_actions: Type[ActionModel]) -> Type['AgentOutput']:
@@ -119,10 +123,17 @@ class AgentOutput(BaseModel):
model_ = create_model(
'AgentOutput',
__base__=AgentOutput,
- action=(list[custom_actions], Field(...)), # Properly annotated field with no default
+ action=(
+ list[custom_actions],
+ Field(
+ ...,
+ description="List of actions to execute",
+ min_items=1
+ )
+ ),
__module__=AgentOutput.__module__,
)
- model_.__doc__ = 'AgentOutput model'
+ model_.__doc__ = 'AgentOutput model with custom actions'
return model_