AgentFile (.af)
Define agent configurations as code using AgentFile
AgentFile (.af) is a legacy format for serializing stateful agents. The documentation below describes the retired V1 API server, whose source is preserved on the archive branch. The current self-hosted source no longer includes the V1 AgentFile import/export routes.
What is AgentFile?
Section titled “What is AgentFile?”AgentFiles package all components of a stateful agent:
- System prompts
- Editable memory (personality and user information)
- Tool configurations (code and schemas)
- LLM settings
By standardizing these elements in a single format, AgentFile enables seamless transfer between compatible frameworks, while allowing for easy checkpointing and version control of agent state.
Why Use AgentFile?
Section titled “Why Use AgentFile?”The AI ecosystem is experiencing rapid growth in agent development, with each framework implementing its own storage mechanisms. AgentFile addresses the need for a standard that enables:
- Portability: Move agents between systems or deploy them to new environments
- Collaboration: Share your agents with other developers and the community
- Preservation: Archive agent configurations to preserve your work
- Versioning: Track changes to agents over time through a standardized format
- Testing: Run reproducible evaluations by using agent files as eval targets
What State Does .af Include?
Section titled “What State Does .af Include?”A .af file contains all the state required to re-create the exact same agent:
| Component | Description |
|---|---|
| Model configuration | Context window limit, model name, embedding model name |
| Message history | Complete chat history with in_context field indicating if a message is in the current context window |
| System prompt | Initial instructions that define the agent’s behavior |
| Memory blocks | In-context memory segments for personality, user info, etc. |
| Tool rules | Definitions of how tools should be sequenced or constrained |
| Environment variables | Configuration values for tool execution |
| Tools | Complete tool definitions including source code and JSON schema |
You can view the complete .af schema in the Letta repository.
For Cloud evaluations, use an existing agent ID.
Does .af work with frameworks other than Letta?
Section titled “Does .af work with frameworks other than Letta?”Theoretically, other frameworks could also load in .af files if they convert the state into their own representations. Some concepts, such as context window “blocks” which can be edited or shared between agents, are not implemented in other frameworks, so may need to be adapted per-framework.
How does .af handle secrets?
Section titled “How does .af handle secrets?”Agents have associated secrets for tool execution in Letta. When you export agents with secrets, the secrets are set to null for security reasons.
Contributing to AgentFile
Section titled “Contributing to AgentFile”The AgentFile format is a community-driven standard that welcomes contributions:
- Share Example Agents: Contribute your own
.affiles to the community - Join the Discussion: Connect with other agent developers in our Discord server
- Provide Feedback: Offer suggestions and feature requests to help refine the format
For more information on AgentFile, including example agents and the complete schema specification, visit the AgentFile repository.