Execute an agent
import swarmnode
swarmnode.api_key = "YOUR_API_KEY"
agent = swarmnode.Agent.retrieve(id="15d19ca3-26f1-4adb-9cea-3955b73d9b4e")
agent.execute(wait=True, payload={"foo": "bar"})
If wait
is set to True
, the method will wait for the agent to finish executing and return a Execution
object. If wait
is set to False
, the method will return a AgentExecutorJob
object immediately.
payload
is an optional parameter that can be used to pass data to the agent. The agent can access the payload via the request
parameter:
def main(request):
print(request.payload["foo"]) # prints "bar"