Commit Graph

57 Commits

Author SHA1 Message Date
Kian Jones
f5c4ab50f4 chore: add ty + pre-commit hook and repeal even more ruff rules (#9504)
* auto fixes

* auto fix pt2 and transitive deps and undefined var checking locals()

* manual fixes (ignored or letta-code fixed)

* fix circular import

* remove all ignores, add FastAPI rules and Ruff rules

* add ty and precommit

* ruff stuff

* ty check fixes

* ty check fixes pt 2

* error on invalid
2026-02-24 10:55:11 -08:00
Kian Jones
25d54dd896 chore: enable F821, F401, W293 (#9503)
* auto fixes

* auto fix pt2 and transitive deps and undefined var checking locals()

* manual fixes (ignored or letta-code fixed)

* fix circular import
2026-02-24 10:55:08 -08:00
Kian Jones
f55ff3a822 fix(core): descriptive error for empty message_ids instead of IndexError (#9464)
fix(core): replace IndexError with descriptive error for empty message_ids

Agent with no in-context messages (empty/None message_ids) would crash
with a cryptic IndexError on message_ids[0]. Now raises a clear
LettaError explaining the system message was not initialized.

Datadog: https://us5.datadoghq.com/error-tracking/issue/6c061c28-0830-11f1-b060-da7ad0900000

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

Co-authored-by: Letta <noreply@letta.com>
2026-02-24 10:52:07 -08:00
Ari Webb
c08b67a26a feat: add ToolReturnCreate to MessageCreateParams [LET-7366] (#9385)
* fix: add ToolReturnCreate to sdk types

* ci
2026-02-24 10:52:07 -08:00
cthomas
6f8f227e64 fix: improve approval retry idempotency check for server-side tool calls (#9136)
**Problem:**
When retrying an approval response, the idempotency check only looked at
the last message. If the approved tool triggered server-side tool calls
(e.g., `memory`), those tool returns would be the last message, causing
the idempotency check to fail with:
"Cannot process approval response: No tool call is currently awaiting approval."

**Root Cause:**
The check at line 249 only validated `current_in_context_messages[-1]`,
but server-side tool calls can add additional tool return messages after
the original approved tool's return.

**Fix:**
Search the last 10 messages (instead of just the last one) for a tool
return matching the approval's tool_call_ids. This handles the case where
server-side tool calls happen after the approved tool executes, while
keeping the search bounded and efficient.

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

Co-authored-by: Letta <noreply@letta.com>
2026-01-29 12:44:04 -08:00
cthomas
57ab117437 feat: dedupe approval response retries on server (#9038) 2026-01-29 12:44:04 -08:00
Charles Packer
2fc592e0b6 feat(core): add image support in tool returns [LET-7140] (#8985)
* feat(core): add image support in tool returns [LET-7140]

Enable tool_return to support both string and ImageContent content parts,
matching the pattern used for user message inputs. This allows tools
executed client-side to return images back to the agent.

Changes:
- Add LettaToolReturnContentUnion type for text/image content parts
- Update ToolReturn schema to accept Union[str, List[content parts]]
- Update converters for each provider:
  - OpenAI Chat Completions: placeholder text for images
  - OpenAI Responses API: full image support
  - Anthropic: full image support with base64
  - Google: placeholder text for images
- Add resolve_tool_return_images() for URL-to-base64 conversion
- Make create_approval_response_message_from_input() async

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

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

* fix(core): support images in Google tool returns as sibling parts

Following the gemini-cli pattern: images in tool returns are sent as
sibling inlineData parts alongside the functionResponse, rather than
inside it.

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

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

* test(core): add integration tests for multi-modal tool returns [LET-7140]

Tests verify that:
- Models with image support (Anthropic, OpenAI Responses API) can see
  images in tool returns and identify the secret text
- Models without image support (Chat Completions) get placeholder text
  and cannot see the actual image content
- Tool returns with images persist correctly in the database

Uses secret.png test image containing hidden text "FIREBRAWL" that
models must identify to pass the test.

Also fixes misleading comment about Anthropic only supporting base64
images - they support URLs too, we just pre-resolve for consistency.

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

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

* refactor: simplify tool return image support implementation

Reduce code verbosity while maintaining all functionality:
- Extract _resolve_url_to_base64() helper in message_helper.py (eliminates duplication)
- Add _get_text_from_part() helper for text extraction
- Add _get_base64_image_data() helper for image data extraction
- Add _tool_return_to_google_parts() to simplify Google implementation
- Add _image_dict_to_data_url() for OpenAI Responses format
- Use walrus operator and list comprehensions where appropriate
- Add integration_test_multi_modal_tool_returns.py to CI workflow

Net change: -120 lines while preserving all features and test coverage.

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

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

* fix(tests): improve prompt for multi-modal tool return tests

Make prompts more direct to reduce LLM flakiness:
- Simplify tool description: "Retrieves a secret image with hidden text. Call this function to get the image."
- Change user prompt from verbose request to direct command: "Call the get_secret_image function now."
- Apply to both test methods

This reduces ambiguity and makes tool calling more reliable across different LLM models.

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

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

* fix bugs

* test(core): add google_ai/gemini-2.0-flash-exp to multi-modal tests

Add Gemini model to test coverage for multi-modal tool returns. Google AI already supports images in tool returns via sibling inlineData parts.

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

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

* fix(ui): handle multi-modal tool_return type in frontend components

Convert Union<string, LettaToolReturnContentUnion[]> to string for display:
- ViewRunDetails: Convert array to '[Image here]' placeholder
- ToolCallMessageComponent: Convert array to '[Image here]' placeholder

Fixes TypeScript errors in web, desktop-ui, and docker-ui type-checks.

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

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

---------

Co-authored-by: Letta <noreply@letta.com>
Co-authored-by: Caren Thomas <carenthomas@gmail.com>
2026-01-29 12:43:53 -08:00
Sarah Wooders
87d920782f feat: add conversation and conversation_messages tables for concurrent messaging (#8182) 2026-01-12 10:57:48 -08:00
cthomas
e6a4b3e874 fix: nonetype not iterable (#7216) 2025-12-17 17:31:02 -08:00
Sarah Wooders
c9ad2fd7c4 chore: move things to debug logging (#6610) 2025-12-15 12:03:09 -08:00
Sarah Wooders
bbd52e291c feat: refactor summarization and message persistence code [LET-6464] (#6561) 2025-12-15 12:02:34 -08:00
cthomas
109989ac1a fix: tracing for summarizer errors (#6524) 2025-12-15 12:02:33 -08:00
Sarah Wooders
f417e53638 fix: fix cancellation issues without making too many changes to message_ids persistence (#6442) 2025-12-15 12:02:19 -08:00
cthomas
db534836e4 feat: allow follow up user message for approvals LET-6272 (#6392)
* feat: allow follow up user message for approvals

* add tests
2025-11-26 14:39:40 -08:00
cthomas
4bb116f17c fix: sync api call in message path (#6291)
* fix: sync api call in message path

* remove unused function

* add new error type
2025-11-24 19:10:26 -08:00
cthomas
73dcc0d4b7 feat: latest hitl + parallel tool call changes (#5565) 2025-10-24 15:12:49 -07:00
cthomas
de0896c547 fix: list index out of range empty message history (#5561)
* fix: list index out of range empty message history

* address kian comments
2025-10-24 15:12:26 -07:00
cthomas
f8437d47e2 feat: add support for hitl parallel tool calling (#5549)
* feat: add support for hitl parallel tool calling

* rename to requested_tool_calls
2025-10-24 15:12:11 -07:00
jnjpng
bcfc94846d fix: include run_id and step_id in temporal agent workflow [LET-5387] (#5429)
* base

* update

* fix: temporal agent workflow usage statistics [LET-5516] (#5436)

* base

* clean up comment

* remove import

---------

Co-authored-by: Letta Bot <noreply@letta.com>

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-24 15:12:11 -07:00
cthomas
fe91987749 feat: extend approvals validation to parallel tool calling (#5333) 2025-10-24 15:11:31 -07:00
cthomas
3128b5e126 feat: add client side tool calling support (#5313) 2025-10-24 15:11:31 -07:00
Sarah Wooders
ef07e03ee3 feat: add run_id to input messages and step_id to messages (#5099) 2025-10-07 17:50:48 -07:00
Matthew Zhou
803b837c64 feat: Support pre-filling arguments on InitToolRule [LET-4569] (#5057)
* Add args

* Add testing to tool rule solver

* Add live integration tests for args prefilling

* Add args override
2025-10-07 17:50:48 -07:00
Matthew Zhou
41e1f01659 feat: Factor our approval parsing logic (#4782)
Factor our approval parsing logic
2025-10-07 17:50:44 -07:00
Matthew Zhou
a3925e6a7b feat: Add get valid tools helper pure function [LET-4439] (#4771)
Add get valid tools helper function
2025-10-07 17:50:43 -07:00
Matthew Zhou
2c89b24021 feat: Scaffold pre-handle ai response activities (#4765)
* Scaffold pre handle ai response activities

* workflow specific timeouts
2025-09-17 17:53:53 -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
Charles Packer
0d195bd2b7 fix(core): patch the error throwing for HITL [LET-4218] (#4455)
fix: patch the error throwing for HITL
2025-09-06 11:45:46 -07:00
Matthew Zhou
2ef47d8002 feat: Add search messages endpoint [LET-4144] (#4434)
* Add search messages endpoint

* Run fern autogen and fix tests
2025-09-05 14:28:27 -07:00
Matthew Zhou
cbf2e09e13 feat: Add project id to message schema [LET-4166] (#4433)
* Add project id

* Propogate through update message by id async

* Add project id testing
2025-09-04 16:50:41 -07:00
Matthew Zhou
6e633bd8f9 feat: Change namespace to be org scoped and filter on agent_id [LET-4163] (#4368)
* Change to org scoped and agent_id filtering

* Finish modifying conversation search tool

* Fix failing tests

* Get rid of bad imports
2025-09-03 10:00:19 -07:00
cthomas
315d07568b feat: handle message persistence for approvals flows (#4338) 2025-09-01 14:10:02 -07:00
cthomas
8d1389146a feat: support deny tool call request (#4334) 2025-09-01 10:33:18 -07:00
cthomas
86b073d726 feat: support approve tool call request (#4333) 2025-08-31 11:26:21 -07:00
cthomas
9d03869287 feat: add error handling for approval response attempt (#4326)
* feat: add error handling for approval response attempt

* add one more error case

* improve error messages
2025-08-29 20:39:28 -07:00
cthomas
bb87cc68c7 feat: add approval create input to messages endpoints [LET-4110] (#4309)
* feat: add approval create input to messages endpoints

* rename discriminator tag

* add base class with default

* add field validator

* exclude new type field from agent file schema
2025-08-29 13:16:03 -07:00
cthomas
7f104fd99c fix: tool logging error (#3998) 2025-08-18 18:01:23 -07:00
cthomas
4765f8e7f5 feat: set frequency penalty to 1 for gpt-4o (#3962) 2025-08-18 14:20:16 -07:00
Andy Li
04e9f43220 chore: strings lint cleanup (#3374) 2025-07-18 09:20:45 -07:00
Matthew Zhou
4848e53530 fix: Fix parsing bug where Anthropic returns nested JSON (#3096) 2025-06-29 11:41:33 -07:00
Matthew Zhou
a31826d7a5 feat: Override heartbeat request when system forces step exit (#3015) 2025-06-24 19:50:00 -07:00
Sarah Wooders
4deb6e17a9 feat: add ability to configure agent timezone (#2978)
Co-authored-by: Kian Jones <kian@letta.com>
2025-06-24 12:57:37 -07:00
cthomas
1405464a1c feat: send stop reason in letta APIs (#2789) 2025-06-13 16:04:48 -07:00
Sarah Wooders
3e6729214b feat: add include_return_message_types to LettaRequest to filter down requests (#2666) 2025-06-06 15:48:27 -07:00
cthomas
0020183459 feat: consolidate message persistence (#2518)
Co-authored-by: Matt Zhou <mattzh1314@gmail.com>
2025-05-29 16:23:13 -07:00
cthomas
d650a39670 feat: optimize system message fetch (#2509) 2025-05-28 23:15:53 -07:00
Andy Li
a78abc610e feat: track llm provider traces and tracking steps in async agent loop (#2219) 2025-05-19 15:50:56 -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