Skip to content

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

Enhance CodeAgent parameters documentation

kalil03211dc2ac6039fe
diff --git a/docs/customize/code-agent/all-parameters.mdx b/docs/customize/code-agent/all-parameters.mdx
index 4b2f2ce8f..242a6ae90 100644
--- a/docs/customize/code-agent/all-parameters.mdx
+++ b/docs/customize/code-agent/all-parameters.mdx
@@ -8,24 +8,66 @@ mode: "wide"
## CodeAgent Parameters
### Core Settings
-- `task`: Task description string that defines what the agent should accomplish
-- `llm`: LLM instance for code generation (required: ChatBrowserUse)
-- `browser`: Browser session object for automation
-- `tools`: Registry of tools the agent can call
-- `max_steps` (default: `20`): Maximum number of execution steps before termination
+- `task`: Task description string that defines what the agent should accomplish (required)
+- `llm`: LLM instance for code generation (required: ChatBrowserUse). If not provided, defaults to ChatBrowserUse()
+- `browser`: Browser session object for automation (optional, will be created if not provided)
+- `tools`: Registry of tools the agent can call (optional, creates default if not provided)
+- `max_steps` (default: `100`): Maximum number of execution steps before termination
- `max_failures` (default: `8`): Maximum consecutive errors before termination
-- `max_validations` (default: `0`): Maximum number of times to run the validator agent (default: 0)
+- `max_validations` (default: `0`): Maximum number of times to run the validator agent
### Vision & Processing
-- `use_vision` (default: `"auto"`): Vision mode - `"auto"` includes screenshot tool but only uses vision when requested, `True` always includes screenshots, `False` never includes screenshots and excludes screenshot tool
+- `use_vision` (default: `True`): Whether to include screenshots in LLM messages. `True` always includes screenshots, `False` never includes screenshots
- `page_extraction_llm`: Separate LLM model for page content extraction. You can choose a small & fast model because it only needs to extract text from the page (default: same as `llm`)
-### Actions & Behavior
-- `use_thinking` (default: `True`): Controls whether the agent uses its internal "thinking" field for explicit reasoning steps
-
### File & Data Management
+- `file_system`: File system instance for file operations (optional, creates default if not provided)
- `available_file_paths`: List of file paths the agent can access
- `sensitive_data`: Dictionary of sensitive data to handle carefully
### Advanced Options
-- `calculate_cost` (default: `False`): Calculate and track API costs (see ... to track costs)
+- `calculate_cost` (default: `False`): Calculate and track API costs
+
+### Backwards Compatibility
+- `controller`: Alias for `tools` for backwards compatibility
+- `browser_session`: Alias for `browser` for backwards compatibility (deprecated, use `browser`)
+
+## Return Value
+
+The `run()` method returns a `NotebookSession` object that contains:
+
+- `cells`: List of `CodeCell` objects representing each executed code cell
+- `id`: Unique session identifier
+- `current_execution_count`: Current execution count number
+- `namespace`: Dictionary containing the current namespace state with all variables
+
+### CodeCell Properties
+
+Each cell in `session.cells` has:
+
+- `id`: Unique cell identifier
+- `cell_type`: Type of cell ('code' or 'markdown')
+- `source`: The code that was executed
+- `output`: The output from code execution (if any)
+- `execution_count`: Execution order number
+- `status`: Execution status ('pending', 'running', 'success', or 'error')
+- `error`: Error message if execution failed
+- `browser_state`: Browser state after execution
+
+### Example
+
+```python
+session = await agent.run()
+
+# Access executed cells
+for cell in session.cells:
+ print(f"Cell {cell.execution_count}: {cell.source}")
+ if cell.error:
+ print(f"Error: {cell.error}")
+ elif cell.output:
+ print(f"Output: {cell.output}")
+
+# Access variables from the namespace
+variables = session.namespace
+print(f"Variables: {list(variables.keys())}")
+```