Commit Graph

60 Commits

Author SHA1 Message Date
cthomas
54369a7c12 fix: add billing_context to SleeptimeMultiAgent V3/V4 stream methods (#9753)
fix: add billing_context to SleeptimeMultiAgent V3 and V4 stream methods

Missed these stream methods when adding billing_context parameter.
V3 and V4 stream() methods now accept and pass billing_context to super().stream().
2026-03-03 18:34:15 -08:00
cthomas
416ffc7cd7 Add billing context to LLM telemetry traces (#9745)
* feat: add billing context to LLM telemetry traces

Add billing metadata (plan type, cost source, customer ID) to LLM traces in ClickHouse for cost analytics and attribution.

**Data Flow:**
- Cloud-API: Extract billing info from subscription in rate limiting, set x-billing-* headers
- Core: Parse headers into BillingContext object via dependencies
- Adapters: Flow billing_context through all LLM adapters (blocking & streaming)
- Agent: Pass billing_context to step() and stream() methods
- ClickHouse: Store in billing_plan_type, billing_cost_source, billing_customer_id columns

**Changes:**
- Add BillingContext schema to provider_trace.py
- Add billing columns to llm_traces ClickHouse table DDL
- Update getCustomerSubscription to fetch stripeCustomerId from organization_billing_details
- Propagate billing_context through agent step flow, adapters, and streaming service
- Update ProviderTrace and LLMTrace to include billing metadata
- Regenerate SDK with autogen

**Production Deployment:**
Requires env vars: LETTA_PROVIDER_TRACE_BACKEND=clickhouse, LETTA_STORE_LLM_TRACES=true, CLICKHOUSE_*

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

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

* fix: add billing_context parameter to agent step methods

- Add billing_context to BaseAgent and BaseAgentV2 abstract methods
- Update LettaAgent, LettaAgentV2, LettaAgentV3 step methods
- Update multi-agent groups: SleeptimeMultiAgentV2, V3, V4
- Fix test_utils.py to include billing header parameters
- Import BillingContext in all affected files

* fix: add billing_context to stream methods

- Add billing_context parameter to BaseAgentV2.stream()
- Add billing_context parameter to LettaAgentV2.stream()
- LettaAgentV3.stream() already has it from previous commit

* fix: exclude billing headers from OpenAPI spec

Mark billing headers as internal (include_in_schema=False) so they don't appear in the public API.
These are internal headers between cloud-api and core, not part of the public SDK.

Regenerated SDK with stage-api - removes 10,650 lines of bloat that was causing OOM during Next.js build.

* refactor: return billing context from handleUnifiedRateLimiting instead of mutating req

Instead of passing req into handleUnifiedRateLimiting and mutating headers inside it:
- Return billing context fields (billingPlanType, billingCostSource, billingCustomerId) from handleUnifiedRateLimiting
- Set headers in handleMessageRateLimiting (middleware layer) after getting the result
- This fixes step-orchestrator compatibility since it doesn't have a real Express req object

* chore: remove extra gencode

* p

---------

Co-authored-by: Letta <noreply@letta.com>
2026-03-03 18:34:13 -08:00
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
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
Sarah Wooders
4e1473c6dc fix: patch sleeptime agent (#8315) 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
Sarah Wooders
c5c633285b fix: pass in stop_reason for sleeptime loop (#8086) 2026-01-12 10:57:47 -08:00
cthomas
82de08be42 fix: agent not defined more callsites (#7219) 2025-12-17 17:31:02 -08:00
cthomas
6a2e61c3fa fix: agent not defined error (#7212) 2025-12-17 17:31:02 -08:00
Cameron
8c616a2093 fix: add context prompt to sleeptime agent user message (#6564)
* fix: add context prompt to sleeptime agent user message

Previously the sleeptime agent received only the raw conversation
transcript with no context, causing identity confusion where the
agent would believe it was the primary agent.

Now includes a pre-prompt that:
- Uses "sleeptime agent" terminology explicitly
- Clarifies the agent is NOT the primary agent
- Explains message labels (assistant = primary agent)
- States the agent has no prior turns in the transcript
- Describes the memory management role

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

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

* chore: remove redundant sleeptime pre-prompt line

* chore: add memory_persona reference to sleeptime pre-prompt

* chore: wrap sleeptime pre-prompt in system-reminder tags

* chore: rename transcript to messages in sleeptime pre-prompt

---------

Co-authored-by: Letta <noreply@letta.com>
2025-12-15 12:02:34 -08:00
cthomas
864415532e fix: list index error for sleeptime due to summarization failure (#6525)
fix: list index error for sleeptime
2025-12-15 12:02:33 -08:00
Kian Jones
dc331c0f61 fix: handle step streaming for sleeptime agent (#6014)
handle step streaming for sleeptime agent
2025-11-13 15:36:55 -08:00
Charles Packer
e8e94f2ebe fix(core): patch bugs on transcript formatting for sleeptime w/ HITL (#6025) 2025-11-13 15:36:55 -08:00
Ari Webb
162661457a fix: sleeptime agents are broken [LET-6042] (#5953)
minimal solution
2025-11-13 15:36:55 -08:00
Sarah Wooders
29c4ed20eb fix: patch sleeptime integration test (#5845) 2025-11-13 15:36:14 -08:00
cthomas
9118a7c236 fix: assistant msg not getting processed by sleeptime on letta v1 (#5751)
fix: assistant messages not getting processed by sleeptime agents on letta v1
2025-11-13 15:35:34 -08:00
cthomas
cd2fb0cd02 feat: add new internal capture endpoint (#5750) 2025-11-13 15:35:34 -08:00
cthomas
cd4553f3e6 feat: enable sleeptime on new agent loop (#5405) 2025-10-24 15:11:31 -07:00
cthomas
6e4caae15c feat: move existing sleeptime agents to new agent loop (#5398) 2025-10-24 15:11:31 -07:00
Sarah Wooders
354205f581 feat: create new runs table [LET-4467] (#4841) 2025-10-07 17:50:47 -07: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
cthomas
48b5722095 fix: missing actor in sleeptime loop (#4498) 2025-09-09 00:43:04 -07:00
cthomas
f00453c152 feat: migrate sleeptime to new agent loop (#4485)
* feat: migrate sleeptime to new agent loop

* only load agent state when needed
2025-09-08 22:25:01 -07:00
cthomas
b4810633af chore: deprecate orm enum file (#3724) 2025-08-04 11:59:55 -07:00
Andy Li
58081e3cea feat: support for providers 2025-07-22 16:09:50 -07:00
Andy Li
04e9f43220 chore: strings lint cleanup (#3374) 2025-07-18 09:20:45 -07:00
cthomas
87e69a4808 fix: handle image content for sleeptime (#3142) 2025-07-02 16:11:43 -07:00
Andy Li
33c1f26ab6 feat: support for agent loop job cancelation (#2837) 2025-07-02 14:31:16 -07:00
Andy Li
98a79afbdd fix: bugfixes (and bump) (#3071) 2025-06-27 14:23:42 -07:00
cthomas
99e112e486 feat: make create_async route consistent with other message routes (#2877) 2025-06-19 13:51:51 -07:00
cthomas
605a1f410c feat: consolidate logic for finish tokens (#2779) 2025-06-12 15:24:06 -07:00
cthomas
a855532e4b feat: set request heartbeat for max steps (#2739) 2025-06-10 15:26:07 -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
Andy Li
d2252f2953 feat: otel metrics and expanded collecting (#2647)
(passed tests in last run)
2025-06-05 17:20:14 -07:00
Andy Li
3f28a5c8df fix: SleeptimeMultiAgentV2.step() unexpected arg (#2599) 2025-06-03 13:21:22 -07:00
Kian Jones
ad3503f0ee fix: typo in conditional checking is not "None" instead of != "None" (#2589) 2025-06-03 13:18:28 -07:00
Sarah Wooders
268285c688 fix: pass in argument to sleeptime (#2566) 2025-06-01 13:55:23 -07:00
Matthew Zhou
87f4bcad9a feat: Add summarization for more scenarios (#2499) 2025-05-29 11:10:13 -07:00
Andy Li
275b75901d chore: cleanup (#2480) 2025-05-29 10:40:41 -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
cthomas
2bdeeccc41 feat: add step stream to async sleeptime agent (#2379) 2025-05-23 14:38:25 -07:00
cthomas
db520f9a22 feat: add sleeptime to new agent loop (#2263) 2025-05-22 23:22:51 -07:00
cthomas
1325cacbfe feat(asyncify): migrate list messages (#2272) 2025-05-20 16:52:11 -07:00
cthomas
3644a17426 fix: unset timezone for async db (#2220) 2025-05-16 13:11:15 -07:00
cthomas
a6286b6307 fix: sleeptime mcp bug (#2178) 2025-05-14 12:08:44 -07:00
cthomas
2889d2f2d5 feat: add mcp support to sleeptime (#1964) 2025-04-30 21:08:26 -07:00
cthomas
d4f9fd3cd2 feat: add sleeptime to new agent loop (#1900) 2025-04-26 10:23:59 -07:00