Commit Graph

260 Commits

Author SHA1 Message Date
jnjpng
591420876a fix: correct decorator order for trace_method and raise_on_invalid_id (#7226)
Swap the order of @trace_method and @raise_on_invalid_id decorators
across all service managers so that @trace_method is always the first
wrapper applied to the function (positioned directly above the method).

This ensures the ID validation happens before tracing begins, which is
the intended execution order.

Files modified:
- agent_manager.py (23 occurrences)
- archive_manager.py (11 occurrences)
- block_manager.py (7 occurrences)
- file_manager.py (6 occurrences)
- group_manager.py (9 occurrences)
- identity_manager.py (10 occurrences)
- job_manager.py (7 occurrences)
- message_manager.py (2 occurrences)
- provider_manager.py (3 occurrences)
- sandbox_config_manager.py (7 occurrences)
- source_manager.py (5 occurrences)
- step_manager.py (13 occurrences)
2025-12-17 17:31:02 -08:00
jnjpng
25d75d6528 fix: update aysnc get plaintext callsites (#7069)
* base

* resolve

* fix

* fix
2025-12-17 17:31:02 -08:00
jnjpng
4be813b956 fix: migrate sandbox and agent environment variables to encrypted only (#6623)
* base

* remove unnnecessary db migration

* update

* fix

* update

* update

* comments

* fix

* revert

* anotha

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-12-15 12:03:08 -08:00
Sarah Wooders
7ea297231a feat: add compaction_settings to agents (#6625)
* initial commit

* Add database migration for compaction_settings field

This migration adds the compaction_settings column to the agents table
to support customized summarization configuration for each agent.

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

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

* fix

* rename

* update apis

* fix tests

* update web test

---------

Co-authored-by: Letta <noreply@letta.com>
Co-authored-by: Kian Jones <kian@letta.com>
2025-12-15 12:02:34 -08:00
cthomas
0d77b373e6 fix: remove concurrent db writes for file upload (#6617) 2025-12-15 12:02:34 -08:00
Ari Webb
eb547bb96e fix: clear message history no longer deletes messages (#6515)
* fix: clear message history no longer deletes messages

* toast and make it stay for 8 secs

* fix test

---------

Co-authored-by: Ari Webb <ari@letta.com>
2025-12-15 12:02:33 -08:00
Sarah Wooders
91e3dd8b3e feat: fix new summarizer code and add more tests (#6461) 2025-12-15 12:02:19 -08:00
Sarah Wooders
807c5c18d9 feat: add gemini token counting [LET-6371] (#6444) 2025-12-15 12:02:19 -08:00
Kian Jones
94c2921711 chore: walk back some temporary debugging stuff (#6332)
* first pass

* uv lock
2025-11-24 19:10:27 -08:00
Ari Webb
f9b405372d feat: add search routes [LET-6236] (#6280)
* claude code first pass

* rename routes

* search_messages and list_messages

* revert agents messagesearch

* generate api

* fix backend for list all messages

* request for message search

* return list of letta message

* add tests

* error in archive endpoint

* archive delete return type wrong

* optional params for archive creation

* add passage to tpuf on create

* fix archive manager

* support global passage search

* search by agent

* just do basic org wide search for now

* change message test to be about fresh data, cleanup after

---------

Co-authored-by: Ari Webb <ari@letta.com>
2025-11-24 19:10:27 -08:00
Ari Webb
14843b2600 feat: enable folder_ids on agent create [LET-6147] (#6247)
enable folder_ids

Co-authored-by: Ari Webb <ari@letta.com>
2025-11-24 19:09:33 -08:00
Shelley Pham
7ce33c4f22 feat: add attach detach memory block functionality [LET-5860] (#6207) 2025-11-24 19:09:33 -08:00
Ari Webb
65a733d5dd fix: make attach/detach routes return None if sdk verion 1.0 (#6203)
* Revert "Revert "feat: make attach/detach routes return None if version is 1.0 [LET-5844]" (#6201)"

This reverts commit bb0d10725f5889306de61e1758f061d6c1041c52.

* fix type checking

* revert

* return state for blocks and sources

* func signatures

* create memgpt_agent for cloud-e2e-tests

* Revert "create memgpt_agent for cloud-e2e-tests"

This reverts commit f279e5897b0942b1006a5f8527713dd801064c63.

* fix

---------

Co-authored-by: Ari Webb <ari@letta.com>
2025-11-24 19:09:33 -08:00
Sarah Wooders
a466e65e6b feat: move sources to folders [LET-6189] (#6199) 2025-11-24 19:09:32 -08:00
Sarah Wooders
cce0f41095 Revert "feat: make attach/detach routes return None if version is 1.0 [LET-5844]" (#6201)
Revert "feat: make attach/detach routes return None if version is 1.0 [LET-58…"

This reverts commit 328c481da6e4e0f7f30a82dcc287c90835f431cc.
2025-11-24 19:09:32 -08:00
Ari Webb
e20feaa3e4 feat: make attach/detach routes return None if version is 1.0 [LET-5844] (#6141)
---------

Co-authored-by: Ari Webb <ari@letta.com>
2025-11-24 19:09:32 -08:00
Kian Jones
848aa962b6 feat: add memory tracking to core (#6179)
* add memory tracking to core

* move to asyncio from threading.Thread

* remove threading.thread all the way

* delay decorator monitoring initialization until after event loop is registered

* context manager to decorator

* add psutil
2025-11-24 19:09:32 -08:00
Kian Jones
98ab655765 chore: add add limit of 100 (#6143)
* add limit of 100

* revert scheduler logging

* api changes

* remove redundant None type check
2025-11-13 15:36:56 -08:00
Shelley Pham
b73545cd60 fix: agents created from templates cannot read attached files [LET-6146] (#6137)
* fix: Ensure agents created from templates can read attached files

* test: Add test for template-based agent file attachment from sources
2025-11-13 15:36:56 -08:00
Kian Jones
077d0e2f9a feat: dump stack trace on segfault (#6121)
* dump stack trace on segfault

* log tokenizer
2025-11-13 15:36:56 -08:00
Charles Packer
5beaa84b5f fix(core): fix enable_sleeptime on letta_agent_v1 getting initial message sequence (#6018)
fix(core): for letta_agent_v1, if enable_sleeptime, make the sleeptime agent not have initial message sequence, similar to the base agent
2025-11-13 15:36:55 -08:00
Christina Tong
c76bc9e216 feat: add filters to count_agents endpoint [LET-5380] [LET-5497] (#6008)
* feat: add filters to count_agents endpoint [LET-5380]

* comment

* update
2025-11-13 15:36:55 -08:00
Christina Tong
881831501a feat: filter list agents by stop reason [LET-5928] (#5779)
* feat: add last_stop_reason to AgentState [LET-5911]

* feat: filter list agents by stop reason [LET-5928]

* undo agent loop changes, use update_run_by_id_async

* add run manager test

* add integration tests

* remove comment

* fix duplicate

* fix docs
2025-11-13 15:36:55 -08:00
Christina Tong
ef3df907c5 feat: add last_stop_reason to AgentState [LET-5911] (#5772)
* feat: add last_stop_reason to AgentState [LET-5911]

* undo agent loop changes, use update_run_by_id_async

* add run manager test

* add integration tests

* remove comment

* remove duplicate test
2025-11-13 15:36:55 -08:00
Sarah Wooders
1f05872b10 fix: patch attaching archival tools (#5869) 2025-11-13 15:36:20 -08:00
Ari Webb
015a209f40 fix: prevent cross tenancy attaching sources
patch

Co-authored-by: Ari Webb <ari@letta.com>
2025-11-13 15:36:14 -08:00
Kian Jones
704d3b2d79 chore: refactor not to use warnings.warn (#5730)
* refactor not to use warnings.warn

* temp circular import fix maybe unecessary/bnad

* fix Deprecation warning

* fix deprecation warning and mcp thing?

* revert changes to mcp server test

* fix deprecation warning
2025-10-24 15:14:31 -07:00
cthomas
875908cb44 feat: add include param to all backend list agents helpers (#5699) 2025-10-24 15:14:20 -07:00
cthomas
afdf0f80e3 feat: add backend support for agent relationship loads (#5693) 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
Kevin Lin
35b5383724 feat: match line number rendering to Anthropic / OAI defaults (#5492) 2025-10-24 15:13:15 -07:00
Kian Jones
d7b0a38a92 fix: index out of bounds check in agent_manager (#5571)
* set cur_system_message = None if there's no message ids

* typo
2025-10-24 15:13:15 -07:00
Kian Jones
4bbd760204 feat: add validation to fastapi routes for agent IDs (#5454)
* change my PR to match Caren's

* add path parameter validation for agent id first

* remove old import

* remove old agent_id_pattern pattern

* add example and fix max/min calculation to include hyphen

* fix regex string interpolation

* example deprecated in favour of examples

* openapi autogen

* change template test to expect 422

* fix 422 swallow

* expect 422 or 400

* rewrite  error codes

* fix hallucinated uuid

* tweaked error message test

* print docker logs on failure
2025-10-24 15:12:11 -07:00
Matthew Zhou
2dae4d33c3 feat: Implement streaming chat completions endpoint [LET-5485] (#5446)
* wip

* Add chat completions router and fix streaming service

* Finish chat completions

* Finish chat completions

* Remove extra print statement

* Run just api

* Don't explicitly throw http exceptions but surface Letta errors

* Remap errors

* Trigger CI

* Add missing Optional import
2025-10-24 15:12:11 -07:00
Shubham Naik
a95a449b02 feat: ignore bad tools when creating agents for template [LET-4850] (#5390)
* feat: ignore bad tools when creating agents for template

* chore: use paramater

* chore: next

* chore: next

---------

Co-authored-by: Shubham Naik <shub@memgpt.ai>
2025-10-24 15:12:11 -07:00
Kian Jones
158546414d fix: better error message for llm on agent failure (#5402)
* better error message for llm on agent failure

* raise NoResultFoundError instead of value error and do it outside async db registry
2025-10-24 15:11:31 -07:00
Sarah Wooders
7ab44e61fa feat: patch anthropic token counting + build-in tokenizers [LET-5377] (#5354) 2025-10-24 15:11:31 -07:00
Matthew Zhou
d826aceaf9 fix: Remove unuseful tool rules for v1 (#5345)
Remove unuseful tool rules for v1
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
cthomas
416af626cc feat: add pagination to agent folders endpoint (#5085)
* feat: add pagination to agent folders endpoint

* chore: regenerate API client with pagination parameters

* feat: add pagination parameters to agent folders and sources endpoints

- Add pagination parameters (before, after, limit, order, order_by) to list_agent_folders endpoint
- Add pagination parameters to list_agent_sources endpoint
- Update list_attached_sources_async method to support pagination with cursor-based filtering
- Regenerate API client with new pagination parameters
2025-10-07 17:50:49 -07:00
Sarah Wooders
7aff9aa659 feat: error handling for rest api for agents + blocks [LET-4625] (#5142) 2025-10-07 17:50:49 -07:00
Charles Packer
62a5d10099 fix(core): raise 404 properly for agent not found (#5118) 2025-10-07 17:50:49 -07:00
cthomas
7c03288c05 feat: add pagination to agent blocks endpoint (#5087)
* feat: add pagination to agent blocks endpoint

* chore: regenerate API client with pagination parameters

* feat: implement pagination logic in list_blocks endpoint

- Fix list_blocks implementation to use pagination parameters that were already in the route signature
- Add in-memory pagination logic for core memory blocks (sorting, cursor filtering, limit)
- Sort blocks by created_at timestamp with proper asc/desc ordering
- Apply cursor-based pagination with before/after filters
- Apply limit to results
- Regenerate API client code to reflect pagination functionality

* fix: correct sorting logic in list_blocks endpoint

- Fix AttributeError where blocks don't have created_at attribute
- Sort blocks by id instead of created_at (core memory blocks don't have timestamps)
- Maintains consistent pagination behavior while fixing runtime error

* feat: implement database-level pagination for list_blocks endpoint

- Replace inefficient in-memory filtering with proper SQLAlchemy query
- Use BlocksAgents join table to filter blocks by agent_id at database level
- Apply pagination filters (before, after, limit) in SQL query for better performance
- Sort by BlockModel.created_at instead of in-memory sorting
- Add necessary imports: select from sqlalchemy, db_registry from letta.server.db
- Verify agent access before querying blocks

* refactor: move database logic from route to agent manager service layer

- Add list_agent_blocks_async method to AgentManager for proper separation of concerns
- Move SQLAlchemy query logic from REST route to service layer
- Keep routes focused on request/response handling
- Remove unnecessary imports from router (select, db_registry)
- Database pagination logic now properly encapsulated in service layer
2025-10-07 17:50:48 -07:00
cthomas
6e3e45fb2d feat: add pagination to agent groups endpoint (#5089)
feat: add pagination to list_agent_groups endpoint

- Add pagination parameters to list_groups_async method (before, after, limit, ascending)
- Update list_agent_groups endpoint to include pagination parameters (before, after, limit, order, order_by)
- Add proper cursor-based pagination and sorting in SQL query
- Pass pagination parameters from route to underlying service method
- Regenerate API client to reflect pagination parameter changes
2025-10-07 17:50:48 -07:00
cthomas
1b4780fa27 feat: add back async list_groups in agent manager [LET-4597] (#5095)
feat: convert list_groups to async in agent manager

- Add list_groups_async method to AgentManager to replace sync version
- Method filters groups by agent_id using join with GroupsAgents table
- Supports optional manager_type filtering
- Update list_agent_groups endpoint to use new async method
- No functional changes to endpoint behavior or parameters
2025-10-07 17:50:48 -07:00
cthomas
874ac0dd5c feat: add pagination to agent tools endpoint (#5084)
* feat: add pagination to agent tools endpoint

* chore: regenerate API client with pagination parameters

* feat: implement pagination logic in list_agent_tools endpoint

- Update list_attached_tools_async method to support pagination parameters (before, after, limit, ascending)
- Update list_agent_tools route to pass pagination parameters to underlying service method
- Add proper cursor-based pagination and sorting in SQL query

* feat: update default limit for list_agent_tools to 10

* feat: regenerate API client after limit parameter change
2025-10-07 17:50:48 -07:00
Kevin Lin
09d9c3ffd4 feat: anthropic tools for claude sonnet 4.5 (#4988)
* add anthropic memory tools

* memory view working

* update memory examples

* tools

* feat: some changes (#5003)

* feat: added the ability to modify and add descriptions on creation

* fix: kill dead code & write into core_tool_executor instead

* fix: use block_manager not agent_manager where possible, also turn the return string errors into raising exceptions

* fix: cleanup, get rid of more return string errors replaced with valueerror, also drop deadcode

---------

Co-authored-by: Charles Packer <packercharles@gmail.com>
2025-10-07 17:50:47 -07:00
Matthew Zhou
171f9b0b19 fix: Refactor reset messages async to reduce idle in transaction [LET-4529] (#4958)
* Reduce comments

* Move turbopuffer outside of reset messages
2025-10-07 17:50:46 -07:00
Charles Packer
9fd901c3a5 fix(core): patch default reasoning for letta-free on letta v1 (#4953)
* fix(core): patch default reasoning for letta-free on letta v1

* fix: patch (unrelated?) bug w/ missing required for empty tools like reset_research
2025-10-07 17:50:46 -07:00
Matthew Zhou
b5053d02d5 fix: Fix multi agent test (#4947)
Fix multi agent
2025-10-07 17:50:46 -07:00