Commit Graph

43 Commits

Author SHA1 Message Date
cthomas
9a95a8f976 fix: duplicate session commit in step logging (#7512)
* fix: duplicate session commit in step logging

* update all callsites
2026-01-12 10:57:19 -08:00
jnjpng
25d75d6528 fix: update aysnc get plaintext callsites (#7069)
* base

* resolve

* fix

* fix
2025-12-17 17:31:02 -08:00
jnjpng
00ba2d09f3 refactor: migrate mcp_servers and mcp_oauth to encrypted-only columns (#6751)
* refactor: migrate mcp_servers and mcp_oauth to encrypted-only columns

Complete migration to encrypted-only storage for sensitive fields:

- Remove dual-write to plaintext columns (token, custom_headers,
  authorization_code, access_token, refresh_token, client_secret)
- Read only from _enc columns, not from plaintext fallback
- Remove helper methods (get_token_secret, set_token_secret, etc.)
- Remove Secret.from_db() and Secret.to_dict() methods
- Update tests to verify encrypted-only behavior

After this change, plaintext columns can be set to NULL manually
since they are no longer read from or written to.

* fix test

* rename

* update

* union

* fix test
2025-12-17 17:31:02 -08:00
Kian Jones
43aa97b7d2 fix: prevent db connection pool exhaustion in MCP tool creation (#6621)
Problem: When creating an MCP server with many tools, the code used
asyncio.gather to create all tools concurrently. Each tool creation involves
database operations (INSERT with upsert logic), leading to N concurrent
database connections.

Example: An MCP server with 50 tools creates 50 simultaneous database
connections during server creation, exhausting the connection pool.

Root cause: asyncio.gather(*[create_mcp_tool_async(...) for tool in tools])
processes all tool creations concurrently, each opening a DB session.

Solution: Create tools sequentially instead of concurrently. While this takes
longer for server creation, it prevents database connection pool exhaustion
and maintains error handling by catching exceptions per tool.

Changes:
- apps/core/letta/services/mcp_manager.py:
  - Replaced asyncio.gather with sequential for loop
  - Maintained return_exceptions=True behavior with try/except
  - Added explanatory comment about db pool exhaustion prevention

Impact: With 50 MCP tools:
- Before: 50 concurrent DB connections (pool exhaustion)
- After: 1 DB connection at a time (no pool exhaustion)

Note: This follows the same pattern as PR #6617, #6619, and #6620 which
fixed similar issues in file operations, multi-agent execution, and file
status checks.
2025-12-15 12:02:34 -08:00
jnjpng
89ca8fe8b0 feat: read from encrypted values with error on fallback [LET-4250] (#6484)
* base

* warning

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-12-15 12:02:33 -08:00
cthomas
345ea42630 feat: offload all file i/o in server endpoints LET-6252 (#6300)
feat: offload all file i/o in server endpoints
2025-11-24 19:10:26 -08:00
jnjpng
d4a75b1a2f chore: enable optimistic tool sync (#5612)
base

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-24 15:14:09 -07:00
Kian Jones
45065297a0 feat: runtime validation for ids for internal managers calls (#5544)
* claude coded first pass

* fix test cases to expect errors instead

* fix this

* let's see how letta-code did

* claude

* fix tests, remove dangling comments, retrofit all managers functions with decorator

* revert to main for these since we are not erroring on invalid tool and block ids

* reorder decorators

* finish refactoring test cases

* reorder agent_manager decorators and fix test tool manager

* add decorator on missing managers

* fix id sources

* remove redundant check

* uses enum now

* move to enum
2025-10-24 15:13:47 -07:00
jnjpng
e3f794dac5 fix: handle async context task cleanup for mcp client [LET-5746] (#5619)
* base

* update

* update

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-24 15:13:15 -07:00
jnjpng
dfcb7ee73d fix: poll for authorization url with timeout [LET-5740] (#5595)
base

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-24 15:13:15 -07:00
jnjpng
a880fb49ae fix: test disabling optimistic sync (#5576)
base

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-24 15:13:15 -07:00
Ari Webb
f98f729218 create or update instead of create [LET-5566] (#5496)
* create or update instead of create

* silence error

---------

Co-authored-by: Ari Webb <ari@letta.com>
2025-10-24 15:12:11 -07:00
jnjpng
5d153214c0 feat: allow invalid schema tools to be attached with warning (#5341)
* base

* allow attach

* display badge

* clean up

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-24 15:11:31 -07:00
jnjpng
b3fef4b5a8 feat: double write to all encrypted columns and decrypt on read (#5265)
* base

* use secret field

* fix

* auth code

* stage publish

* decouple backfill

* revert uncomment

* providers and agent vars

* mcp

* mcp

* stage and publish

* fix oauth

* double encrypt

* sandbox

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-24 15:11:31 -07:00
Sarah Wooders
af2a28b1b1 fix: add schema patching for mcp list tools (#5105) 2025-10-07 17:50:48 -07:00
Sarah Wooders
7b73b25a95 fix: fix mcp for complex schemas and add tests (#5063) 2025-10-07 17:50:48 -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
Kian Jones
fecf6decfb chore: migrate to ruff (#4305)
* base requirements

* autofix

* Configure ruff for Python linting and formatting

- Set up minimal ruff configuration with basic checks (E, W, F, I)
- Add temporary ignores for common issues during migration
- Configure pre-commit hooks to use ruff with pass_filenames
- This enables gradual migration from black to ruff

* Delete sdj

* autofixed only

* migrate lint action

* more autofixed

* more fixes

* change precommit

* try changing the hook

* try this stuff
2025-08-29 11:11:19 -07:00
cthomas
2a5306b748 fix: unassigned local var error (#4140) 2025-08-24 12:39:29 -07:00
jnjpng
74029acb0d fix: mcp schema generation and non-strict schema validation
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-08-22 15:45:33 -07:00
jnjpng
afc4809be0 feat: add x-agent-id header for mcp tool execution
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-08-22 14:09:03 -07:00
jnjpng
c38b1f5992 fix: mcp client cleanup but finally
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-08-22 13:07:58 -07:00
Charles Packer
773a6452d1 fix: handle faulty schemas from bad mcp servers better
Co-authored-by: jnjpng <jin@letta.com>
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-08-15 16:08:52 -07:00
jnjpng
711c22ec0e feat: add mcp tool simulator
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-08-14 16:31:43 -07:00
cthomas
cf719cc1dd fix: mcp client unbound var (#3925) 2025-08-14 11:58:59 -07:00
jnjpng
93e41bbf0a fix: delete associated mcp oauth sessions on delete and link existing mcp oauth sessions on create
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-08-12 15:32:33 -07:00
Charles Packer
62103fab2b fix: patch mcp alerting on sentry 2025-08-11 10:26:42 -07:00
jnjpng
25c83dcf2e fix: handling 401 unauthorized for streamable http oauth
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-07-31 12:28:51 -07:00
jnjpng
04511d1ffc feat: allow mcp authentication overrides per agent (#3318)
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-07-28 18:20:58 -07:00
jnjpng
711cc7b824 fix: catch and log mcp tool list exceptions
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-07-25 13:07:05 -07:00
jnjpng
aa30da9169 fix: test_agent_serialization_v2.py and use bulk fetch when fetching mcp servers
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-07-25 18:13:05 +00:00
jnjpng
4fb8902084 feat: add support for oauth mcp
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-07-24 18:23:01 -07:00
jnjpng
df738ba34a feat: support mcp server export/import with agent files
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-07-24 18:17:08 -07:00
Andy Li
04e9f43220 chore: strings lint cleanup (#3374) 2025-07-18 09:20:45 -07:00
jnjpng
91f556e014 feat: mcp custom headers and multiple fixes (#3079)
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-07-03 00:06:21 +00:00
jnjpng
c6aca63d56 fix: test async context fix for mcp clients (#2880)
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-06-18 16:52:58 +00:00
jnjpng
76b9dc1599 fix: mcp fixes and update flow (#2851)
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-06-17 16:19:27 -07:00
jnjpng
6efbc56e3b feat: add token column to mcp_servers and pipe through to sse server config (#2775)
Co-authored-by: Jin Peng <jinjpeng@Jins-MacBook-Pro.local>
2025-06-14 18:48:10 -07:00
Sarah Wooders
bb0122c662 feat: default to False for mcp_read_from_config (#2691) 2025-06-06 16:28:27 -07:00
cthomas
78c82f1ad9 fix: move db logic inside sessions (#2553) 2025-05-30 14:02:25 -07:00
cthomas
f6102e8a87 fix: parse function response for async agent loop (#2411)
Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
2025-05-24 09:26:48 -07:00
Sarah Wooders
8133a5a158 feat: add MCP servers into a table and MCP tool execution to new agent loop (#2323)
Co-authored-by: Matt Zhou <mattzh1314@gmail.com>
Co-authored-by: Kian Jones <11655409+kianjones9@users.noreply.github.com>
2025-05-23 16:22:16 -07:00