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 SwiftAgentimport asyncioagent =SwiftAgent(name='SampleAgent')asyncdefmain():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 SwiftClientimport asyncioclient =SwiftClient()client.connect(type_='agent', host='0.0.0.0', port=8000)asyncdefmain():await client.send('What is the color of an apple?')asyncio.run(main())