Execute an Agent

import agent_orbit as orbit

orbit.api_key = "YOUR_API_KEY"

agent = orbit.Agent.retrieve(id="15d19ca3-26f1-4adb-9cea-3955b73d9b4e")

execution_result = agent.execute(
    wait=True, 
    payload={"foo": "bar"}
)

Parameters:

  • wait:

    • If True, the method waits for the agent to finish executing and returns an Execution object.

    • If False, the method returns an AgentExecutorJob object immediately.

  • payload: (Optional) A dictionary used to pass data to the agent. The agent can access this via the request.payload attribute.

Example: Accessing the Payload in the Agent Script

def main(request, store):
    print(request.payload["foo"])  # prints "bar"

Returns:

  • If wait=True: An Execution object containing the result of the agent's execution.

  • If wait=False: An AgentExecutorJob object representing the execution job.

Last updated