2ddddfb527 [fix] Preserve saved JsonDb tables when writes fail (#10794)
## Summary

Fixes #10793.

JsonDb overwrites a live table before JSON serialization and the
filesystem write finish. A failed save can therefore destroy previously
persisted sessions rather than leaving the last successful table
readable.

I reproduced this through public `JsonDb.upsert_session` with valid
session data on macOS/Python 3.12 using an isolated subprocess and
`RLIMIT_FSIZE`. The second save raises native `EFBIG`: the previous
347-byte valid table becomes a 411-byte partial JSON file. With this
change the same error leaves all 347 prior bytes intact, and
`get_session` still returns the previously saved session.

Regular tables are serialized into a unique sibling file and published
with `os.replace` only after the file closes successfully. Failed
serialization/publication removes only the staging file this writer
created. Existing write permissions, mode bits, file/directory symlinks
and direct writes to nonregular paths are preserved.

## Type of change

- [x] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Improvement
- [ ] Model update
- [ ] Other:

---

## Checklist

- [x] Code complies with style guidelines
- [x] Ran format/validation scripts (`./scripts/format.sh` and
`./scripts/validate.sh`)
- [x] Self-review completed
- [x] Documentation updated (comments, docstrings)
- [ ] Examples and guides: Relevant cookbook examples have been included
or updated (if applicable)
- [x] Tested in clean environment
- [x] Tests added/updated (if applicable)

### Duplicate and AI-Generated PR Check

- [x] I have searched existing [open pull
requests](https://github.com/agno-agi/agno/pulls) and confirmed that no
other PR already addresses this issue
- [ ] If a similar PR exists, I have explained below why this PR is a
better approach
- [x] Check if this PR was entirely AI-generated (by Copilot, Claude
Code, Cursor, etc.)

---

## Additional Notes

This patch and its regression tests were prepared with AI assistance.
The actual filesystem failure was reproduced before the change, the
resulting patch was reviewed, and the verification results below come
from executed tests.

### Verification

- Before the fix, three focused failure-preservation tests fail; seven
success/compatibility controls pass.
- After the fix, 132 tests pass and 35 are skipped across the changed
writer tests and adjacent JSON session migration/run/eval tests. Tests
cover native file-size failure, partial serialization failure, rename
failure, private mode preservation, write denial, write-only files,
table/directory symlinks, an owned FIFO, UTF-8 and staging filename
collision ownership.
- Root `./scripts/format.sh` and `./scripts/validate.sh` pass using the
declared-compatible SQLAlchemy 2.0.48 development environment. The
format script also touches seven unrelated pre-existing style
discrepancies; those changes are excluded from this PR.
- Fresh hosted [unchanged
Validation](https://github.com/rudycelekli/agno/actions/runs/37157702686)
passes all ten jobs: all five full unit-test groups with the configured
PostgreSQL service, four style groups, and supported-runtime page
guards. The QA pull-request merge tree exactly equals reviewed head
`09a6851fa034c50ced55a3d1b796ed4be85cfd5e`. PR Lint also passes. No
workflow, test selection or dependency constraints were changed.
- After the capability-aware Windows symlink fixture helper, all 12
focused writer/UTF-8 tests pass and root format/validation pass again.
The symlink controls skip on Windows only if native creation actually
fails for missing privilege.
- This local development environment omits optional all-test SDKs. An
attempted adjacent Mongo-containing suite stops collection because
`pymongo` is absent; that local run is not described as passing. Full
test verification comes from the fresh hosted matrix above.

This change protects a single regular table's prior content when
publishing that table fails. It does not merge concurrent writers, make
multi-table operations transactional, or guarantee power-loss
durability. Atomic replacement requires the table directory to allow
creation/rename. Existing mode bits are preserved; no claim is made
about extended ACLs or arbitrary hard-link aliases. No LLM/API calls or
real database services were needed for the focused reproduction.

---------

Signed-off-by: Rudy Celekli <[email protected]>
Co-authored-by: Sannya Singal <[email protected]>
Co-authored-by: sannya-singal <[email protected]>
2026-10-06 15:35:19 +05:30
2026-08-24 18:19:42 +05:30
2024-02-12 21:05:49 +00:00
2026-08-24 18:19:42 +05:30
2025-09-09 15:39:09 +02:00
2025-01-30 20:50:59 +05:30
2026-07-14 22:55:34 +01:00

Build, run, and manage agent platforms.

Introduction

Agno is a framework and runtime for agent platforms. Build agents, run them as a service, manage your platform using a web UI.

  • Build your agent platform using the Agno SDK.
  • Run your agent platform using the AgentOS runtime.
  • Manage everything using the AgentOS UI.

Agno allows you to own your agent stack. Maintain control of your data, memory, and security posture (JWT-based RBAC), and turn your agent platform into a learning loop with simulations and usage data.

demo-os

Get started

Hand this prompt to your coding agent (Claude Code, Cursor, Codex):

Help me set up my agent platform.

Clone https://github.com/agno-agi/agentos-railway into a folder called
agent-platform, cd in, read the README, and follow the get started guide.

Your coding agent will set up your agent platform and run it locally using Docker, giving you a REST API for serving your agents, a Postgres database for storing your data and traces, an MCP server, and a control plane.

Deploying somewhere else? Use the same prompt but point it to a different repo. The starter templates are identical except for the deploy scripts: swap agentos-railway for agentos-docker, agentos-aws, agentos-gcp, agentos-azure, agentos-fly, agentos-render, agentos-modal, or agentos-helm.

Prefer to code by hand?

Features

  • Production API. 50+ endpoints with SSE and websockets to build a product on top.
  • Storage. Store sessions, memory, knowledge, and traces in your own database.
  • 100+ integrations. Connect to GitHub, Slack, Postgres, and more using pre-built toolkits.
  • Context Providers. Access live data from Slack, Drive, wikis, MCP, and custom sources.
  • Human approval. Pause runs for user confirmation. Block tools that require admin approval.
  • Observability. Monitor with OpenTelemetry tracing, run history, and audit logs.
  • Security. Get JWT-based RBAC and multi-user, multi-tenant isolation out of the box.
  • Interfaces. Expose your agents via Slack, Telegram, WhatsApp, Discord, AG-UI, A2A.
  • Scheduling. Cron-based scheduling and background jobs with no external infrastructure.
  • Deploy anywhere. Run on any cloud platform that runs containers. Docker, Railway, AWS, GCP.

Use Agno with your coding agent

Two options:

  1. Recommended: Add Agno docs as an MCP server. Add docs.agno.com/mcp to your favourite coding agent.
  2. Add Agno docs as an indexed source. In Cursor: Settings → Indexing & Docs → Add https://docs.agno.com/llms-full.txt. Also works in VSCode, Windsurf, and similar tools.

Read the full guide here.

Community

Contributing

See the contributing guide.

License

Agno is distributed under the Apache-2.0 license.

Telemetry

Agno sends a telemetry event per agent run so we know which model providers to prioritize. Prompts, messages, and outputs are never sent. Disable by setting AGNO_TELEMETRY=false.

↑ Back to top

S
Description
Build, run, and manage agent platforms.
Readme Apache-2.0
693 MiB
Languages
Python 99.7%
HTML 0.1%
Shell 0.1%