Commit Graph

64 Commits

Author SHA1 Message Date
Kian Jones
a92e868ee6 feat: centralize telemetry logging at LLM client level (#8815)
* feat: centralize telemetry logging at LLM client level

Moves telemetry logging from individual adapters to LLMClientBase:
- Add TelemetryStreamWrapper for streaming telemetry on stream close
- Add request_async_with_telemetry() for non-streaming requests
- Add stream_async_with_telemetry() for streaming requests
- Add set_telemetry_context() to configure agent_id, run_id, step_id

Updates adapters and agents to use new pattern:
- LettaLLMAdapter now accepts agent_id/run_id in constructor
- Adapters call set_telemetry_context() before LLM requests
- Removes duplicate telemetry logging from adapters
- Enriches traces with agent_id, run_id, call_type metadata

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

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

* fix: accumulate streaming response content for telemetry

TelemetryStreamWrapper now extracts actual response data from chunks:
- Content text (concatenated from deltas)
- Tool calls (id, name, arguments)
- Model name, finish reason, usage stats

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

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

* refactor: move streaming telemetry to caller (option 3)

- Remove TelemetryStreamWrapper class
- Add log_provider_trace_async() helper to LLMClientBase
- stream_async_with_telemetry() now just returns raw stream
- Callers log telemetry after processing with rich interface data

Updated callers:
- summarizer.py: logs content + usage after stream processing
- letta_agent.py: logs tool_call, reasoning, model, usage

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

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

* fix: pass agent_id and run_id to parent adapter class

LettaLLMStreamAdapter was not passing agent_id/run_id to parent,
causing "unexpected keyword argument" errors.

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

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

---------

Co-authored-by: Letta <noreply@letta.com>
2026-01-19 15:54:43 -08:00
jnjpng
85c242077e feat: strict tool calling setting (#8810)
base
2026-01-19 15:54:42 -08:00
Sarah Wooders
97cdfb4225 Revert "feat: add strict tool calling setting [LET-6902]" (#8720)
Revert "feat: add strict tool calling setting [LET-6902] (#8577)"

This reverts commit 697c9d0dee6af73ec4d5d98780e2ca7632a69173.
2026-01-19 15:54:39 -08:00
Sarah Wooders
bdede5f90c feat: add strict tool calling setting [LET-6902] (#8577) 2026-01-19 15:54:38 -08:00
Sarah Wooders
96cf24264c fix: avoid 'NoneType' object has no attribute 'name' error (#8407) 2026-01-12 10:57:49 -08:00
Sarah Wooders
87d920782f feat: add conversation and conversation_messages tables for concurrent messaging (#8182) 2026-01-12 10:57:48 -08:00
Sarah Wooders
7669896184 feat: allow client-side tools to be specified in request (#8220)
* feat: allow client-side tools to be specified in request

Add `client_tools` field to LettaRequest to allow passing tool schemas
at message creation time without requiring server-side registration.
When the agent calls a client-side tool, execution pauses with
stop_reason=requires_approval for the client to provide tool returns.

- Add ClientToolSchema class for request-level tool schemas
- Merge client tools with agent tools in _get_valid_tools()
- Treat client-side tool calls as requiring approval
- Add integration tests for client-side tools flow

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

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

* test: add comprehensive end-to-end test for client-side tools

Update integration test to verify the complete flow:
- Agent calls client-side tool and pauses
- Client provides tool return with secret code
- Agent processes and responds
- User asks about the code, agent recalls it
- Validate full conversation history makes sense

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

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

* update apis

* fix: client-side tools schema format and test assertions

- Use flat schema format for client tools (matching t.json_schema)
- Support both object and dict access for client tools
- Fix stop_reason assertions to access .stop_reason attribute

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

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

* refactor: simplify client_tools access pattern

ClientToolSchema objects always have .name attribute

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

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

* fix: add client_tools parameter to LettaAgentV2 for API compatibility

V2 agent doesn't use client_tools but needs the parameter
to match the base class signature.

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

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

* revert: remove client_tools from LettaRequestConfig

Client-side tools don't work with background jobs since
there's no client present to provide tool returns.

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

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

* fix: add client_tools parameter to SleeptimeMultiAgent classes

Add client_tools to step() and stream() methods in:
- SleeptimeMultiAgentV3
- SleeptimeMultiAgentV4

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

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

* chore: regenerate API specs for client_tools support

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

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

---------

Co-authored-by: Letta <noreply@letta.com>
2026-01-12 10:57:48 -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
Charles Packer
1c30ad6991 fix(core): patch anthropic context caching busting (#6516)
Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
2025-12-15 12:02:34 -08:00
Sarah Wooders
3569721fd4 fix: avoid infinite summarization loops (#6506) 2025-12-15 12:02:33 -08:00
jnjpng
c90eacdcbb fix: step metrics not found (#6472)
* base

* comment

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-12-15 12:02:19 -08:00
Sarah Wooders
90e2030f41 fix: fix manual summarization (#6466) 2025-12-15 12:02:19 -08:00
Charles Packer
1f7165afc4 fix: patch counting of tokens for anthropic (#6458)
* fix: patch counting of tokens for anthropic

* fix: patch ui to be simpler

* fix: patch undercounting bug in anthropic when caching is on
2025-12-15 12:02:19 -08:00
Charles Packer
88a3743cc8 fix(core): distinguish between null and 0 for prompt caching (#6451)
* fix(core): distinguish between null and 0 for prompt caching

* fix: runtime errors

* fix: just publish just sgate
2025-12-15 12:02:19 -08:00
Charles Packer
131891e05f feat: add tracking of advanced usage data (eg caching) [LET-6372] (#6449)
* feat: init refactor

* feat: add helper code

* fix: missing file + test

* fix: just state/publish api
2025-12-15 12:02:19 -08:00
cthomas
6fe0971bfa fix: unexpected kwarg llm config error (#6289) 2025-11-24 19:10:26 -08:00
Sarah Wooders
5b9cac08b6 fix: populate stop_reason [LET-6040] (#5955)
fix: populate stop_reason
2025-11-13 15:36:55 -08:00
Sarah Wooders
a566900533 chore: add back test_server.py (#5783) 2025-11-13 15:36:00 -08:00
cthomas
06d2cde43d fix: llm error interrupting stream for agent loop (#5696) 2025-10-24 15:14:20 -07:00
Kevin Lin
35b5383724 feat: match line number rendering to Anthropic / OAI defaults (#5492) 2025-10-24 15:13:15 -07:00
cthomas
73dcc0d4b7 feat: latest hitl + parallel tool call changes (#5565) 2025-10-24 15:12:49 -07:00
Matthew Zhou
fc950ecddf feat: Change execution pattern depending on enable_parallel_execution (#5550)
* Change execution pattern depending on

* Increase efficiency
2025-10-24 15:12:11 -07:00
cthomas
69b15d606c feat: support approval requests for parallel tool calls (#5538) 2025-10-24 15:12:11 -07:00
Ari Webb
e7ef73c0b6 Ari/let 5503 error during step processing error code 429 type error error [LET-5503] (#5421)
* letta agent v2 throw exception not error

* warning instead of error or exception

---------

Co-authored-by: Ari Webb <ari@letta.com>
2025-10-24 15:12:11 -07:00
Ari Webb
cf227bc400 letta agent v2 throw exception not error [LET-5503] (#5417)
letta agent v2 throw exception not error

Co-authored-by: Ari Webb <ari@letta.com>
2025-10-24 15:12:11 -07:00
Ari Webb
1d3e2d14d6 use LLMError instead of ValueError (#5389)
Co-authored-by: Ari Webb <ariwebb@Aris-MacBook-Pro.local>
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
1edb21a652 feat: add letta_agent_v1 flag for docker image and some patches (#5081)
* feat: add letta_agent_v1 flag for docker image and some patches

* update build
2025-10-09 15:25:21 -07:00
Matthew Zhou
20ce885e07 feat: Simplify create_letta_messages_from_llm_response [LET-4681] (#5204)
Simplify create_letta_messages_from_llm_response
2025-10-07 17:50:50 -07:00
cthomas
4089ad0629 fix: summarization bug (#5174) 2025-10-07 17:50:49 -07:00
cthomas
ec2375f332 feat: prevent summarization mid approval request (#5172) 2025-10-07 17:50:49 -07:00
Sarah Wooders
a8e6afc12c fix: allow for >50 files to be attached to an agent [LET-4606] (#5139) 2025-10-07 17:50:49 -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
cthomas
67f8e46619 feat: add run id to streamed messages (#5037) 2025-10-07 17:50:47 -07:00
Sarah Wooders
354205f581 feat: create new runs table [LET-4467] (#4841) 2025-10-07 17:50:47 -07:00
Charles Packer
a4041879a4 feat: add new agent loop (squash rebase of OSS PR) (#4815)
* feat: squash rebase of OSS PR

* fix: revert changes that weren't on manual rebase

* fix: caught another one

* fix: disable force

* chore: drop print

* fix: just stage-api && just publish-api

* fix: make agent_type consistently an arg in the client

* fix: patch multi-modal support

* chore: put in todo stub

* fix: disable hardcoding for tests

* fix: patch validate agent sync (#4882)

patch validate agent sync

* fix: strip bad merge diff

* fix: revert unrelated diff

* fix: react_v2 naming -> letta_v1 naming

* fix: strip bad merge

---------

Co-authored-by: Kevin Lin <klin5061@gmail.com>
2025-10-07 17:50:45 -07:00
Matthew Zhou
81bb131afb feat: Calculate remaining turns [LET-4453] (#4789)
Calculate remaining turns
2025-10-07 17:50:44 -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
Sarah Wooders
c85bfefa52 feat: add agents_runs table (#4768) 2025-10-07 17:50:44 -07:00
jnjpng
39a8959989 feat: _handle_ai_response activity skeleton (#4760)
* base

* skeleton

* TODO

* unpack

* unpack

* cleanup

* cleanup

* merge

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-10-07 17:50:43 -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
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
2281c52de3 feat: conditionally record step metrics (#4497) 2025-09-09 00:35:03 -07:00
cthomas
6cb12b7f66 feat: handle streaming for hitl in new agent loop (#4496) 2025-09-09 00:27:44 -07:00
cthomas
c60683c5a0 feat: add check before logging step metrics (#4495) 2025-09-09 00:02:21 -07:00
cthomas
efe34c9db3 fix: async generator return type (#4494) 2025-09-08 23:44:19 -07:00
cthomas
517e25ea2a fix: add llm adapter to build request method (#4493) 2025-09-08 23:38:59 -07:00
cthomas
f41f561a38 feat: always break when step is finished (#4492) 2025-09-08 23:37:36 -07:00