Agent.run() executes a natural-language task in a Narada environment and returns an AgentResponse.
Create an environment first, then bind an agent to it:
Agent.run() is the current SDK interface. The older Narada().open_and_initialize_browser_window() and window.agent(...) pattern is no longer the recommended API.Constructor
Run Signature
Agent Kinds
Choose the agent kind when constructingAgent.
The agent to use for task execution.
- OPERATOR
- CORE_AGENT
- PRODUCTIVITY
- Custom Agent
Best for browser automation tasks like clicking, navigating, filling forms, and extracting data from pages.
Parameters
The natural-language instruction for the task. When using
AgentKind.OPERATOR, Narada applies the correct Operator prefix automatically.Controls how much reasoning the Core Agent uses before responding. This option is only valid with
AgentKind.CORE_AGENT.A Pydantic model class defining the expected structured response.
A file-like object to attach to the request. The SDK uploads the file automatically before dispatching the task.
Sensitive values substituted at action time. The LLM sees placeholders such as
${password}, not the actual values. See Secrets and Secret Variables.Values passed into prompts using
{{$variable_name}} syntax. File-like values are uploaded automatically.URL to call when the task status changes or completes. Use this with
callback_secret or callback_headers to authenticate callbacks.Callback invoked when a task enters an input-required state.
Optional critic configuration that validates the run after the main agent finishes.
Response
Agent.run() returns an AgentResponse object:
Unique identifier for this request. Use it for debugging, callbacks, or conversation continuation.
Usage metrics:
actions: Number of actions performedcredits: Credits consumed for the task
Detailed log of agent actions. Top-level action trace entries include
start_ts, end_ts, and duration_ms fields. See Action Trace
for the trace format and timing semantics.Examples
- Basic Web Automation
- Structured Data Extraction
- Conversation
- Error Handling
- File Attachments
- Custom Agent
Best Practices
Reuse Environments
Create one environment and reuse it across multiple
Agent instances when tasks should share a browser session.Choose the Agent Kind
Use
AgentKind.OPERATOR for browser automation and AgentKind.CORE_AGENT for read-only reasoning or conversation.Use Structured Output
Define Pydantic schemas for consistent, typed responses from data extraction tasks.
Protect Sensitive Data
Use
secret_variables or Agent Studio Secrets and Secret Variables for passwords, API keys, or personal information that should not be exposed to the LLM.Pass Files Directly
Pass file-like objects with
attachment= instead of calling a separate upload method.Handle Timeouts
Set appropriate timeouts and call
agent.reset_agent_state() before retrying after a timeout.Migration from Older SDKs
Older SDK examples used a Narada client and window object:agent: