AgentFS Python SDK
A filesystem and key-value store for AI agents, powered by SQLite and pyturso.
Installation
pip install agentfs-sdk
Quick Start
import asyncio
from agentfs_sdk import AgentFS, AgentFSOptions
async def main():
# Open an agent filesystem
agent = await AgentFS.open(AgentFSOptions(id='my-agent'))
# Use key-value store
await agent.kv.set('config', {'debug': True, 'version': '1.0'})
config = await agent.kv.get('config')
print(f"Config: {config}")
# Use filesystem
await agent.fs.write_file('/data/notes.txt', 'Hello, AgentFS!')
content = await agent.fs.read_file('/data/notes.txt')
print(f"Content: {content}")
# Track tool calls
call_id = await agent.tools.start('search', {'query': 'Python'})
await agent.tools.success(call_id, {'results': ['result1', 'result2']})
# Get statistics
stats = await agent.tools.get_stats()
for stat in stats:
print(f"{stat.name}: {stat.total_calls} calls, {stat.avg_duration_ms:.2f}ms avg")
# Close the database
await agent.close()
if __name__ == '__main__':
asyncio.run(main())
Features
Key-Value Store
Simple key-value storage with JSON serialization:
# Set a value
await agent.kv.set('user:123', {'name': 'Alice', 'age': 30})
# Get a value
user = await agent.kv.get('user:123')
# List by prefix
users = await agent.kv.list('user:')
# Delete a value
await agent.kv.delete('user:123')
Filesystem
POSIX-like filesystem operations:
# Write a file (creates parent directories automatically)
await agent.fs.write_file('/data/config.json', '{"key": "value"}')
# Read a file
content = await agent.fs.read_file('/data/config.json')
# Read as bytes
data = await agent.fs.read_file('/data/image.png', encoding=None)
# List directory
entries = await agent.fs.readdir('/data')
# Get file stats
stats = await agent.fs.stat('/data/config.json')
print(f"Size: {stats.size} bytes")
print(f"Modified: {stats.mtime}")
print(f"Is file: {stats.is_file()}")
# Delete a file
await agent.fs.delete_file('/data/config.json')
Tool Calls Tracking
Track and analyze tool/function calls:
# Start a tool call
call_id = await agent.tools.start('search', {'query': 'Python'})
# Mark as successful
await agent.tools.success(call_id, {'results': [...]})
# Or mark as failed
await agent.tools.error(call_id, 'Connection timeout')
# Record a completed call
await agent.tools.record(
'search',
started_at=1234567890,
completed_at=1234567892,
parameters={'query': 'Python'},
result={'results': [...]}
)
# Query tool calls
calls = await agent.tools.get_by_name('search', limit=10)
recent = await agent.tools.get_recent(since=1234567890)
# Get statistics
stats = await agent.tools.get_stats()
for stat in stats:
print(f"{stat.name}: {stat.successful}/{stat.total_calls} successful")
Configuration
Using Agent ID
Creates a database at .agentfs/{id}.db:
agent = await AgentFS.open(AgentFSOptions(id='my-agent'))
Using Custom Path
Specify a custom database path:
agent = await AgentFS.open(AgentFSOptions(path='./data/mydb.db'))
Using Both
You can specify both for clarity:
agent = await AgentFS.open(AgentFSOptions(id='my-agent', path='./data/mydb.db'))
Context Manager Support
Use AgentFS with async context managers:
async with await AgentFS.open(AgentFSOptions(id='my-agent')) as agent:
await agent.kv.set('key', 'value')
# Database is automatically closed when exiting the context
Development
Setup
# Install dependencies
uv sync --group dev
# Run tests
uv run pytest
# Format code
uv run ruff format agentfs_sdk tests
# Check code
uv run ruff check agentfs_sdk tests
License
MIT License - see LICENSE file for details.
Links
Metadata
Release files for agentfs-sdk 0.6.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentfs_sdk-0.6.4.tar.gz | 27.7 kB | Without provenance | Details for agentfs_sdk-0.6.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentfs_sdk-0.6.4-py3-none-any.whl | Python 3 | none | any | Details for agentfs_sdk-0.6.4-py3-none-any.whl |
Total release size: 46.8 kB
Release files / agentfs_sdk-0.6.4.tar.gz
| Download URL | agentfs_sdk-0.6.4.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa70b15a8a3576783e2657a8ff56986e8baa3bb5cd1280ca4a3d652324df207d
|
|
BLAKE2b-256 checksum How to use checksums |
50b437255e6e1b77d69b855d0a8874848a1c9cd33b26ef778e541628fc62b233
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / agentfs_sdk-0.6.4-py3-none-any.whl
| Download URL | agentfs_sdk-0.6.4-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7db2ee9dbb68b027ca5a1d9ed8ddea55811036cc3520b13d64bb9dc10e366f67
|
|
BLAKE2b-256 checksum How to use checksums |
26bffcd634e2fc3910fc428f00277b5215e6f558554d800fa5456c92b1df9d03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for agentfs-sdk 0.6.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.