Commit Graph

67 Commits

Author SHA1 Message Date
Kian Jones
0d42afa151 fix(core): catch LockNotAvailableError and return 409 instead of 500 (#9359)
Re-apply changes on top of latest main to resolve merge conflicts.

- Add DatabaseLockNotAvailableError custom exception in orm/errors.py
- Catch asyncpg LockNotAvailableError and pgcode 55P03 in _handle_dbapi_error
- Register FastAPI exception handler returning 409 with Retry-After header



🐾 Generated with [Letta Code](https://letta.com)

Co-authored-by: letta-code <248085862+letta-code@users.noreply.github.com>
Co-authored-by: Letta <noreply@letta.com>
2026-02-24 10:52:07 -08:00
Kian Jones
71e0a8aab9 fix(core): use INSERT ON CONFLICT DO NOTHING for provider model sync (#9342)
* fix(core): use INSERT ON CONFLICT DO NOTHING for provider model sync

Replaces try/except around model.create_async() with pg_insert()
.on_conflict_do_nothing() to prevent UniqueViolationError from being
raised at the asyncpg driver level during concurrent model syncs.
The previous approach caught the exception in Python but ddtrace still
captured it at the driver level, causing Datadog error tracking noise.

Fixes Datadog issue d8dec148-d535-11f0-95eb-da7ad0900000

🐾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta <noreply@letta.com>

* cleaner impl

* fix

---------

Co-authored-by: Letta <noreply@letta.com>
Co-authored-by: Ari Webb <ari@letta.com>
2026-02-24 10:52:07 -08:00
Kian Jones
4eb27e23b3 fix(core): add deadlock retry logic to ORM write operations (#9352)
Adds automatic retry with exponential backoff for PostgreSQL deadlock
errors (40P01) in all ORM write methods: create_async, update_async,
batch_create_async, hard_delete_async, and bulk_hard_delete_async.

For update_async, column values are snapshotted before the commit
attempt so they can be restored after rollback clears them.

Also adds DatabaseDeadlockError to _handle_dbapi_error as a fallback
when retries are exhausted.

Datadog: https://us5.datadoghq.com/error-tracking/issue/53ccdd7a-f0cc-11f0-8969-da7ad0900000

🤖 Generated with [Letta Code](https://letta.com)

Co-authored-by: Letta <noreply@letta.com>
Co-authored-by: letta-code <248085862+letta-code@users.noreply.github.com>
2026-02-24 10:52:07 -08:00
Kian Jones
d592ec3135 fix: handle DBAPIError wrapping asyncpg DeadlockDetectedError (#9355)
SQLAlchemy wraps asyncpg's DeadlockDetectedError in a DBAPIError,
which was falling through to the generic 500 handler. Now detected
at both the ORM level (_handle_dbapi_error) and FastAPI handler level,
returning 409 with Retry-After header.

Datadog: https://us5.datadoghq.com/error-tracking/issue/2f1dc54c-dab6-11f0-a828-da7ad0900000

🐾 Generated with [Letta Code](https://letta.com)

Co-authored-by: Letta <noreply@letta.com>
2026-02-24 10:52:07 -08:00
Kian Jones
0099a95a43 fix(sec): first pass of ensuring actor id is required everywhere (#9126)
first pass of ensuring actor id is required
2026-01-29 12:44:04 -08:00
github-actions[bot]
2460b36f97 fix: handle asyncpg QueryCanceledError for statement timeouts (#8241)
The handle_db_timeout decorator only caught SQLAlchemy's TimeoutError
(for pool/connection timeouts) but not asyncpg's QueryCanceledError
which is thrown when PostgreSQL's statement_timeout kills a long-running
query.

This fix:
- Import asyncpg.exceptions.QueryCanceledError
- Update handle_db_timeout decorator to catch QueryCanceledError and wrap
  it in DatabaseTimeoutError
- Update _handle_dbapi_error method to also handle wrapped QueryCanceledError

Fixes #8108

🤖 Generated with [Letta Code](https://letta.com)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Letta <noreply@letta.com>
Co-authored-by: datadog-official[bot] <datadog-official[bot]@users.noreply.github.com>
Co-authored-by: Kian Jones <11655409+kianjones9@users.noreply.github.com>
2026-01-19 15:54:38 -08:00
cthomas
9be2ab2c3d fix: skip additional query in stale data error handling (#8171) 2026-01-12 10:57:48 -08:00
cthomas
d489d8837f fix: broken pagination for objects with missing created_at [LET-6699] (#8139)
fix: broken pagination for objects with missing created_at
2026-01-12 10:57:47 -08:00
cthomas
0dd1df306a fix: concurrent block update rollback [LET-6695] (#8133)
fix: concurrent block update rollback
2026-01-12 10:57:47 -08:00
cthomas
369274a219 fix: greenlet spawn errors in deletion path (#6267) 2025-11-24 19:10:11 -08:00
Sarah Wooders
6654473514 fix: handle block race conditions (#5819) 2025-11-13 15:36:14 -08:00
jnjpng
d09f321af7 fix: before and after pagination comparison based off order [LET-5833] (#5712)
base

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-24 15:14:21 -07:00
Sarah Wooders
4df0a27eb0 chore: remove sync db (#4873) 2025-10-07 17:50:45 -07:00
Kian Jones
b8e9a80d93 merge this (#4759)
* wait I forgot to comit locally

* cp the entire core directory and then rm the .git subdir
2025-09-17 15:47:40 -07:00
Kian Jones
22f70ca07c chore: officially migrate to submodule (#4502)
* remove apps/core and apps/fern

* fix precommit

* add submodule updates in workflows

* submodule

* remove core tests

* update core revision

* Add submodules: true to all GitHub workflows

- Ensure all workflows can access git submodules
- Add submodules support to deployment, test, and CI workflows
- Fix YAML syntax issues in workflow files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* remove core-lint

* upgrade core with latest main of oss

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-09 12:45:53 -07:00
cthomas
57ed8e40d2 feat: temp remove disabling enable_seqscan setting (#3443) 2025-07-20 23:02:23 -07:00
Andy Li
1ccaae8960 chore: cleanup database detection 2025-07-18 17:12:56 -07:00
Kian Jones
0cd8c830c9 feat(sqlite): CI Tests for Alembic and SQLite (#3358)
Co-authored-by: Matt Zhou <mattzh1314@gmail.com>
2025-07-17 18:04:13 -07:00
cthomas
f670bd7619 feat: add no_refresh flag to sqlalchemy helpers (#3377) 2025-07-17 14:20:50 -07:00
Sarah Wooders
d1a0dae9fb fix: fixes to step feedback listing (#3080) 2025-06-27 16:31:23 -07:00
Sarah Wooders
d4b510e358 feat: allow filtering steps by feedback (#3061) 2025-06-27 14:35:29 -07:00
Sarah Wooders
a7092c9794 fix: patches sqlite support (#2876)
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
Co-authored-by: jnjpng <jin@letta.com>
2025-06-21 21:06:37 -07:00
cthomas
0141b1f30b fix: not enough values to unpack error (#2753) 2025-06-11 11:05:46 -07:00
Andy Li
eaf5682422 feat: plugin system and backend runtime flags (#2543) 2025-06-05 18:12:44 -07:00
Matthew Zhou
3d8704395b feat: Store entire parsed file content in separate table (#2618) 2025-06-03 18:51:45 -07:00
cthomas
75d1b50f5d feat: add size async caching (#2532) 2025-05-29 16:45:29 -07:00
cthomas
74f4207886 feat: default skip is deleted check in queries (#2531) 2025-05-29 16:10:41 -07:00
cthomas
c376baac10 feat: force read_async to use indices (#2530) 2025-05-29 15:44:06 -07:00
cthomas
183a5565b2 feat: optimize read single id (#2517) 2025-05-29 01:27:41 -07:00
cthomas
d7e0dc43a3 feat: optimize read query (#2516) 2025-05-28 23:53:43 -07:00
cthomas
ab2c8f7e2d feat: optimize size async queries (#2512) 2025-05-28 23:30:18 -07:00
cthomas
e0020d088a feat: reuse asyncpg db sessions (#2510) 2025-05-28 23:16:06 -07:00
cthomas
71f42473a9 feat: add bulk deletion for passages (#2489) 2025-05-28 13:11:33 -07:00
Andy Li
83b897e91d feat: job listing takes source id (#2473) 2025-05-27 15:34:27 -07:00
Andy Li
a5af6fec7f perf: agent tags optimization (#2454) 2025-05-27 15:14:07 -07:00
cthomas
ffafc8f3b4 chore: cleanup tracing (#2365) 2025-05-23 00:48:40 -07:00
cthomas
8d00e7fd14 feat: add low level db traces (#2343) 2025-05-22 23:35:10 -07:00
cthomas
b3f33472c0 fix: size_async bug (#2217) 2025-05-16 07:25:53 -07:00
cthomas
91a5516090 feat(asyncify): add size_async db function (#2207) 2025-05-16 01:22:48 -07:00
cthomas
00914e5308 feat(asyncify): migrate actors(users) endpoints (#2211) 2025-05-16 00:37:08 -07:00
cthomas
7f90746152 feat: convert many methods to async (#2193) 2025-05-15 12:09:40 -07:00
Andy Li
955873ab4d feat: async list/prepare messages (#2181)
Co-authored-by: Caren Thomas <carenthomas@gmail.com>
2025-05-15 00:34:04 -07:00
Andy Li
600ccb35e7 feat: async db client (#2076) 2025-05-12 17:15:14 -07:00
Matthew Zhou
0780cec6b9 feat: Set SqlAlchemy to fetch sequence_id from DB, not generate it itself (#1726) 2025-04-15 19:25:46 -07:00
Matthew Zhou
983f750990 feat: Implement resume step after request in new batch agent loop (#1676) 2025-04-15 13:56:22 -07:00
cthomas
15c7ad0f87 fix: memory block refresh bug (#1668) 2025-04-10 15:59:41 -07:00
Matthew Zhou
557359a4c6 feat: Add ability to redo to more recent checkpoint (#1496) 2025-03-31 17:35:51 -07:00
Matthew Zhou
24fbdc6032 feat: Add block history tables (#1489) 2025-03-31 16:39:23 -07:00
Matthew Zhou
f0ba8bbb1f feat: Make multi agent broadcast directly invoke step (#1355) 2025-03-20 17:05:04 -07:00
Matthew Zhou
c343abb75e chore: Various bug fixes (#1350)
Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
Co-authored-by: cthomas <caren@letta.com>
Co-authored-by: tarunkumark <tkksctwo@gmail.com>
Co-authored-by: Kevin Lin <klin5061@gmail.com>
Co-authored-by: Charles Packer <packercharles@gmail.com>
Co-authored-by: Miao <one.lemorage@gmail.com>
Co-authored-by: Krishnakumar R (KK) <65895020+kk-src@users.noreply.github.com>
Co-authored-by: Shubham Naik <shub@memgpt.ai>
Co-authored-by: Shubham Naik <shub@letta.com>
Co-authored-by: Will Sargent <will.sargent@gmail.com>
Co-authored-by: Shubham Naik <shubham.naik10@gmail.com>
Co-authored-by: mlong93 <35275280+mlong93@users.noreply.github.com>
Co-authored-by: Mindy Long <mindy@letta.com>
Co-authored-by: Stephan Fitzpatrick <stephan@knowsuchagency.com>
Co-authored-by: dboyliao <qmalliao@gmail.com>
Co-authored-by: Jyotirmaya Mahanta <jyotirmaya.mahanta@gmail.com>
Co-authored-by: Nicholas <102550462+ndisalvio3@users.noreply.github.com>
Co-authored-by: Tristan Morris <tristanbmorris@gmail.com>
Co-authored-by: Daniel Shin <88547237+kyuds@users.noreply.github.com>
Co-authored-by: Jindřich Šíma <67415662+JindrichSima@users.noreply.github.com>
Co-authored-by: Azin Asgarian <31479845+azinasg@users.noreply.github.com>
Co-authored-by: Connor Shorten <connorshorten300@gmail.com>
Co-authored-by: Lucas Mohallem Ferraz <ferraz.m.lucas@gmail.com>
Co-authored-by: kyuds <kyuds@everspin.co.kr>
2025-03-20 11:06:45 -07:00