Skip to main content
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 constructing Agent.
kind
AgentKind | str
default:"AgentKind.OPERATOR"
The agent to use for task execution.
Best for browser automation tasks like clicking, navigating, filling forms, and extracting data from pages.

Parameters

prompt
str
required
The natural-language instruction for the task. When using AgentKind.OPERATOR, Narada applies the correct Operator prefix automatically.
reasoning
ReasoningEffort | None
default:"None"
Controls how much reasoning the Core Agent uses before responding. This option is only valid with AgentKind.CORE_AGENT.
clear_chat
bool | None
default:"None"
Whether to clear chat context before executing the command.
generate_gif
bool | None
default:"None"
Whether to capture an animated GIF of the automation trajectory.
output_schema
type[BaseModel] | None
default:"None"
A Pydantic model class defining the expected structured response.
previous_request_id
str | None
default:"None"
The prior request ID to continue a conversation.
attachment
File | IO[Any] | None
default:"None"
A file-like object to attach to the request. The SDK uploads the file automatically before dispatching the task.
time_zone
str
default:"America/Los_Angeles"
The time zone for time-related operations.
mcp_servers
list[McpServer] | None
default:"None"
MCP servers to connect during task execution.
secret_variables
dict[str, str] | None
default:"None"
Sensitive values substituted at action time. The LLM sees placeholders such as ${password}, not the actual values.
input_variables
Mapping[str, Any] | None
default:"None"
Values passed into prompts using {{$variable_name}} syntax. File-like values are uploaded automatically.
callback_url
str | None
default:"None"
URL to call when the task status changes or completes. Use this with callback_secret or callback_headers to authenticate callbacks.
on_input_required
InputRequiredCallback | None
default:"None"
Callback invoked when a task enters an input-required state.
critic
CriticConfig | None
default:"None"
Optional critic configuration that validates the run after the main agent finishes.
timeout
int
default:"1000"
Maximum time in seconds to wait for task completion.

Response

Agent.run() returns an AgentResponse object:
request_id
str
Unique identifier for this request. Use it for debugging, callbacks, or conversation continuation.
status
str
Execution status: "success", "error", or "input-required".
text
str
The text response from the agent.
structured_output
BaseModel | None
Parsed structured data when output_schema is provided. Otherwise None.
output
TextOutput | StructuredOutput
Discriminated union containing either text or structured data:
usage
AgentUsage
Usage metrics:
  • actions: Number of actions performed
  • credits: Credits consumed for the task
action_trace
ActionTrace | None
Detailed log of agent actions. See Action Trace for the trace format.
workflow_trace
dict | None
Workflow-level trace data when available.
critic_result
CriticResult | None
Result from the optional critic step.

Examples

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 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:
Use an environment and agent instead:
For browser actions, call methods on agent:
For lifecycle and IDs, use the environment: