Installation
Create your Python file (run_agent.py)
Run the agent
Method Reference
Method | Purpose | Returns |
---|---|---|
execute_agent() | Start agent execution | execution_id |
wait_for_execution_result() | Wait for completion | result |
get_execution_status() | Check current status | status_info |
get_execution_result() | Get final result | result |
upload_execution_files() | Upload files | upload_response |
get_browser_session_recording() | Get recording URL | url |
get_last_n_execution_activities() | Get last N activities | list |
add_message_to_execution() | Add message to execution | None |
wait_for_agent_interaction() | Wait for interaction or completion | AgentInteractionResult |
get_agents() | Get a paginated list of agents | list |
get_agent_profiles() | Get list of agent profiles | list |
get_agent_profile() | Get agent profile by ID | profile |
create_agent_profile() | Create new agent profile | profile |
update_agent_profile() | Update existing agent profile | profile |
delete_agent_profile() | Delete agent profile | string |
Python Examples
API Reference
Core Methods
execute_agent() - Execute an agent with the provided parameters
execute_agent() - Execute an agent with the provided parameters
agent_id
: The ID of the agent to executeexecution_data
: The execution parametersagent_profile_id
: Optional ID of the agent profile
- Exception: If the execution request fails
get_execution_status() - Get the current status for an execution
get_execution_status() - Get the current status for an execution
execution_id
: The execution identifier
- Exception: If the status request fails
get_execution_result() - Get the final result of an execution
get_execution_result() - Get the final result of an execution
execution_id
: The execution identifier
- Exception: If the result request fails or execution failed
wait_for_execution_result() - Wait for an execution to reach a terminal state and return the result
wait_for_execution_result() - Wait for an execution to reach a terminal state and return the result
execution_id
: The execution identifierinterval
: Polling interval in seconds (default is 1.0)timeout
: Maximum wait time in seconds (default is 3600 - 1 hour)
- Exception: If the execution ends as “cancelled” or “failed”, or times out
upload_execution_files() - Upload files to an execution
upload_execution_files() - Upload files to an execution
execution_id
: The execution identifierfiles
: List of files to upload. Each file can be:default_filename
: Default filename to use when file is provided as bytes
- Exception: If the upload request fails
get_browser_session_recording() - Get the browser session recording URL for a completed execution
get_browser_session_recording() - Get the browser session recording URL for a completed execution
execution_id
: The execution identifier
- Exception: If the recording request fails
get_last_n_execution_activities() - Get the last N execution activities for a given execution ID, sorted by their timestamp in descending order
get_last_n_execution_activities() - Get the last N execution activities for a given execution ID, sorted by their timestamp in descending order
execution_id
: The execution identifiern
: The number of activities to return
- Exception: If the execution activities request fails
add_message_to_execution() - Add a message to an execution
add_message_to_execution() - Add a message to an execution
execution_id
: The execution identifiermessage
: The message to add
- Exception: If the message addition fails
wait_for_agent_interaction() - Wait for an agent interaction request or terminal state
wait_for_agent_interaction() - Wait for an agent interaction request or terminal state
- Requests human input (paused_by_agent state)
- Reaches a terminal state (completed, failed, cancelled)
- Times out
execution_id
: The execution identifier for an already started executionpoll_interval
: How often to check for updates in seconds (default: 2.0)timeout
: Maximum wait time in seconds (default: 3600 - 1 hour)
is_terminal
: True if execution finished (completed/failed/cancelled)status
: Current execution status stringagent_message
: Agent’s message if requesting interaction (None if terminal)execution_result
: Final result if terminal state (None if requesting interaction)
- ValueError: If interval or timeout parameters are invalid
- TimeoutError: If the execution times out
- AsteroidAPIError: If API calls fail
Agent Profiles
get_agent_profiles() - Get a list of agent profiles for a specific organization
get_agent_profiles() - Get a list of agent profiles for a specific organization
organization_id
: The organization identifier (required)
- Exception: If the agent profiles request fails
get_agent_profile() - Get an agent profile by ID
get_agent_profile() - Get an agent profile by ID
profile_id
: The ID of the agent profile
- Exception: If the agent profile request fails
create_agent_profile() - Create an agent profile with automatic credential encryption
create_agent_profile() - Create an agent profile with automatic credential encryption
request
: The request object
- Exception: If the agent profile creation fails
update_agent_profile() - Update an agent profile with automatic credential encryption
update_agent_profile() - Update an agent profile with automatic credential encryption
profile_id
: The ID of the agent profilerequest
: The request object
- Exception: If the agent profile update fails
delete_agent_profile() - Delete an agent profile
delete_agent_profile() - Delete an agent profile
profile_id
: The ID of the agent profile
- Exception: If the agent profile deletion fails
get_credentials_public_key() - Get the public key for encrypting credentials
get_credentials_public_key() - Get the public key for encrypting credentials
- Exception: If the public key request fails
format_agent_profile() - Format an agent profile for nice display
format_agent_profile() - Format an agent profile for nice display
profile
: No description available
format_agent_profiles_list() - Format a list of agent profiles for nice display
format_agent_profiles_list() - Format a list of agent profiles for nice display
profiles
: No description available