Commit Graph

38 Commits

Author SHA1 Message Date
cthomas
aeeec41859 feat: new agent id query param for default convo (#9756)
* feat: new agent id query param for default convo

* update stainless
2026-03-03 18:34:15 -08:00
Kevin Lin
23c94ec6d3 feat: add log probabilities from OpenAI-compatible servers and SGLang native endpoint (#9240)
* Add log probabilities support for RL training

This enables Letta server to request and return log probabilities from
OpenAI-compatible providers (including SGLang) for use in RL training.

Changes:
- LLMConfig: Add return_logprobs and top_logprobs fields
- OpenAIClient: Set logprobs in ChatCompletionRequest when enabled
- LettaLLMAdapter: Add logprobs field and extract from response
- LettaResponse: Add logprobs field to return log probs to client
- LettaRequest: Add return_logprobs/top_logprobs for per-request override
- LettaAgentV3: Store and pass logprobs through to response
- agents.py: Handle request-level logprobs override

Usage:
  response = client.agents.messages.create(
      agent_id=agent_id,
      messages=[...],
      return_logprobs=True,
      top_logprobs=5,
  )
  print(response.logprobs)  # Per-token log probabilities

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

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

* Add multi-turn token tracking for RL training via SGLang native endpoint

- Add TurnTokenData schema to track token IDs and logprobs per turn
- Add return_token_ids flag to LettaRequest and LLMConfig
- Create SGLangNativeClient for /generate endpoint (returns output_ids)
- Create SGLangNativeAdapter that uses native endpoint
- Modify LettaAgentV3 to accumulate turns across LLM calls
- Include turns in LettaResponse when return_token_ids=True

* Fix: Add SGLang native adapter to step() method, not just stream()

* Fix: Handle Pydantic Message objects in SGLang native adapter

* Fix: Remove api_key reference from LLMConfig (not present)

* Fix: Add missing 'created' field to ChatCompletionResponse

* Add full tool support to SGLang native adapter

- Format tools into prompt in Qwen-style format
- Parse tool calls from <tool_call> tags in response
- Format tool results as <tool_response> in user messages
- Set finish_reason to 'tool_calls' when tools are called

* Use tokenizer.apply_chat_template for proper tool formatting

- Add tokenizer caching in SGLang native adapter
- Use apply_chat_template when tokenizer available
- Fall back to manual formatting if not
- Convert Letta messages to OpenAI format for tokenizer

* Fix: Use func_response instead of tool_return for ToolReturn content

* Fix: Get output_token_logprobs from meta_info in SGLang response

* Fix: Allow None in output_token_logprobs (SGLang format includes null)

* chore: remove unrelated files from logprobs branch

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

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

* fix: add missing call_type param to adapter constructors in letta_agent_v3

The SGLang refactor dropped call_type=LLMCallType.agent_step when extracting
adapter creation into conditional blocks. Restores it for all 3 spots (SGLang
in step, SimpleLLM in step, SGLang in stream).

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

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

* just stage-api && just publish-api

* fix: update expected LLMConfig fields in schema test for logprobs support

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

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

* chore: remove rllm provider references

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

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

* just stage-api && just publish-api

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

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

---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-65-206.ec2.internal>
Co-authored-by: Letta <noreply@letta.com>
2026-02-24 10:52:07 -08:00
jnjpng
d28ccc0be6 feat: add summary message and event on compaction (#9144)
* base

* update

* update

* revert formatting

* routes

* legacy

* fix

* review

* update
2026-02-24 10:52:05 -08:00
Kian Jones
45c0a4cd0d feat: add ID format validation to batch request schema (#9154)
* feat: add ID format validation to batch request schema

Add ID format validation to LettaBatchRequest using existing validator
types from letta.validators.

Changes:
- LettaBatchRequest.agent_id: str → AgentId

This ensures malformed agent IDs in batch requests are rejected with 422
validation errors instead of causing 500 database errors.

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

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

* chore: regenerate API spec and SDK

---------

Co-authored-by: Letta <noreply@letta.com>
2026-01-29 12:44:04 -08:00
github-actions[bot]
194c743223 refactor: rename stream to streaming in ConversationMessageRequest (#9063) 2026-01-29 12:44:04 -08:00
Sarah Wooders
6c415b27f8 feat: add non-streaming option for conversation messages (#9044)
* feat: add non-streaming option for conversation messages

- Add ConversationMessageRequest with stream=True default (backwards compatible)
- stream=true (default): SSE streaming via StreamingService
- stream=false: JSON response via AgentLoop.load().step()

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

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

* chore: regenerate API schema for ConversationMessageRequest

---------

Co-authored-by: Letta <noreply@letta.com>
2026-01-29 12:44:04 -08:00
Ari Webb
193c0e4b74 feat: add override_model to message endpoints (#8763)
* feat: add override_model to message endpoints

* add tests back

* remove from ci
2026-01-19 15:54:42 -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
edbff34d63 feat: enable streaming flag on send message [LET-6100] (#6040)
* base

* base

* update

* stainless

* final

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-11-13 15:36:55 -08:00
jnjpng
e2774c07c6 feat: generate otid when using input field on message send (#5990)
* base

* try this out

* plz

* fix

---------

Co-authored-by: Letta Bot <noreply@letta.com>
2025-11-13 15:36:55 -08:00
Ari Webb
ed99d7eb2b feat: add input option to send message route [LET-4540] (#5938)
---------

Co-authored-by: Ari Webb <ari@letta.com>
2025-11-13 15:36:50 -08:00
cthomas
6c27d8a1ec feat: mark use_assistant_message, etc as deprecated [LET-4556] (#5598)
feat: mark use_assistant_message, etc as deprecated
2025-10-24 15:13:15 -07:00
cthomas
ab8b19df1c feat: make include pings default to true (#4438) 2025-09-05 12:14:28 -07:00
cthomas
697be58b78 feat: make new message create type field optional [LET-4116] (#4319)
feat: make new message create type field optional
2025-08-29 15:22:34 -07:00
cthomas
bfdb586f74 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
04767aa4fe feat: remove stream_steps reference from api docs [LET-4109] (#4308)
feat: remove stream_steps reference from api docs
2025-08-29 11:20:32 -07:00
cthomas
6ca388557f feat: add new client.runs.stream endpoint (#4165) 2025-08-25 13:42:22 -07:00
cthomas
03cf5f43ea feat: add background flag to streaming api (#4148) 2025-08-24 20:45:35 -07:00
Charles Packer
a13c6c78bb feat: move keepalive to an arg (#3652) 2025-07-30 16:49:45 -07:00
Matthew Zhou
84ea52172a feat: Add ability to disable reasoning (#3594) 2025-07-28 15:30:10 -07:00
cthomas
a332b34830 feat: make create_async route consistent with other message routes (#2877) 2025-06-19 13:51:51 -07:00
cthomas
883050e761 feat: set request heartbeat for max steps (#2739) 2025-06-10 15:26:07 -07:00
Shangyin Tan
f9b6efa632 feat: add max_steps as argument to messages.create (#2664)
Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
2025-06-09 16:54:48 -07:00
Sarah Wooders
953ed5a610 feat: add include_return_message_types to LettaRequest to filter down requests (#2666) 2025-06-06 15:48:27 -07:00
Matthew Zhou
ba5897545b chore: Update description of callback url (#1985) 2025-05-02 11:15:05 -07:00
Matthew Zhou
15fefe0e1a feat: Add callback for jobs (#1776)
Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
2025-04-18 10:48:04 -07:00
Sarah Wooders
41d85c4114 feat: add batch job tracking and generate batch APIs (#1727)
Co-authored-by: Matt Zhou <mattzh1314@gmail.com>
2025-04-17 17:02:07 -07:00
Matthew Zhou
68fbcf33d8 feat: Finish step_until_request in new batch agent loop (#1656) 2025-04-10 10:19:06 -07:00
cthomas
5a71a2c346 chore: remove nested config in send requests (#813) 2025-01-28 14:58:53 -08:00
mlong93
e4700fdfe1 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
Sarah Wooders
096791aae1 feat: parse assistant message to AssistantMessage by default (#528) 2025-01-08 15:00:32 -08:00
Caren Thomas
7144fd2867 run black, add isort config to pyproject.toml 2024-12-26 19:43:11 -08:00
Shubham Naik
4cf354c033 fix: add tests to cypress 2024-12-23 14:44:08 -08:00
Sarah Wooders
fae2d06755 feat: modify REST API schemas (#2121) 2024-12-10 16:10:34 -08:00
Matthew Zhou
5a59d2ac42 feat: Separate out streaming route (#2111) 2024-11-27 14:03:46 -08:00
Charles Packer
f408436669 feat: refactor the POST agent/messages API to take multiple messages (#1882) 2024-10-14 13:29:07 -07:00
Charles Packer
b17246a3b0 feat: add back support for using AssistantMessage subtype of LettaMessage (#1812) 2024-10-04 15:36:33 -07:00
Sarah Wooders
8ae1e64987 chore: migrate package name to letta (#1775)
Co-authored-by: Charles Packer <packercharles@gmail.com>
Co-authored-by: Shubham Naik <shubham.naik10@gmail.com>
Co-authored-by: Shubham Naik <shub@memgpt.ai>
2024-09-23 09:15:18 -07:00