CodeAgent Parameters
Core Settings
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 terminationmax_failures(default:8): Maximum consecutive errors before terminationmax_validations(default:0): Maximum number of times to run the validator agent
Vision & Processing
use_vision(default:True): Whether to include screenshots in LLM messages.Truealways includes screenshots,Falsenever includes screenshotspage_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 asllm)
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 accesssensitive_data: Dictionary of sensitive data to handle carefully
Advanced Options
calculate_cost(default:False): Calculate and track API costs
Backwards Compatibility
controller: Alias fortoolsfor backwards compatibilitybrowser_session: Alias forbrowserfor backwards compatibility (deprecated, usebrowser)
Return Value
Therun() method returns a NotebookSession object that contains:
cells: List ofCodeCellobjects representing each executed code cellid: Unique session identifiercurrent_execution_count: Current execution count numbernamespace: Dictionary containing the current namespace state with all variables
CodeCell Properties
Each cell insession.cells has:
id: Unique cell identifiercell_type: Type of cell (‘code’ or ‘markdown’)source: The code that was executedoutput: The output from code execution (if any)execution_count: Execution order numberstatus: Execution status (‘pending’, ‘running’, ‘success’, or ‘error’)error: Error message if execution failedbrowser_state: Browser state after execution