AgentsManager

Listing Agents

To list all agents available in your project, use the list_agents method:

agent_list = client.agents.list_agents()
agent_list

Example response:

[Agent(agent_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", name="Agent 1"), Agent(agent_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", name="Agent 2")]

Retrieving an Agent

To retrieve a specific agent by its ID, use the retrieve_agent method:

my_agent = client.agents.retrieve_agent(agent_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
my_agent

Example response:

Agent(agent_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", name="Agent Name")

Upserting an Agent

To create or update an agent, use the upsert_agent method:

new_agent = client.agents.upsert_agent(name="New Agent", system_prompt="You are a helpful assistant.", model="gpt-3.5", temperature=0.7)
new_agent

Example response:

Agent(agent_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", name="New Agent")

Deleting an Agent

To delete an agent, use the delete_agent method:

success = client.agents.delete_agent(agent_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
success

Example response:

True

Agent

Managing Tools

Listing Tools

To list all tools associated with an agent, use the list_tools method:

tools = my_agent.list_tools()
tools

Example response:

[Tool(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", title="Tool 1"), Tool(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", title="Tool 2")]

Adding a Tool

To add a tool to an agent, use the add_tool method:

my_agent.add_tool(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")

Removing a Tool

To remove a tool from an agent, use the remove_tool method:

my_agent.remove_tool(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")

Removing All Tools

To clear all tools associated with an agent, use the remove_all_tools method:

my_agent.remove_all_tools()

Managing Subagents

Listing Subagents

To list all subagents associated with an agent, use the list_subagents method:

subagents = my_agent.list_subagents()
subagents

Example response:

[Tool(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", title="Subagent 1"), Tool(tool_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", title="Subagent 2")]

Adding a Subagent

To add a subagent to an agent, use the add_subagent method:

my_agent.add_subagent(agent_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", action_behaviour="always-ask")

Removing a Subagent

To remove a subagent from an agent, use the remove_subagent method:

my_agent.remove_subagent(agent_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")

Task Management

Triggering a Task

To trigger a task with a message, use the trigger_task method:

triggered_task = my_agent.trigger_task(message="Hello, Agent!")
triggered_task

Example response:

TriggeredTask(task_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", status="triggered")

Viewing Task Steps

To view the steps of a task, use the view_task_steps method:

task_view = my_agent.view_task_steps(conversation_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
task_view

Approving a Task

To approve a task, use the approve_task method:

approved_task = my_agent.approve_task(conversation_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
approved_task

Rerunning a Task

To rerun a task, use the rerun_task method:

rerun_task = my_agent.rerun_task(conversation_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
rerun_task

Scheduling an Action in a Task

To schedule an action in a task, use the schedule_action_in_task method:

scheduled_action = my_agent.schedule_action_in_task(conversation_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", message="Schedule this action", minutes_until_schedule=10)
scheduled_action

Getting Task Output Preview

To get a preview of the task output, use the get_task_output_preview method:

output_preview = my_agent.get_task_output_preview(conversation_id="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
output_preview

Example response:

{"field1": "value1", "field2": "value2"}

Updating Agent Settings

Updating Core Instructions

To update the core instructions for an agent, use the update_core_instructions method:

my_agent.update_core_instructions(core_instructions="You are now a debugging assistant.")

Updating Template Settings

To update template settings for an agent, use the update_template_settings method:

template_params = {
    "param1": Param(value="value1", required=True),
    "param2": Param(value="value2", required=False)
}
my_agent.update_template_settings(params=template_params)

To get a link to an agent’s configuration page, use the get_link method:

link = my_agent.get_link()
link

Example response:

"https://app.relevanceai.com/agents/region/project/agent_id"