Commit Graph

61 Commits

Author SHA1 Message Date
Ari Webb
5c6ca705f1 Revert "feat: bring back use message packing for timezone [LET-6846]" (#9302)
Revert "feat: bring back use message packing for timezone [LET-6846] (#9256)"

This reverts commit c5017cccdef95b84fc585b26a0ddc5b7e44eb7c9.
2026-02-24 10:52:06 -08:00
jnjpng
ff69c6a32e feat: add /agents/{agent_id}/generate endpoint for direct LLM requests (#9272)
* feat: add /agents/{agent_id}/generate endpoint for direct LLM requests

Add new endpoint that makes direct LLM provider requests without agent
context, memory, tools, or state modification. This enables:
- Quick LLM queries without agent overhead
- Testing model configurations
- Simple chat completions using agent's credentials
- Comparing responses across different models

Features:
- Uses agent's LLM config by default
- Supports model override with full provider config resolution
- Non-streaming, stateless operation
- Proper error handling and validation
- Request/response schemas with Pydantic validation

Implementation:
- Add GenerateRequest and GenerateResponse schemas
- Implement generate_completion endpoint handler
- Add necessary imports (LLMError, LLMClient, HandleNotFoundError)
- Include logging and comprehensive error handling

* fix: improve error handling and fix Message construction

- Fix critical bug: use content=[TextContent(text=...)] instead of text=...
- Add explicit error handling for NoResultFound and HandleNotFoundError
- Add error handling for convert_response_to_chat_completion
- Add structured logging for debugging
- Remove unnecessary .get() calls since Pydantic validates messages

* refactor: extract generate logic to AgentCompletionService

Move the generate endpoint business logic out of the endpoint handler
into a dedicated AgentCompletionService class for better code organization
and separation of concerns.

Changes:
- Create new AgentCompletionService in services/agent_completion_service.py
- Service handles all business logic: agent validation, LLM config resolution,
  message conversion, LLM client creation, and request/response processing
- Integrate service with SyncServer initialization
- Refactor generate_completion endpoint to use the service
- Endpoint now only handles HTTP concerns (auth, error mapping)

Benefits:
- Cleaner endpoint code (reduced from ~140 lines to ~25 lines)
- Better separation of concerns (HTTP vs business logic)
- Service logic can be reused or tested independently
- Follows established patterns in the codebase (AgentManager, etc.)

* feat: simplify generate API to accept just prompt text

Simplify the client interface by accepting a simple prompt string instead
of requiring clients to format messages.

Changes:
- Update GenerateRequest schema:
  - Replace 'messages' array with simple 'prompt' string
  - Add optional 'system_prompt' for context/instructions
  - Keep 'override_model' for model selection
- Update AgentCompletionService to format messages automatically:
  - Accepts prompt and optional system_prompt
  - Constructs message array internally (system + user messages)
  - Simpler API surface for clients
- Update endpoint documentation with new simplified examples
- Regenerate OpenAPI spec and TypeScript SDK

Benefits:
- Much simpler client experience - just send text
- No need to understand message formatting
- Still supports system prompts for context
- Cleaner API that matches common use cases

Example (before):
{
  "messages": [{"role": "user", "content": "What is 2+2?"}]
}

Example (after):
{
  "prompt": "What is 2+2?"
}

* test: add comprehensive integration tests for generate endpoint

Add 9 integration tests covering various scenarios:

Happy path tests:
- test_agent_generate_basic: Basic prompt -> response flow
- test_agent_generate_with_system_prompt: System prompt + user prompt
- test_agent_generate_with_model_override: Override model selection
- test_agent_generate_long_prompt: Handle longer prompts
- test_agent_generate_no_persistence: Verify no messages saved to agent

Error handling tests:
- test_agent_generate_empty_prompt_error: Empty prompt validation (422)
- test_agent_generate_invalid_agent_id: Invalid agent ID (404)
- test_agent_generate_invalid_model_override: Invalid model handle (404)

All tests verify:
- Response structure (content, model, usage)
- Proper status codes for errors
- Usage statistics (tokens, counts)
- No side effects on agent state

Tests follow existing test patterns in test_client.py and use the
letta_client SDK (assuming generate_completion method is auto-generated
from the OpenAPI spec).

* openapi

* refactor: rename AgentCompletionService to AgentGenerateCompletionManager

Rename for better clarity and consistency with codebase naming conventions:
- Rename file: agent_completion_service.py → agent_generate_completion_manager.py
- Rename class: AgentCompletionService → AgentGenerateCompletionManager
- Rename attribute: server.agent_completion_service → server.agent_generate_completion_manager
- Update docstrings: 'Service' → 'Manager'

Changes:
- apps/core/letta/services/agent_generate_completion_manager.py (renamed + updated class)
- apps/core/letta/server/server.py (import + initialization)
- apps/core/letta/server/rest_api/routers/v1/agents.py (usage in endpoint)

No functional changes, purely a naming refactor.

* fix: remove invalid Message parameters in generate manager

Remove agent_id=None and user_id=None from Message construction.
The Message model doesn't accept these as None values - only pass
required parameters (role, content).

Fixes validation error:
  'Extra inputs are not permitted [type=extra_forbidden, input_value=None]'

This aligns with other Message construction patterns in the codebase
(see tools.py, memory.py examples).

* feat: improve generate endpoint validation and tests

- Add field validator for whitespace-only prompts
- Always include system message (required by Anthropic)
- Use default "You are a helpful assistant." when no system_prompt provided
- Update tests to use direct HTTP calls via httpx
- Fix test issues:
  - Use valid agent ID format (agent-{uuid})
  - Use available model (openai/gpt-4o-mini)
  - Add whitespace validation test
- All 9 integration tests passing
2026-02-24 10:52:06 -08:00
Ari Webb
426f6a8ca4 feat: bring back use message packing for timezone [LET-6846] (#9256)
* feat: bring back use message packing for timezone

* add tests
2026-02-24 10:52:06 -08:00
Shelley Pham
4353df683e Shelley/let 7155 favorites tagged should be user scoped [LET-7155] (#9003)
* make favorite tag a const

* add favorite:user:{userId} for favorites

* favorite agent upon initial creation

* rename const

* add eslint ignore

* expect favorite tag
2026-01-29 12:43:53 -08:00
Shubham Naik
4578a9203f chore: fix e2e (#8773) 2026-01-19 15:54:41 -08:00
Shubham Naik
e877418443 chore: fix e2e (#8768) 2026-01-19 15:54:41 -08:00
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
Sarah Wooders
0c0ba5d03d fix: remove letta-free embeddings from testing (#6870) 2025-12-15 12:03:09 -08:00
Sarah Wooders
a721a00899 feat: add agent_id to search results (#6867) 2025-12-15 12:03:09 -08:00
cthomas
7b0bd1cb13 feat: cutover repo to 1.0 sdk client LET-6256 (#6361)
feat: cutover repo to 1.0 sdk client
2025-11-24 19:11:18 -08:00
Sarah Wooders
5730f69ecf feat: modal tool execution - NO FEATURE FLAGS USES MODAL [LET-4357] (#5120)
* initial commit

* add delay to deploy

* fix tests

* add tests

* passing tests

* cleanup

* and use modal

* working on modal

* gate on tool metadata

* agent state

* cleanup

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-11-13 15:36:56 -08:00
jnjpng
849d0dc64a feat: provider-specific model configuration (#5873) (#5874) 2025-11-13 15:36:55 -08:00
Sarah Wooders
cfeed463a9 Revert "feat: provider-specific model configuration " (#5873)
Revert "feat: provider-specific model configuration  (#5774)"

This reverts commit 34a334949a3ef72cd49ff0ca3da9e85d16daa57c.
2025-11-13 15:36:20 -08:00
Sarah Wooders
aaa12a393c feat: provider-specific model configuration (#5774)
* initial code updates

* add models

* cleanup

* support overriding

* add apis

* cleanup reasoning interfaces to match models

* update schemas

* update apis

* add new field

* remove parallel

* various fixes

* modify schemas

* fix

* fix

* make model optional

* undo model schema change

* update schemas

* update schemas

* format

* fix tests

* attempt to patch web

* fic docs

* change schemas

* update error

* fix tests

* delete tests

* clean up undefined matching conditional

---------

Co-authored-by: jnjpng <jin@letta.com>
Co-authored-by: Letta Bot <noreply@letta.com>
2025-11-13 15:36:14 -08: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
Matthew Zhou
ef225d3e49 fix: Temp remove timezone test (#4427)
Temp remove test
2025-09-04 12:05:16 -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
Andy Li
ad52c7001c test: reduce flakiness of tz testing 2025-08-12 14:53:36 -07:00
Sarah Wooders
f7e6e49ab5 chore: patch timezone tests (#3789) 2025-08-06 17:24:00 -07:00
cthomas
6f77017408 fix: cloud api test Embedding is not allowed in cloud API (#3621) 2025-07-29 13:24:07 -07:00
cthomas
d936335f27 fix: sources test (#3581) 2025-07-26 23:38:50 -07:00
Shubham Naik
d292b6e4de chore: restrict custom embeddings in cloud (#3578)
Co-authored-by: Shubham Naik <shub@memgpt.ai>
2025-07-26 16:14:23 -07:00
Andy Li
1959109821 feat: support for project_id and backfills 2025-07-25 13:06:12 -07:00
Sarah Wooders
0f5bc65aa2 fix: enable updating agent timezone (#3095) 2025-06-29 11:30:47 -07:00
Sarah Wooders
581454c58c fix: remove no_commit=True for sleeptime block patch and add client tests (#3057) 2025-06-26 18:01:08 -07:00
Sarah Wooders
912766141b chore: add back timezone tests (#3011)
Co-authored-by: Andy Li <55300002+cliandy@users.noreply.github.com>
2025-06-25 15:12:21 -07:00
Sarah Wooders
2feaac398f fix: fix timezone setting and add client tests (#2997) 2025-06-24 17:49:54 -07:00
Matthew Zhou
91432088f9 feat: Add auto attach and detach of file tools (#2655) 2025-06-05 14:01:29 -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
Matthew Zhou
917821a735 refactor: Deprecate local client (#2344) 2025-05-22 18:57:14 -07:00
Kian Jones
3f47a8557c feat(ci): Adds Integration Testing Against cloud-api (#1909)
Co-authored-by: Shubham Naik <shub@letta.com>
Co-authored-by: Shubham Naik <shub@memgpt.ai>
2025-05-08 11:28:41 -07:00
Matthew Zhou
e6eea9450b feat: Add Letta voice tools (#1922) 2025-04-29 10:46:29 -07:00
Andy Li
3fd49c5037 fix: docker tests - local sandbox call and agent listing tests (#1888) 2025-04-24 17:10:51 -07:00
Sarah Wooders
55c3fbba3f chore: add sleeptime example + better error handling + upgrade client SDK (#1809) 2025-04-21 00:09:50 -07:00
Matthew Zhou
227b76fe0e feat: Add testing for SDK send_message variants (#1520) 2025-04-01 16:54:09 -07:00
Matthew Zhou
131a3b021b feat: Refactor letta tool execution to not require agent class (#1384) 2025-03-24 12:25:03 -07:00
Charles Packer
44ecc2dab8 fix: don't throw an error if adding a new mcp server, also allow sett… (#1293) 2025-03-15 13:45:20 -07:00
Sarah Wooders
56679d2cea chore: migrate tests to new client (#1290) 2025-03-14 15:17:28 -07:00
Matthew Zhou
b5e09536ae feat: Serialize agent state simple fields and messages (#1012) 2025-02-18 11:01:10 -08:00
cthomas
7bc5fab2b1 fix: revert sandbox error message (#904) 2025-02-05 13:54:18 -08:00
mlong93
c3e425c012 fix: failed tool calls will not be called in the subsequent step (#868)
Co-authored-by: Mindy Long <mindy@letta.com>
Co-authored-by: Shubham Naik <shubham.naik10@gmail.com>
2025-02-01 16:41:37 -08:00
Matthew Zhou
03fe297846 fix: Remove name from Create/Update tool (#741)
Co-authored-by: Caren Thomas <caren@letta.com>
2025-01-24 10:55:23 -08:00
mlong93
d6be7809d0 fix: deprecate cursor param and replace with before, after (#736)
Co-authored-by: Mindy Long <mindy@letta.com>
2025-01-23 14:17:25 -08:00
mlong93
c9e18e66f1 fix: move all attach detach to be under agents (#723)
Co-authored-by: Mindy Long <mindy@letta.com>
2025-01-22 12:16:31 -08:00
cthomas
cabb04c005 fix: rename memory/block routes to core_memory/blocks (#711) 2025-01-21 18:03:04 -08:00
mlong93
b9775ca3b4 fix: updated send_message_async request params, get_run_messages returns LettaMessage (#638)
Co-authored-by: Mindy Long <mindy@letta.com>
Co-authored-by: cthomas <caren@letta.com>
Co-authored-by: Shubham Naik <shubham.naik10@gmail.com>
Co-authored-by: Shubham Naik <shub@memgpt.ai>
2025-01-15 14:47:20 -08:00
mlong93
f10b87e8fa feat: add text search for agent names (#662)
Co-authored-by: Mindy Long <mindy@letta.com>
2025-01-15 10:41:40 -08:00
mlong93
b92370cdad feat: Added list_tags route (#645)
Co-authored-by: Mindy Long <mindy@letta.com>
2025-01-14 13:33:55 -08:00