Persistent

Introduction

Deploying and using agents on a production level requires persistent infrastructure to ensure scalability and reliability. This typically involves integrating agents with API frameworks like FastAPI, Flask, or Node.js, which not only increases complexity and development time but can also lead to fragmented agentic applications over multiple systems.

Swiftagent simplifies this process with built-in persistence, eliminating the need for multiple tools or custom setups. This allows for a focus on scaling agents without the overhead of managing fragmented infrastructure.

Using Persistent Mode

1

Run an Agent in Persistent Mode

agent.py
from swiftagent import SwiftAgent
import asyncio

agent = SwiftAgent(name='SampleAgent')

async def main():
  await agent.run(type_='persistent')

asyncio.run(main())
2

Interact with the Agent

In another file, you can now interact with the agent using either the SwiftClient or any other HTTP based method.

client.py
from swiftagent import SwiftClient
import asyncio

client = SwiftClient()

client.connect(type_='agent', host='0.0.0.0', port=8000)

async def main():
    await client.send('What is the color of an apple?')

asyncio.run(main())

Last updated