letta-client 0.1.232__py3-none-any.whl → 0.1.234__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of letta-client might be problematic. Click here for more details.

Files changed (440) hide show
  1. letta_client/__init__.py +4 -0
  2. letta_client/agents/__init__.py +2 -0
  3. letta_client/agents/blocks/__init__.py +2 -0
  4. letta_client/agents/blocks/client.py +72 -313
  5. letta_client/agents/blocks/raw_client.py +654 -0
  6. letta_client/agents/client.py +329 -869
  7. letta_client/agents/context/__init__.py +2 -0
  8. letta_client/agents/context/client.py +31 -66
  9. letta_client/agents/context/raw_client.py +122 -0
  10. letta_client/agents/core_memory/__init__.py +2 -0
  11. letta_client/agents/core_memory/client.py +31 -66
  12. letta_client/agents/core_memory/raw_client.py +124 -0
  13. letta_client/agents/files/__init__.py +2 -0
  14. letta_client/agents/files/client.py +39 -178
  15. letta_client/agents/files/raw_client.py +349 -0
  16. letta_client/agents/folders/__init__.py +2 -0
  17. letta_client/agents/folders/client.py +39 -178
  18. letta_client/agents/folders/raw_client.py +327 -0
  19. letta_client/agents/groups/__init__.py +2 -0
  20. letta_client/agents/groups/client.py +31 -72
  21. letta_client/agents/groups/raw_client.py +142 -0
  22. letta_client/agents/memory_variables/__init__.py +2 -0
  23. letta_client/agents/memory_variables/client.py +31 -65
  24. letta_client/agents/memory_variables/raw_client.py +125 -0
  25. letta_client/agents/memory_variables/types/__init__.py +2 -0
  26. letta_client/agents/memory_variables/types/memory_variables_list_response.py +3 -2
  27. letta_client/agents/messages/__init__.py +2 -0
  28. letta_client/agents/messages/client.py +150 -589
  29. letta_client/agents/messages/raw_client.py +1384 -0
  30. letta_client/agents/messages/types/__init__.py +2 -0
  31. letta_client/agents/messages/types/letta_streaming_response.py +6 -5
  32. letta_client/agents/messages/types/messages_modify_request.py +3 -2
  33. letta_client/agents/messages/types/messages_modify_response.py +5 -4
  34. letta_client/agents/messages/types/messages_preview_raw_payload_request.py +1 -0
  35. letta_client/agents/passages/__init__.py +2 -0
  36. letta_client/agents/passages/client.py +89 -301
  37. letta_client/agents/passages/raw_client.py +678 -0
  38. letta_client/agents/raw_client.py +2068 -0
  39. letta_client/agents/sources/__init__.py +2 -0
  40. letta_client/agents/sources/client.py +39 -178
  41. letta_client/agents/sources/raw_client.py +327 -0
  42. letta_client/agents/templates/__init__.py +2 -0
  43. letta_client/agents/templates/client.py +57 -276
  44. letta_client/agents/templates/raw_client.py +505 -0
  45. letta_client/agents/templates/types/__init__.py +2 -0
  46. letta_client/agents/templates/types/templates_create_response.py +5 -4
  47. letta_client/agents/templates/types/templates_migrate_response.py +3 -2
  48. letta_client/agents/tools/__init__.py +2 -0
  49. letta_client/agents/tools/client.py +40 -179
  50. letta_client/agents/tools/raw_client.py +327 -0
  51. letta_client/agents/types/__init__.py +2 -0
  52. letta_client/agents/types/agents_search_request_search_item.py +4 -3
  53. letta_client/agents/types/agents_search_request_search_item_field.py +4 -3
  54. letta_client/agents/types/agents_search_request_search_item_one.py +4 -3
  55. letta_client/agents/types/agents_search_request_search_item_three.py +3 -2
  56. letta_client/agents/types/agents_search_request_search_item_two.py +3 -2
  57. letta_client/agents/types/agents_search_request_search_item_zero.py +3 -2
  58. letta_client/agents/types/agents_search_response.py +5 -4
  59. letta_client/agents/types/create_agent_request_response_format.py +1 -0
  60. letta_client/agents/types/create_agent_request_tool_rules_item.py +4 -3
  61. letta_client/agents/types/update_agent_response_format.py +1 -0
  62. letta_client/agents/types/update_agent_tool_rules_item.py +4 -3
  63. letta_client/base_client.py +41 -49
  64. letta_client/batches/__init__.py +2 -0
  65. letta_client/batches/client.py +45 -253
  66. letta_client/batches/raw_client.py +457 -0
  67. letta_client/blocks/__init__.py +2 -0
  68. letta_client/blocks/agents/__init__.py +2 -0
  69. letta_client/blocks/agents/client.py +33 -70
  70. letta_client/blocks/agents/raw_client.py +144 -0
  71. letta_client/blocks/client.py +126 -424
  72. letta_client/blocks/raw_client.py +973 -0
  73. letta_client/client_side_access_tokens/__init__.py +2 -0
  74. letta_client/client_side_access_tokens/client.py +45 -216
  75. letta_client/client_side_access_tokens/raw_client.py +435 -0
  76. letta_client/client_side_access_tokens/types/__init__.py +2 -0
  77. letta_client/client_side_access_tokens/types/client_side_access_tokens_create_request_policy_item.py +4 -3
  78. letta_client/client_side_access_tokens/types/client_side_access_tokens_create_response.py +6 -5
  79. letta_client/client_side_access_tokens/types/client_side_access_tokens_create_response_policy.py +4 -3
  80. letta_client/client_side_access_tokens/types/client_side_access_tokens_create_response_policy_data_item.py +4 -3
  81. letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response.py +6 -5
  82. letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response_tokens_item.py +6 -5
  83. letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response_tokens_item_policy.py +4 -3
  84. letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response_tokens_item_policy_data_item.py +4 -3
  85. letta_client/core/__init__.py +5 -0
  86. letta_client/core/api_error.py +13 -5
  87. letta_client/core/client_wrapper.py +14 -5
  88. letta_client/core/force_multipart.py +16 -0
  89. letta_client/core/http_client.py +70 -26
  90. letta_client/core/http_response.py +55 -0
  91. letta_client/core/jsonable_encoder.py +0 -1
  92. letta_client/core/pydantic_utilities.py +70 -111
  93. letta_client/core/serialization.py +7 -3
  94. letta_client/core/unchecked_base_model.py +40 -4
  95. letta_client/embedding_models/__init__.py +2 -0
  96. letta_client/embedding_models/client.py +31 -65
  97. letta_client/embedding_models/raw_client.py +117 -0
  98. letta_client/errors/__init__.py +2 -0
  99. letta_client/errors/bad_request_error.py +4 -3
  100. letta_client/errors/conflict_error.py +4 -2
  101. letta_client/errors/internal_server_error.py +4 -3
  102. letta_client/errors/not_found_error.py +4 -3
  103. letta_client/errors/payment_required_error.py +4 -2
  104. letta_client/errors/unprocessable_entity_error.py +4 -2
  105. letta_client/folders/__init__.py +2 -0
  106. letta_client/folders/client.py +100 -564
  107. letta_client/folders/files/__init__.py +2 -0
  108. letta_client/folders/files/client.py +44 -189
  109. letta_client/folders/files/raw_client.py +391 -0
  110. letta_client/folders/passages/__init__.py +2 -0
  111. letta_client/folders/passages/client.py +33 -74
  112. letta_client/folders/passages/raw_client.py +162 -0
  113. letta_client/folders/raw_client.py +1084 -0
  114. letta_client/groups/__init__.py +2 -0
  115. letta_client/groups/client.py +87 -406
  116. letta_client/groups/messages/__init__.py +2 -0
  117. letta_client/groups/messages/client.py +110 -371
  118. letta_client/groups/messages/raw_client.py +881 -0
  119. letta_client/groups/messages/types/__init__.py +2 -0
  120. letta_client/groups/messages/types/letta_streaming_response.py +5 -4
  121. letta_client/groups/messages/types/messages_modify_request.py +3 -2
  122. letta_client/groups/messages/types/messages_modify_response.py +5 -4
  123. letta_client/groups/raw_client.py +807 -0
  124. letta_client/groups/types/__init__.py +2 -0
  125. letta_client/groups/types/group_create_manager_config.py +1 -0
  126. letta_client/groups/types/group_update_manager_config.py +1 -0
  127. letta_client/health/__init__.py +2 -0
  128. letta_client/health/client.py +31 -43
  129. letta_client/health/raw_client.py +85 -0
  130. letta_client/identities/__init__.py +2 -0
  131. letta_client/identities/client.py +115 -498
  132. letta_client/identities/properties/__init__.py +2 -0
  133. letta_client/identities/properties/client.py +32 -76
  134. letta_client/identities/properties/raw_client.py +152 -0
  135. letta_client/identities/raw_client.py +1010 -0
  136. letta_client/jobs/__init__.py +2 -0
  137. letta_client/jobs/client.py +67 -310
  138. letta_client/jobs/raw_client.py +624 -0
  139. letta_client/messages/__init__.py +2 -0
  140. letta_client/messages/client.py +41 -74
  141. letta_client/messages/raw_client.py +186 -0
  142. letta_client/models/__init__.py +2 -0
  143. letta_client/models/client.py +39 -73
  144. letta_client/models/raw_client.py +151 -0
  145. letta_client/projects/__init__.py +2 -0
  146. letta_client/projects/client.py +31 -53
  147. letta_client/projects/raw_client.py +125 -0
  148. letta_client/projects/types/__init__.py +2 -0
  149. letta_client/projects/types/projects_list_response.py +5 -4
  150. letta_client/projects/types/projects_list_response_projects_item.py +3 -2
  151. letta_client/providers/__init__.py +2 -0
  152. letta_client/providers/client.py +62 -335
  153. letta_client/providers/raw_client.py +664 -0
  154. letta_client/runs/__init__.py +2 -0
  155. letta_client/runs/client.py +56 -258
  156. letta_client/runs/messages/__init__.py +2 -0
  157. letta_client/runs/messages/client.py +34 -79
  158. letta_client/runs/messages/raw_client.py +209 -0
  159. letta_client/runs/raw_client.py +440 -0
  160. letta_client/runs/steps/__init__.py +2 -0
  161. letta_client/runs/steps/client.py +33 -76
  162. letta_client/runs/steps/raw_client.py +192 -0
  163. letta_client/runs/usage/__init__.py +2 -0
  164. letta_client/runs/usage/client.py +31 -66
  165. letta_client/runs/usage/raw_client.py +122 -0
  166. letta_client/sources/__init__.py +2 -0
  167. letta_client/sources/client.py +107 -625
  168. letta_client/sources/files/__init__.py +2 -0
  169. letta_client/sources/files/client.py +44 -189
  170. letta_client/sources/files/raw_client.py +391 -0
  171. letta_client/sources/passages/__init__.py +2 -0
  172. letta_client/sources/passages/client.py +33 -74
  173. letta_client/sources/passages/raw_client.py +162 -0
  174. letta_client/sources/raw_client.py +1209 -0
  175. letta_client/steps/__init__.py +2 -0
  176. letta_client/steps/client.py +65 -153
  177. letta_client/steps/feedback/__init__.py +2 -0
  178. letta_client/steps/feedback/client.py +32 -73
  179. letta_client/steps/feedback/raw_client.py +141 -0
  180. letta_client/steps/raw_client.py +355 -0
  181. letta_client/steps/types/__init__.py +2 -0
  182. letta_client/tags/__init__.py +2 -0
  183. letta_client/tags/client.py +33 -73
  184. letta_client/tags/raw_client.py +148 -0
  185. letta_client/telemetry/__init__.py +2 -0
  186. letta_client/telemetry/client.py +31 -66
  187. letta_client/telemetry/raw_client.py +118 -0
  188. letta_client/templates/__init__.py +2 -0
  189. letta_client/templates/agents/__init__.py +2 -0
  190. letta_client/templates/agents/client.py +48 -96
  191. letta_client/templates/agents/raw_client.py +227 -0
  192. letta_client/templates/agents/types/__init__.py +2 -0
  193. letta_client/templates/agents/types/agents_create_request_initial_message_sequence_item.py +4 -3
  194. letta_client/templates/agents/types/agents_create_response.py +4 -3
  195. letta_client/templates/client.py +36 -57
  196. letta_client/templates/raw_client.py +133 -0
  197. letta_client/templates/types/__init__.py +2 -0
  198. letta_client/templates/types/templates_list_response.py +5 -4
  199. letta_client/templates/types/templates_list_response_templates_item.py +3 -2
  200. letta_client/tools/__init__.py +2 -0
  201. letta_client/tools/client.py +195 -1322
  202. letta_client/tools/raw_client.py +2565 -0
  203. letta_client/tools/types/__init__.py +2 -0
  204. letta_client/tools/types/add_mcp_server_request.py +2 -1
  205. letta_client/tools/types/add_mcp_server_response_item.py +2 -1
  206. letta_client/tools/types/connect_mcp_server_request.py +2 -1
  207. letta_client/tools/types/delete_mcp_server_response_item.py +2 -1
  208. letta_client/tools/types/list_mcp_servers_response_value.py +1 -0
  209. letta_client/tools/types/streaming_response.py +5 -4
  210. letta_client/tools/types/test_mcp_server_request.py +2 -1
  211. letta_client/tools/types/update_mcp_server_request.py +2 -1
  212. letta_client/tools/types/update_mcp_server_response.py +2 -1
  213. letta_client/types/__init__.py +4 -0
  214. letta_client/types/action_model.py +6 -5
  215. letta_client/types/action_parameters_model.py +3 -2
  216. letta_client/types/action_response_model.py +3 -2
  217. letta_client/types/agent_environment_variable.py +3 -2
  218. letta_client/types/agent_schema.py +7 -6
  219. letta_client/types/agent_schema_tool_rules_item.py +2 -1
  220. letta_client/types/agent_state.py +9 -8
  221. letta_client/types/agent_state_response_format.py +1 -0
  222. letta_client/types/agent_state_tool_rules_item.py +4 -3
  223. letta_client/types/app_auth_scheme.py +4 -3
  224. letta_client/types/app_model.py +5 -4
  225. letta_client/types/assistant_message.py +3 -2
  226. letta_client/types/assistant_message_content.py +1 -0
  227. letta_client/types/audio.py +3 -2
  228. letta_client/types/auth_request.py +2 -1
  229. letta_client/types/auth_response.py +5 -4
  230. letta_client/types/auth_scheme_field.py +3 -2
  231. letta_client/types/bad_request_error_body.py +3 -2
  232. letta_client/types/base_64_image.py +2 -1
  233. letta_client/types/base_tool_rule_schema.py +3 -2
  234. letta_client/types/batch_job.py +4 -3
  235. letta_client/types/block.py +3 -2
  236. letta_client/types/block_update.py +2 -1
  237. letta_client/types/chat_completion_assistant_message_param.py +5 -4
  238. letta_client/types/chat_completion_assistant_message_param_content.py +1 -0
  239. letta_client/types/chat_completion_assistant_message_param_content_item.py +2 -1
  240. letta_client/types/chat_completion_audio_param.py +4 -3
  241. letta_client/types/chat_completion_content_part_image_param.py +4 -3
  242. letta_client/types/chat_completion_content_part_input_audio_param.py +4 -3
  243. letta_client/types/chat_completion_content_part_refusal_param.py +3 -2
  244. letta_client/types/chat_completion_content_part_text_param.py +3 -2
  245. letta_client/types/chat_completion_developer_message_param.py +4 -3
  246. letta_client/types/chat_completion_developer_message_param_content.py +1 -0
  247. letta_client/types/chat_completion_function_call_option_param.py +3 -2
  248. letta_client/types/chat_completion_function_message_param.py +3 -2
  249. letta_client/types/chat_completion_message_tool_call.py +4 -3
  250. letta_client/types/chat_completion_message_tool_call_param.py +4 -3
  251. letta_client/types/chat_completion_named_tool_choice_param.py +4 -3
  252. letta_client/types/chat_completion_prediction_content_param.py +4 -3
  253. letta_client/types/chat_completion_prediction_content_param_content.py +1 -0
  254. letta_client/types/chat_completion_stream_options_param.py +3 -2
  255. letta_client/types/chat_completion_system_message_param.py +4 -3
  256. letta_client/types/chat_completion_system_message_param_content.py +1 -0
  257. letta_client/types/chat_completion_tool_message_param.py +4 -3
  258. letta_client/types/chat_completion_tool_message_param_content.py +1 -0
  259. letta_client/types/chat_completion_tool_param.py +4 -3
  260. letta_client/types/chat_completion_user_message_param.py +4 -3
  261. letta_client/types/chat_completion_user_message_param_content.py +1 -0
  262. letta_client/types/chat_completion_user_message_param_content_item.py +2 -1
  263. letta_client/types/child_tool_rule.py +3 -2
  264. letta_client/types/child_tool_rule_schema.py +3 -2
  265. letta_client/types/code_input.py +3 -2
  266. letta_client/types/completion_create_params_non_streaming.py +10 -9
  267. letta_client/types/completion_create_params_non_streaming_function_call.py +1 -0
  268. letta_client/types/completion_create_params_non_streaming_messages_item.py +4 -3
  269. letta_client/types/completion_create_params_non_streaming_response_format.py +3 -2
  270. letta_client/types/completion_create_params_non_streaming_tool_choice.py +1 -0
  271. letta_client/types/completion_create_params_streaming.py +10 -9
  272. letta_client/types/completion_create_params_streaming_function_call.py +1 -0
  273. letta_client/types/completion_create_params_streaming_messages_item.py +4 -3
  274. letta_client/types/completion_create_params_streaming_response_format.py +3 -2
  275. letta_client/types/completion_create_params_streaming_tool_choice.py +1 -0
  276. letta_client/types/conditional_tool_rule.py +3 -2
  277. letta_client/types/conditional_tool_rule_schema.py +3 -2
  278. letta_client/types/conflict_error_body.py +3 -2
  279. letta_client/types/context_window_overview.py +4 -3
  280. letta_client/types/continue_tool_rule.py +3 -2
  281. letta_client/types/core_memory_block_schema.py +4 -3
  282. letta_client/types/create_block.py +3 -2
  283. letta_client/types/dynamic_manager.py +2 -1
  284. letta_client/types/dynamic_manager_update.py +2 -1
  285. letta_client/types/e_2_b_sandbox_config.py +2 -1
  286. letta_client/types/embedding_config.py +4 -3
  287. letta_client/types/file.py +4 -3
  288. letta_client/types/file_block.py +4 -3
  289. letta_client/types/file_file.py +3 -2
  290. letta_client/types/file_metadata.py +5 -4
  291. letta_client/types/file_stats.py +3 -2
  292. letta_client/types/folder.py +5 -4
  293. letta_client/types/function_call.py +3 -2
  294. letta_client/types/function_definition_input.py +3 -2
  295. letta_client/types/function_definition_output.py +3 -2
  296. letta_client/types/function_output.py +3 -2
  297. letta_client/types/function_tool.py +4 -3
  298. letta_client/types/generate_tool_input.py +3 -2
  299. letta_client/types/generate_tool_output.py +4 -3
  300. letta_client/types/group.py +4 -3
  301. letta_client/types/health.py +3 -2
  302. letta_client/types/hidden_reasoning_message.py +4 -3
  303. letta_client/types/http_validation_error.py +4 -3
  304. letta_client/types/identity.py +4 -3
  305. letta_client/types/identity_property.py +5 -4
  306. letta_client/types/image_content.py +3 -2
  307. letta_client/types/image_content_source.py +1 -0
  308. letta_client/types/image_url.py +4 -3
  309. letta_client/types/init_tool_rule.py +3 -2
  310. letta_client/types/input_audio.py +4 -3
  311. letta_client/types/internal_server_error_body.py +3 -2
  312. letta_client/types/job.py +4 -3
  313. letta_client/types/json_object_response_format.py +3 -2
  314. letta_client/types/json_schema.py +4 -3
  315. letta_client/types/json_schema_response_format.py +2 -1
  316. letta_client/types/letta_batch_messages.py +4 -3
  317. letta_client/types/letta_batch_request.py +4 -3
  318. letta_client/types/letta_image.py +2 -1
  319. letta_client/types/letta_message_content_union.py +4 -3
  320. letta_client/types/letta_message_union.py +5 -4
  321. letta_client/types/letta_ping.py +2 -1
  322. letta_client/types/letta_request.py +4 -3
  323. letta_client/types/letta_request_config.py +3 -2
  324. letta_client/types/letta_response.py +4 -3
  325. letta_client/types/letta_stop_reason.py +3 -2
  326. letta_client/types/letta_streaming_request.py +9 -3
  327. letta_client/types/letta_usage_statistics.py +3 -2
  328. letta_client/types/letta_user_message_content_union.py +2 -1
  329. letta_client/types/llm_config.py +6 -5
  330. letta_client/types/local_sandbox_config.py +3 -2
  331. letta_client/types/max_count_per_step_tool_rule.py +3 -2
  332. letta_client/types/max_count_per_step_tool_rule_schema.py +3 -2
  333. letta_client/types/mcp_tool.py +4 -3
  334. letta_client/types/memory.py +4 -3
  335. letta_client/types/message.py +6 -5
  336. letta_client/types/message_content_item.py +1 -0
  337. letta_client/types/message_create.py +5 -4
  338. letta_client/types/message_create_content.py +1 -0
  339. letta_client/types/message_schema.py +4 -3
  340. letta_client/types/modal_sandbox_config.py +28 -0
  341. letta_client/types/not_found_error_body.py +3 -2
  342. letta_client/types/omitted_reasoning_content.py +3 -2
  343. letta_client/types/openai_types_chat_chat_completion_message_tool_call_param_function.py +3 -2
  344. letta_client/types/openai_types_chat_chat_completion_named_tool_choice_param_function.py +3 -2
  345. letta_client/types/openai_types_chat_completion_create_params_function.py +3 -2
  346. letta_client/types/organization.py +3 -2
  347. letta_client/types/organization_create.py +2 -1
  348. letta_client/types/organization_sources_stats.py +3 -2
  349. letta_client/types/organization_update.py +2 -1
  350. letta_client/types/parameter_properties.py +3 -2
  351. letta_client/types/parameters_schema.py +4 -3
  352. letta_client/types/parent_tool_rule.py +3 -2
  353. letta_client/types/passage.py +4 -3
  354. letta_client/types/payment_required_error_body.py +3 -2
  355. letta_client/types/pip_requirement.py +3 -2
  356. letta_client/types/provider.py +5 -4
  357. letta_client/types/provider_check.py +4 -3
  358. letta_client/types/provider_trace.py +3 -2
  359. letta_client/types/reasoning_content.py +2 -1
  360. letta_client/types/reasoning_message.py +4 -3
  361. letta_client/types/redacted_reasoning_content.py +2 -1
  362. letta_client/types/required_before_exit_tool_rule.py +3 -2
  363. letta_client/types/response_format_json_object.py +3 -2
  364. letta_client/types/response_format_json_schema.py +4 -3
  365. letta_client/types/response_format_text.py +3 -2
  366. letta_client/types/round_robin_manager.py +2 -1
  367. letta_client/types/round_robin_manager_update.py +2 -1
  368. letta_client/types/run.py +4 -3
  369. letta_client/types/sandbox_config.py +4 -3
  370. letta_client/types/sandbox_config_create.py +4 -3
  371. letta_client/types/sandbox_config_create_config.py +4 -2
  372. letta_client/types/sandbox_config_update.py +3 -2
  373. letta_client/types/sandbox_config_update_config.py +4 -2
  374. letta_client/types/sandbox_environment_variable.py +3 -2
  375. letta_client/types/sandbox_environment_variable_create.py +3 -2
  376. letta_client/types/sandbox_environment_variable_update.py +2 -1
  377. letta_client/types/sandbox_type.py +1 -1
  378. letta_client/types/sleeptime_manager.py +2 -1
  379. letta_client/types/sleeptime_manager_update.py +2 -1
  380. letta_client/types/source.py +5 -4
  381. letta_client/types/source_create.py +4 -3
  382. letta_client/types/source_stats.py +4 -3
  383. letta_client/types/source_update.py +3 -2
  384. letta_client/types/sse_server_config.py +4 -3
  385. letta_client/types/stdio_server_config.py +4 -3
  386. letta_client/types/step.py +5 -4
  387. letta_client/types/streamable_http_server_config.py +4 -3
  388. letta_client/types/supervisor_manager.py +2 -1
  389. letta_client/types/supervisor_manager_update.py +2 -1
  390. letta_client/types/system_message.py +2 -1
  391. letta_client/types/tag_schema.py +3 -2
  392. letta_client/types/terminal_tool_rule.py +3 -2
  393. letta_client/types/text_content.py +2 -1
  394. letta_client/types/text_response_format.py +3 -2
  395. letta_client/types/tool.py +5 -4
  396. letta_client/types/tool_annotations.py +4 -3
  397. letta_client/types/tool_call.py +3 -2
  398. letta_client/types/tool_call_content.py +2 -1
  399. letta_client/types/tool_call_delta.py +3 -2
  400. letta_client/types/tool_call_message.py +4 -3
  401. letta_client/types/tool_call_message_tool_call.py +1 -0
  402. letta_client/types/tool_create.py +3 -2
  403. letta_client/types/tool_env_var_schema.py +3 -2
  404. letta_client/types/tool_json_schema.py +4 -3
  405. letta_client/types/tool_return.py +4 -3
  406. letta_client/types/tool_return_content.py +2 -1
  407. letta_client/types/tool_return_message.py +4 -3
  408. letta_client/types/tool_schema.py +5 -4
  409. letta_client/types/tool_type.py +0 -1
  410. letta_client/types/update_assistant_message.py +3 -2
  411. letta_client/types/update_assistant_message_content.py +1 -0
  412. letta_client/types/update_reasoning_message.py +3 -2
  413. letta_client/types/update_ssemcp_server.py +2 -1
  414. letta_client/types/update_stdio_mcp_server.py +3 -2
  415. letta_client/types/update_streamable_httpmcp_server.py +2 -1
  416. letta_client/types/update_system_message.py +2 -1
  417. letta_client/types/update_user_message.py +3 -2
  418. letta_client/types/update_user_message_content.py +1 -0
  419. letta_client/types/url_image.py +2 -1
  420. letta_client/types/usage_statistics.py +5 -4
  421. letta_client/types/usage_statistics_completion_token_details.py +3 -2
  422. letta_client/types/usage_statistics_prompt_token_details.py +3 -2
  423. letta_client/types/user.py +3 -2
  424. letta_client/types/user_create.py +3 -2
  425. letta_client/types/user_message.py +3 -2
  426. letta_client/types/user_message_content.py +1 -0
  427. letta_client/types/user_update.py +3 -2
  428. letta_client/types/validation_error.py +4 -3
  429. letta_client/types/voice_sleeptime_manager.py +2 -1
  430. letta_client/types/voice_sleeptime_manager_update.py +2 -1
  431. letta_client/types/web_search_options.py +4 -3
  432. letta_client/types/web_search_options_user_location.py +4 -3
  433. letta_client/types/web_search_options_user_location_approximate.py +3 -2
  434. letta_client/voice/__init__.py +2 -0
  435. letta_client/voice/client.py +33 -74
  436. letta_client/voice/raw_client.py +154 -0
  437. {letta_client-0.1.232.dist-info → letta_client-0.1.234.dist-info}/METADATA +24 -3
  438. letta_client-0.1.234.dist-info/RECORD +503 -0
  439. letta_client-0.1.232.dist-info/RECORD +0 -454
  440. {letta_client-0.1.232.dist-info → letta_client-0.1.234.dist-info}/WHEEL +0 -0
@@ -0,0 +1,2068 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from .. import core
8
+ from ..core.api_error import ApiError
9
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
10
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
11
+ from ..core.jsonable_encoder import jsonable_encoder
12
+ from ..core.request_options import RequestOptions
13
+ from ..core.serialization import convert_and_respect_annotation_metadata
14
+ from ..core.unchecked_base_model import construct_type
15
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
16
+ from ..types.agent_state import AgentState
17
+ from ..types.agent_type import AgentType
18
+ from ..types.create_block import CreateBlock
19
+ from ..types.embedding_config import EmbeddingConfig
20
+ from ..types.http_validation_error import HttpValidationError
21
+ from ..types.llm_config import LlmConfig
22
+ from ..types.message_create import MessageCreate
23
+ from .types.agents_search_request_search_item import AgentsSearchRequestSearchItem
24
+ from .types.agents_search_request_sort_by import AgentsSearchRequestSortBy
25
+ from .types.agents_search_response import AgentsSearchResponse
26
+ from .types.create_agent_request_response_format import CreateAgentRequestResponseFormat
27
+ from .types.create_agent_request_tool_rules_item import CreateAgentRequestToolRulesItem
28
+ from .types.update_agent_response_format import UpdateAgentResponseFormat
29
+ from .types.update_agent_tool_rules_item import UpdateAgentToolRulesItem
30
+
31
+ # this is used as the default value for optional parameters
32
+ OMIT = typing.cast(typing.Any, ...)
33
+
34
+
35
+ class RawAgentsClient:
36
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
37
+ self._client_wrapper = client_wrapper
38
+
39
+ def list(
40
+ self,
41
+ *,
42
+ name: typing.Optional[str] = None,
43
+ tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
44
+ match_all_tags: typing.Optional[bool] = None,
45
+ before: typing.Optional[str] = None,
46
+ after: typing.Optional[str] = None,
47
+ limit: typing.Optional[int] = None,
48
+ query_text: typing.Optional[str] = None,
49
+ project_id: typing.Optional[str] = None,
50
+ template_id: typing.Optional[str] = None,
51
+ base_template_id: typing.Optional[str] = None,
52
+ identity_id: typing.Optional[str] = None,
53
+ identifier_keys: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
54
+ include_relationships: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
55
+ ascending: typing.Optional[bool] = None,
56
+ sort_by: typing.Optional[str] = None,
57
+ request_options: typing.Optional[RequestOptions] = None,
58
+ ) -> HttpResponse[typing.List[AgentState]]:
59
+ """
60
+ List all agents associated with a given user.
61
+
62
+ This endpoint retrieves a list of all agents and their configurations
63
+ associated with the specified user ID.
64
+
65
+ Parameters
66
+ ----------
67
+ name : typing.Optional[str]
68
+ Name of the agent
69
+
70
+ tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
71
+ List of tags to filter agents by
72
+
73
+ match_all_tags : typing.Optional[bool]
74
+ If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed-in tags.
75
+
76
+ before : typing.Optional[str]
77
+ Cursor for pagination
78
+
79
+ after : typing.Optional[str]
80
+ Cursor for pagination
81
+
82
+ limit : typing.Optional[int]
83
+ Limit for pagination
84
+
85
+ query_text : typing.Optional[str]
86
+ Search agents by name
87
+
88
+ project_id : typing.Optional[str]
89
+ Search agents by project ID
90
+
91
+ template_id : typing.Optional[str]
92
+ Search agents by template ID
93
+
94
+ base_template_id : typing.Optional[str]
95
+ Search agents by base template ID
96
+
97
+ identity_id : typing.Optional[str]
98
+ Search agents by identity ID
99
+
100
+ identifier_keys : typing.Optional[typing.Union[str, typing.Sequence[str]]]
101
+ Search agents by identifier keys
102
+
103
+ include_relationships : typing.Optional[typing.Union[str, typing.Sequence[str]]]
104
+ Specify which relational fields (e.g., 'tools', 'sources', 'memory') to include in the response. If not provided, all relationships are loaded by default. Using this can optimize performance by reducing unnecessary joins.
105
+
106
+ ascending : typing.Optional[bool]
107
+ Whether to sort agents oldest to newest (True) or newest to oldest (False, default)
108
+
109
+ sort_by : typing.Optional[str]
110
+ Field to sort by. Options: 'created_at' (default), 'last_run_completion'
111
+
112
+ request_options : typing.Optional[RequestOptions]
113
+ Request-specific configuration.
114
+
115
+ Returns
116
+ -------
117
+ HttpResponse[typing.List[AgentState]]
118
+ Successful Response
119
+ """
120
+ _response = self._client_wrapper.httpx_client.request(
121
+ "v1/agents/",
122
+ method="GET",
123
+ params={
124
+ "name": name,
125
+ "tags": tags,
126
+ "match_all_tags": match_all_tags,
127
+ "before": before,
128
+ "after": after,
129
+ "limit": limit,
130
+ "query_text": query_text,
131
+ "project_id": project_id,
132
+ "template_id": template_id,
133
+ "base_template_id": base_template_id,
134
+ "identity_id": identity_id,
135
+ "identifier_keys": identifier_keys,
136
+ "include_relationships": include_relationships,
137
+ "ascending": ascending,
138
+ "sort_by": sort_by,
139
+ },
140
+ request_options=request_options,
141
+ )
142
+ try:
143
+ if 200 <= _response.status_code < 300:
144
+ _data = typing.cast(
145
+ typing.List[AgentState],
146
+ construct_type(
147
+ type_=typing.List[AgentState], # type: ignore
148
+ object_=_response.json(),
149
+ ),
150
+ )
151
+ return HttpResponse(response=_response, data=_data)
152
+ if _response.status_code == 422:
153
+ raise UnprocessableEntityError(
154
+ headers=dict(_response.headers),
155
+ body=typing.cast(
156
+ HttpValidationError,
157
+ construct_type(
158
+ type_=HttpValidationError, # type: ignore
159
+ object_=_response.json(),
160
+ ),
161
+ ),
162
+ )
163
+ _response_json = _response.json()
164
+ except JSONDecodeError:
165
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
166
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
167
+
168
+ def create(
169
+ self,
170
+ *,
171
+ name: typing.Optional[str] = OMIT,
172
+ memory_blocks: typing.Optional[typing.Sequence[CreateBlock]] = OMIT,
173
+ tools: typing.Optional[typing.Sequence[str]] = OMIT,
174
+ tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
175
+ source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
176
+ block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
177
+ tool_rules: typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]] = OMIT,
178
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
179
+ system: typing.Optional[str] = OMIT,
180
+ agent_type: typing.Optional[AgentType] = OMIT,
181
+ llm_config: typing.Optional[LlmConfig] = OMIT,
182
+ embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
183
+ initial_message_sequence: typing.Optional[typing.Sequence[MessageCreate]] = OMIT,
184
+ include_base_tools: typing.Optional[bool] = OMIT,
185
+ include_multi_agent_tools: typing.Optional[bool] = OMIT,
186
+ include_base_tool_rules: typing.Optional[bool] = OMIT,
187
+ include_default_source: typing.Optional[bool] = OMIT,
188
+ description: typing.Optional[str] = OMIT,
189
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
190
+ model: typing.Optional[str] = OMIT,
191
+ embedding: typing.Optional[str] = OMIT,
192
+ context_window_limit: typing.Optional[int] = OMIT,
193
+ embedding_chunk_size: typing.Optional[int] = OMIT,
194
+ max_tokens: typing.Optional[int] = OMIT,
195
+ max_reasoning_tokens: typing.Optional[int] = OMIT,
196
+ enable_reasoner: typing.Optional[bool] = OMIT,
197
+ from_template: typing.Optional[str] = OMIT,
198
+ template: typing.Optional[bool] = OMIT,
199
+ project: typing.Optional[str] = OMIT,
200
+ tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
201
+ memory_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
202
+ project_id: typing.Optional[str] = OMIT,
203
+ template_id: typing.Optional[str] = OMIT,
204
+ base_template_id: typing.Optional[str] = OMIT,
205
+ identity_ids: typing.Optional[typing.Sequence[str]] = OMIT,
206
+ message_buffer_autoclear: typing.Optional[bool] = OMIT,
207
+ enable_sleeptime: typing.Optional[bool] = OMIT,
208
+ response_format: typing.Optional[CreateAgentRequestResponseFormat] = OMIT,
209
+ timezone: typing.Optional[str] = OMIT,
210
+ max_files_open: typing.Optional[int] = OMIT,
211
+ per_file_view_window_char_limit: typing.Optional[int] = OMIT,
212
+ request_options: typing.Optional[RequestOptions] = None,
213
+ ) -> HttpResponse[AgentState]:
214
+ """
215
+ Create a new agent with the specified configuration.
216
+
217
+ Parameters
218
+ ----------
219
+ name : typing.Optional[str]
220
+ The name of the agent.
221
+
222
+ memory_blocks : typing.Optional[typing.Sequence[CreateBlock]]
223
+ The blocks to create in the agent's in-context memory.
224
+
225
+ tools : typing.Optional[typing.Sequence[str]]
226
+ The tools used by the agent.
227
+
228
+ tool_ids : typing.Optional[typing.Sequence[str]]
229
+ The ids of the tools used by the agent.
230
+
231
+ source_ids : typing.Optional[typing.Sequence[str]]
232
+ The ids of the sources used by the agent.
233
+
234
+ block_ids : typing.Optional[typing.Sequence[str]]
235
+ The ids of the blocks used by the agent.
236
+
237
+ tool_rules : typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]]
238
+ The tool rules governing the agent.
239
+
240
+ tags : typing.Optional[typing.Sequence[str]]
241
+ The tags associated with the agent.
242
+
243
+ system : typing.Optional[str]
244
+ The system prompt used by the agent.
245
+
246
+ agent_type : typing.Optional[AgentType]
247
+ The type of agent.
248
+
249
+ llm_config : typing.Optional[LlmConfig]
250
+ The LLM configuration used by the agent.
251
+
252
+ embedding_config : typing.Optional[EmbeddingConfig]
253
+ The embedding configuration used by the agent.
254
+
255
+ initial_message_sequence : typing.Optional[typing.Sequence[MessageCreate]]
256
+ The initial set of messages to put in the agent's in-context memory.
257
+
258
+ include_base_tools : typing.Optional[bool]
259
+ If true, attaches the Letta core tools (e.g. core_memory related functions).
260
+
261
+ include_multi_agent_tools : typing.Optional[bool]
262
+ If true, attaches the Letta multi-agent tools (e.g. sending a message to another agent).
263
+
264
+ include_base_tool_rules : typing.Optional[bool]
265
+ If true, attaches the Letta base tool rules (e.g. deny all tools not explicitly allowed).
266
+
267
+ include_default_source : typing.Optional[bool]
268
+ If true, automatically creates and attaches a default data source for this agent.
269
+
270
+ description : typing.Optional[str]
271
+ The description of the agent.
272
+
273
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
274
+ The metadata of the agent.
275
+
276
+ model : typing.Optional[str]
277
+ The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
278
+
279
+ embedding : typing.Optional[str]
280
+ The embedding configuration handle used by the agent, specified in the format provider/model-name.
281
+
282
+ context_window_limit : typing.Optional[int]
283
+ The context window limit used by the agent.
284
+
285
+ embedding_chunk_size : typing.Optional[int]
286
+ The embedding chunk size used by the agent.
287
+
288
+ max_tokens : typing.Optional[int]
289
+ The maximum number of tokens to generate, including reasoning step. If not set, the model will use its default value.
290
+
291
+ max_reasoning_tokens : typing.Optional[int]
292
+ The maximum number of tokens to generate for reasoning step. If not set, the model will use its default value.
293
+
294
+ enable_reasoner : typing.Optional[bool]
295
+ Whether to enable internal extended thinking step for a reasoner model.
296
+
297
+ from_template : typing.Optional[str]
298
+ The template id used to configure the agent
299
+
300
+ template : typing.Optional[bool]
301
+ Whether the agent is a template
302
+
303
+ project : typing.Optional[str]
304
+ Deprecated: Project should now be passed via the X-Project header instead of in the request body. If using the sdk, this can be done via the new x_project field below.
305
+
306
+ tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
307
+ The environment variables for tool execution specific to this agent.
308
+
309
+ memory_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
310
+ The variables that should be set for the agent.
311
+
312
+ project_id : typing.Optional[str]
313
+ The id of the project the agent belongs to.
314
+
315
+ template_id : typing.Optional[str]
316
+ The id of the template the agent belongs to.
317
+
318
+ base_template_id : typing.Optional[str]
319
+ The base template id of the agent.
320
+
321
+ identity_ids : typing.Optional[typing.Sequence[str]]
322
+ The ids of the identities associated with this agent.
323
+
324
+ message_buffer_autoclear : typing.Optional[bool]
325
+ If set to True, the agent will not remember previous messages (though the agent will still retain state via core memory blocks and archival/recall memory). Not recommended unless you have an advanced use case.
326
+
327
+ enable_sleeptime : typing.Optional[bool]
328
+ If set to True, memory management will move to a background agent thread.
329
+
330
+ response_format : typing.Optional[CreateAgentRequestResponseFormat]
331
+ The response format for the agent.
332
+
333
+ timezone : typing.Optional[str]
334
+ The timezone of the agent (IANA format).
335
+
336
+ max_files_open : typing.Optional[int]
337
+ Maximum number of files that can be open at once for this agent. Setting this too high may exceed the context window, which will break the agent.
338
+
339
+ per_file_view_window_char_limit : typing.Optional[int]
340
+ The per-file view window character limit for this agent. Setting this too high may exceed the context window, which will break the agent.
341
+
342
+ request_options : typing.Optional[RequestOptions]
343
+ Request-specific configuration.
344
+
345
+ Returns
346
+ -------
347
+ HttpResponse[AgentState]
348
+ Successful Response
349
+ """
350
+ _response = self._client_wrapper.httpx_client.request(
351
+ "v1/agents/",
352
+ method="POST",
353
+ json={
354
+ "name": name,
355
+ "memory_blocks": convert_and_respect_annotation_metadata(
356
+ object_=memory_blocks, annotation=typing.Sequence[CreateBlock], direction="write"
357
+ ),
358
+ "tools": tools,
359
+ "tool_ids": tool_ids,
360
+ "source_ids": source_ids,
361
+ "block_ids": block_ids,
362
+ "tool_rules": convert_and_respect_annotation_metadata(
363
+ object_=tool_rules, annotation=typing.Sequence[CreateAgentRequestToolRulesItem], direction="write"
364
+ ),
365
+ "tags": tags,
366
+ "system": system,
367
+ "agent_type": agent_type,
368
+ "llm_config": convert_and_respect_annotation_metadata(
369
+ object_=llm_config, annotation=LlmConfig, direction="write"
370
+ ),
371
+ "embedding_config": convert_and_respect_annotation_metadata(
372
+ object_=embedding_config, annotation=EmbeddingConfig, direction="write"
373
+ ),
374
+ "initial_message_sequence": convert_and_respect_annotation_metadata(
375
+ object_=initial_message_sequence, annotation=typing.Sequence[MessageCreate], direction="write"
376
+ ),
377
+ "include_base_tools": include_base_tools,
378
+ "include_multi_agent_tools": include_multi_agent_tools,
379
+ "include_base_tool_rules": include_base_tool_rules,
380
+ "include_default_source": include_default_source,
381
+ "description": description,
382
+ "metadata": metadata,
383
+ "model": model,
384
+ "embedding": embedding,
385
+ "context_window_limit": context_window_limit,
386
+ "embedding_chunk_size": embedding_chunk_size,
387
+ "max_tokens": max_tokens,
388
+ "max_reasoning_tokens": max_reasoning_tokens,
389
+ "enable_reasoner": enable_reasoner,
390
+ "from_template": from_template,
391
+ "template": template,
392
+ "project": project,
393
+ "tool_exec_environment_variables": tool_exec_environment_variables,
394
+ "memory_variables": memory_variables,
395
+ "project_id": project_id,
396
+ "template_id": template_id,
397
+ "base_template_id": base_template_id,
398
+ "identity_ids": identity_ids,
399
+ "message_buffer_autoclear": message_buffer_autoclear,
400
+ "enable_sleeptime": enable_sleeptime,
401
+ "response_format": convert_and_respect_annotation_metadata(
402
+ object_=response_format, annotation=CreateAgentRequestResponseFormat, direction="write"
403
+ ),
404
+ "timezone": timezone,
405
+ "max_files_open": max_files_open,
406
+ "per_file_view_window_char_limit": per_file_view_window_char_limit,
407
+ },
408
+ headers={
409
+ "content-type": "application/json",
410
+ },
411
+ request_options=request_options,
412
+ omit=OMIT,
413
+ )
414
+ try:
415
+ if 200 <= _response.status_code < 300:
416
+ _data = typing.cast(
417
+ AgentState,
418
+ construct_type(
419
+ type_=AgentState, # type: ignore
420
+ object_=_response.json(),
421
+ ),
422
+ )
423
+ return HttpResponse(response=_response, data=_data)
424
+ if _response.status_code == 422:
425
+ raise UnprocessableEntityError(
426
+ headers=dict(_response.headers),
427
+ body=typing.cast(
428
+ HttpValidationError,
429
+ construct_type(
430
+ type_=HttpValidationError, # type: ignore
431
+ object_=_response.json(),
432
+ ),
433
+ ),
434
+ )
435
+ _response_json = _response.json()
436
+ except JSONDecodeError:
437
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
438
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
439
+
440
+ def count(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[int]:
441
+ """
442
+ Get the count of all agents associated with a given user.
443
+
444
+ Parameters
445
+ ----------
446
+ request_options : typing.Optional[RequestOptions]
447
+ Request-specific configuration.
448
+
449
+ Returns
450
+ -------
451
+ HttpResponse[int]
452
+ Successful Response
453
+ """
454
+ _response = self._client_wrapper.httpx_client.request(
455
+ "v1/agents/count",
456
+ method="GET",
457
+ request_options=request_options,
458
+ )
459
+ try:
460
+ if 200 <= _response.status_code < 300:
461
+ _data = typing.cast(
462
+ int,
463
+ construct_type(
464
+ type_=int, # type: ignore
465
+ object_=_response.json(),
466
+ ),
467
+ )
468
+ return HttpResponse(response=_response, data=_data)
469
+ if _response.status_code == 422:
470
+ raise UnprocessableEntityError(
471
+ headers=dict(_response.headers),
472
+ body=typing.cast(
473
+ HttpValidationError,
474
+ construct_type(
475
+ type_=HttpValidationError, # type: ignore
476
+ object_=_response.json(),
477
+ ),
478
+ ),
479
+ )
480
+ _response_json = _response.json()
481
+ except JSONDecodeError:
482
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
483
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
484
+
485
+ def export_file(
486
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
487
+ ) -> HttpResponse[str]:
488
+ """
489
+ Export the serialized JSON representation of an agent, formatted with indentation.
490
+
491
+ Parameters
492
+ ----------
493
+ agent_id : str
494
+
495
+ request_options : typing.Optional[RequestOptions]
496
+ Request-specific configuration.
497
+
498
+ Returns
499
+ -------
500
+ HttpResponse[str]
501
+ Successful Response
502
+ """
503
+ _response = self._client_wrapper.httpx_client.request(
504
+ f"v1/agents/{jsonable_encoder(agent_id)}/export",
505
+ method="GET",
506
+ request_options=request_options,
507
+ )
508
+ try:
509
+ if 200 <= _response.status_code < 300:
510
+ _data = typing.cast(
511
+ str,
512
+ construct_type(
513
+ type_=str, # type: ignore
514
+ object_=_response.json(),
515
+ ),
516
+ )
517
+ return HttpResponse(response=_response, data=_data)
518
+ if _response.status_code == 422:
519
+ raise UnprocessableEntityError(
520
+ headers=dict(_response.headers),
521
+ body=typing.cast(
522
+ HttpValidationError,
523
+ construct_type(
524
+ type_=HttpValidationError, # type: ignore
525
+ object_=_response.json(),
526
+ ),
527
+ ),
528
+ )
529
+ _response_json = _response.json()
530
+ except JSONDecodeError:
531
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
532
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
533
+
534
+ def import_file(
535
+ self,
536
+ *,
537
+ file: core.File,
538
+ append_copy_suffix: typing.Optional[bool] = None,
539
+ override_existing_tools: typing.Optional[bool] = None,
540
+ project_id: typing.Optional[str] = None,
541
+ strip_messages: typing.Optional[bool] = None,
542
+ request_options: typing.Optional[RequestOptions] = None,
543
+ ) -> HttpResponse[AgentState]:
544
+ """
545
+ Import a serialized agent file and recreate the agent in the system.
546
+
547
+ Parameters
548
+ ----------
549
+ file : core.File
550
+ See core.File for more documentation
551
+
552
+ append_copy_suffix : typing.Optional[bool]
553
+ If set to True, appends "_copy" to the end of the agent name.
554
+
555
+ override_existing_tools : typing.Optional[bool]
556
+ If set to True, existing tools can get their source code overwritten by the uploaded tool definitions. Note that Letta core tools can never be updated externally.
557
+
558
+ project_id : typing.Optional[str]
559
+ The project ID to associate the uploaded agent with.
560
+
561
+ strip_messages : typing.Optional[bool]
562
+ If set to True, strips all messages from the agent before importing.
563
+
564
+ request_options : typing.Optional[RequestOptions]
565
+ Request-specific configuration.
566
+
567
+ Returns
568
+ -------
569
+ HttpResponse[AgentState]
570
+ Successful Response
571
+ """
572
+ _response = self._client_wrapper.httpx_client.request(
573
+ "v1/agents/import",
574
+ method="POST",
575
+ params={
576
+ "append_copy_suffix": append_copy_suffix,
577
+ "override_existing_tools": override_existing_tools,
578
+ "project_id": project_id,
579
+ "strip_messages": strip_messages,
580
+ },
581
+ data={},
582
+ files={
583
+ "file": file,
584
+ },
585
+ request_options=request_options,
586
+ omit=OMIT,
587
+ force_multipart=True,
588
+ )
589
+ try:
590
+ if 200 <= _response.status_code < 300:
591
+ _data = typing.cast(
592
+ AgentState,
593
+ construct_type(
594
+ type_=AgentState, # type: ignore
595
+ object_=_response.json(),
596
+ ),
597
+ )
598
+ return HttpResponse(response=_response, data=_data)
599
+ if _response.status_code == 422:
600
+ raise UnprocessableEntityError(
601
+ headers=dict(_response.headers),
602
+ body=typing.cast(
603
+ HttpValidationError,
604
+ construct_type(
605
+ type_=HttpValidationError, # type: ignore
606
+ object_=_response.json(),
607
+ ),
608
+ ),
609
+ )
610
+ _response_json = _response.json()
611
+ except JSONDecodeError:
612
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
613
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
614
+
615
+ def retrieve(
616
+ self,
617
+ agent_id: str,
618
+ *,
619
+ include_relationships: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
620
+ request_options: typing.Optional[RequestOptions] = None,
621
+ ) -> HttpResponse[AgentState]:
622
+ """
623
+ Get the state of the agent.
624
+
625
+ Parameters
626
+ ----------
627
+ agent_id : str
628
+
629
+ include_relationships : typing.Optional[typing.Union[str, typing.Sequence[str]]]
630
+ Specify which relational fields (e.g., 'tools', 'sources', 'memory') to include in the response. If not provided, all relationships are loaded by default. Using this can optimize performance by reducing unnecessary joins.
631
+
632
+ request_options : typing.Optional[RequestOptions]
633
+ Request-specific configuration.
634
+
635
+ Returns
636
+ -------
637
+ HttpResponse[AgentState]
638
+ Successful Response
639
+ """
640
+ _response = self._client_wrapper.httpx_client.request(
641
+ f"v1/agents/{jsonable_encoder(agent_id)}",
642
+ method="GET",
643
+ params={
644
+ "include_relationships": include_relationships,
645
+ },
646
+ request_options=request_options,
647
+ )
648
+ try:
649
+ if 200 <= _response.status_code < 300:
650
+ _data = typing.cast(
651
+ AgentState,
652
+ construct_type(
653
+ type_=AgentState, # type: ignore
654
+ object_=_response.json(),
655
+ ),
656
+ )
657
+ return HttpResponse(response=_response, data=_data)
658
+ if _response.status_code == 422:
659
+ raise UnprocessableEntityError(
660
+ headers=dict(_response.headers),
661
+ body=typing.cast(
662
+ HttpValidationError,
663
+ construct_type(
664
+ type_=HttpValidationError, # type: ignore
665
+ object_=_response.json(),
666
+ ),
667
+ ),
668
+ )
669
+ _response_json = _response.json()
670
+ except JSONDecodeError:
671
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
672
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
673
+
674
+ def delete(
675
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
676
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
677
+ """
678
+ Delete an agent.
679
+
680
+ Parameters
681
+ ----------
682
+ agent_id : str
683
+
684
+ request_options : typing.Optional[RequestOptions]
685
+ Request-specific configuration.
686
+
687
+ Returns
688
+ -------
689
+ HttpResponse[typing.Optional[typing.Any]]
690
+ Successful Response
691
+ """
692
+ _response = self._client_wrapper.httpx_client.request(
693
+ f"v1/agents/{jsonable_encoder(agent_id)}",
694
+ method="DELETE",
695
+ request_options=request_options,
696
+ )
697
+ try:
698
+ if _response is None or not _response.text.strip():
699
+ return HttpResponse(response=_response, data=None)
700
+ if 200 <= _response.status_code < 300:
701
+ _data = typing.cast(
702
+ typing.Optional[typing.Any],
703
+ construct_type(
704
+ type_=typing.Optional[typing.Any], # type: ignore
705
+ object_=_response.json(),
706
+ ),
707
+ )
708
+ return HttpResponse(response=_response, data=_data)
709
+ if _response.status_code == 422:
710
+ raise UnprocessableEntityError(
711
+ headers=dict(_response.headers),
712
+ body=typing.cast(
713
+ HttpValidationError,
714
+ construct_type(
715
+ type_=HttpValidationError, # type: ignore
716
+ object_=_response.json(),
717
+ ),
718
+ ),
719
+ )
720
+ _response_json = _response.json()
721
+ except JSONDecodeError:
722
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
723
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
724
+
725
+ def modify(
726
+ self,
727
+ agent_id: str,
728
+ *,
729
+ name: typing.Optional[str] = OMIT,
730
+ tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
731
+ source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
732
+ block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
733
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
734
+ system: typing.Optional[str] = OMIT,
735
+ tool_rules: typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]] = OMIT,
736
+ llm_config: typing.Optional[LlmConfig] = OMIT,
737
+ embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
738
+ message_ids: typing.Optional[typing.Sequence[str]] = OMIT,
739
+ description: typing.Optional[str] = OMIT,
740
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
741
+ tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
742
+ project_id: typing.Optional[str] = OMIT,
743
+ template_id: typing.Optional[str] = OMIT,
744
+ base_template_id: typing.Optional[str] = OMIT,
745
+ identity_ids: typing.Optional[typing.Sequence[str]] = OMIT,
746
+ message_buffer_autoclear: typing.Optional[bool] = OMIT,
747
+ model: typing.Optional[str] = OMIT,
748
+ embedding: typing.Optional[str] = OMIT,
749
+ enable_sleeptime: typing.Optional[bool] = OMIT,
750
+ response_format: typing.Optional[UpdateAgentResponseFormat] = OMIT,
751
+ last_run_completion: typing.Optional[dt.datetime] = OMIT,
752
+ last_run_duration_ms: typing.Optional[int] = OMIT,
753
+ timezone: typing.Optional[str] = OMIT,
754
+ max_files_open: typing.Optional[int] = OMIT,
755
+ per_file_view_window_char_limit: typing.Optional[int] = OMIT,
756
+ request_options: typing.Optional[RequestOptions] = None,
757
+ ) -> HttpResponse[AgentState]:
758
+ """
759
+ Update an existing agent
760
+
761
+ Parameters
762
+ ----------
763
+ agent_id : str
764
+
765
+ name : typing.Optional[str]
766
+ The name of the agent.
767
+
768
+ tool_ids : typing.Optional[typing.Sequence[str]]
769
+ The ids of the tools used by the agent.
770
+
771
+ source_ids : typing.Optional[typing.Sequence[str]]
772
+ The ids of the sources used by the agent.
773
+
774
+ block_ids : typing.Optional[typing.Sequence[str]]
775
+ The ids of the blocks used by the agent.
776
+
777
+ tags : typing.Optional[typing.Sequence[str]]
778
+ The tags associated with the agent.
779
+
780
+ system : typing.Optional[str]
781
+ The system prompt used by the agent.
782
+
783
+ tool_rules : typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]]
784
+ The tool rules governing the agent.
785
+
786
+ llm_config : typing.Optional[LlmConfig]
787
+ The LLM configuration used by the agent.
788
+
789
+ embedding_config : typing.Optional[EmbeddingConfig]
790
+ The embedding configuration used by the agent.
791
+
792
+ message_ids : typing.Optional[typing.Sequence[str]]
793
+ The ids of the messages in the agent's in-context memory.
794
+
795
+ description : typing.Optional[str]
796
+ The description of the agent.
797
+
798
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
799
+ The metadata of the agent.
800
+
801
+ tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
802
+ The environment variables for tool execution specific to this agent.
803
+
804
+ project_id : typing.Optional[str]
805
+ The id of the project the agent belongs to.
806
+
807
+ template_id : typing.Optional[str]
808
+ The id of the template the agent belongs to.
809
+
810
+ base_template_id : typing.Optional[str]
811
+ The base template id of the agent.
812
+
813
+ identity_ids : typing.Optional[typing.Sequence[str]]
814
+ The ids of the identities associated with this agent.
815
+
816
+ message_buffer_autoclear : typing.Optional[bool]
817
+ If set to True, the agent will not remember previous messages (though the agent will still retain state via core memory blocks and archival/recall memory). Not recommended unless you have an advanced use case.
818
+
819
+ model : typing.Optional[str]
820
+ The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
821
+
822
+ embedding : typing.Optional[str]
823
+ The embedding configuration handle used by the agent, specified in the format provider/model-name.
824
+
825
+ enable_sleeptime : typing.Optional[bool]
826
+ If set to True, memory management will move to a background agent thread.
827
+
828
+ response_format : typing.Optional[UpdateAgentResponseFormat]
829
+ The response format for the agent.
830
+
831
+ last_run_completion : typing.Optional[dt.datetime]
832
+ The timestamp when the agent last completed a run.
833
+
834
+ last_run_duration_ms : typing.Optional[int]
835
+ The duration in milliseconds of the agent's last run.
836
+
837
+ timezone : typing.Optional[str]
838
+ The timezone of the agent (IANA format).
839
+
840
+ max_files_open : typing.Optional[int]
841
+ Maximum number of files that can be open at once for this agent. Setting this too high may exceed the context window, which will break the agent.
842
+
843
+ per_file_view_window_char_limit : typing.Optional[int]
844
+ The per-file view window character limit for this agent. Setting this too high may exceed the context window, which will break the agent.
845
+
846
+ request_options : typing.Optional[RequestOptions]
847
+ Request-specific configuration.
848
+
849
+ Returns
850
+ -------
851
+ HttpResponse[AgentState]
852
+ Successful Response
853
+ """
854
+ _response = self._client_wrapper.httpx_client.request(
855
+ f"v1/agents/{jsonable_encoder(agent_id)}",
856
+ method="PATCH",
857
+ json={
858
+ "name": name,
859
+ "tool_ids": tool_ids,
860
+ "source_ids": source_ids,
861
+ "block_ids": block_ids,
862
+ "tags": tags,
863
+ "system": system,
864
+ "tool_rules": convert_and_respect_annotation_metadata(
865
+ object_=tool_rules, annotation=typing.Sequence[UpdateAgentToolRulesItem], direction="write"
866
+ ),
867
+ "llm_config": convert_and_respect_annotation_metadata(
868
+ object_=llm_config, annotation=LlmConfig, direction="write"
869
+ ),
870
+ "embedding_config": convert_and_respect_annotation_metadata(
871
+ object_=embedding_config, annotation=EmbeddingConfig, direction="write"
872
+ ),
873
+ "message_ids": message_ids,
874
+ "description": description,
875
+ "metadata": metadata,
876
+ "tool_exec_environment_variables": tool_exec_environment_variables,
877
+ "project_id": project_id,
878
+ "template_id": template_id,
879
+ "base_template_id": base_template_id,
880
+ "identity_ids": identity_ids,
881
+ "message_buffer_autoclear": message_buffer_autoclear,
882
+ "model": model,
883
+ "embedding": embedding,
884
+ "enable_sleeptime": enable_sleeptime,
885
+ "response_format": convert_and_respect_annotation_metadata(
886
+ object_=response_format, annotation=UpdateAgentResponseFormat, direction="write"
887
+ ),
888
+ "last_run_completion": last_run_completion,
889
+ "last_run_duration_ms": last_run_duration_ms,
890
+ "timezone": timezone,
891
+ "max_files_open": max_files_open,
892
+ "per_file_view_window_char_limit": per_file_view_window_char_limit,
893
+ },
894
+ headers={
895
+ "content-type": "application/json",
896
+ },
897
+ request_options=request_options,
898
+ omit=OMIT,
899
+ )
900
+ try:
901
+ if 200 <= _response.status_code < 300:
902
+ _data = typing.cast(
903
+ AgentState,
904
+ construct_type(
905
+ type_=AgentState, # type: ignore
906
+ object_=_response.json(),
907
+ ),
908
+ )
909
+ return HttpResponse(response=_response, data=_data)
910
+ if _response.status_code == 422:
911
+ raise UnprocessableEntityError(
912
+ headers=dict(_response.headers),
913
+ body=typing.cast(
914
+ HttpValidationError,
915
+ construct_type(
916
+ type_=HttpValidationError, # type: ignore
917
+ object_=_response.json(),
918
+ ),
919
+ ),
920
+ )
921
+ _response_json = _response.json()
922
+ except JSONDecodeError:
923
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
924
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
925
+
926
+ def summarize_agent_conversation(
927
+ self, agent_id: str, *, max_message_length: int, request_options: typing.Optional[RequestOptions] = None
928
+ ) -> HttpResponse[None]:
929
+ """
930
+ Summarize an agent's conversation history to a target message length.
931
+
932
+ This endpoint summarizes the current message history for a given agent,
933
+ truncating and compressing it down to the specified `max_message_length`.
934
+
935
+ Parameters
936
+ ----------
937
+ agent_id : str
938
+
939
+ max_message_length : int
940
+ Maximum number of messages to retain after summarization.
941
+
942
+ request_options : typing.Optional[RequestOptions]
943
+ Request-specific configuration.
944
+
945
+ Returns
946
+ -------
947
+ HttpResponse[None]
948
+ """
949
+ _response = self._client_wrapper.httpx_client.request(
950
+ f"v1/agents/{jsonable_encoder(agent_id)}/summarize",
951
+ method="POST",
952
+ params={
953
+ "max_message_length": max_message_length,
954
+ },
955
+ request_options=request_options,
956
+ )
957
+ try:
958
+ if 200 <= _response.status_code < 300:
959
+ return HttpResponse(response=_response, data=None)
960
+ if _response.status_code == 422:
961
+ raise UnprocessableEntityError(
962
+ headers=dict(_response.headers),
963
+ body=typing.cast(
964
+ HttpValidationError,
965
+ construct_type(
966
+ type_=HttpValidationError, # type: ignore
967
+ object_=_response.json(),
968
+ ),
969
+ ),
970
+ )
971
+ _response_json = _response.json()
972
+ except JSONDecodeError:
973
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
974
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
975
+
976
+ def search(
977
+ self,
978
+ *,
979
+ search: typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]] = OMIT,
980
+ project_id: typing.Optional[str] = OMIT,
981
+ combinator: typing.Optional[typing.Literal["AND"]] = OMIT,
982
+ limit: typing.Optional[float] = OMIT,
983
+ after: typing.Optional[str] = OMIT,
984
+ sort_by: typing.Optional[AgentsSearchRequestSortBy] = OMIT,
985
+ ascending: typing.Optional[bool] = OMIT,
986
+ request_options: typing.Optional[RequestOptions] = None,
987
+ ) -> HttpResponse[AgentsSearchResponse]:
988
+ """
989
+ <Note>This endpoint is only available on Letta Cloud.</Note>
990
+
991
+ Search deployed agents.
992
+
993
+ Parameters
994
+ ----------
995
+ search : typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]]
996
+
997
+ project_id : typing.Optional[str]
998
+
999
+ combinator : typing.Optional[typing.Literal["AND"]]
1000
+
1001
+ limit : typing.Optional[float]
1002
+
1003
+ after : typing.Optional[str]
1004
+
1005
+ sort_by : typing.Optional[AgentsSearchRequestSortBy]
1006
+
1007
+ ascending : typing.Optional[bool]
1008
+
1009
+ request_options : typing.Optional[RequestOptions]
1010
+ Request-specific configuration.
1011
+
1012
+ Returns
1013
+ -------
1014
+ HttpResponse[AgentsSearchResponse]
1015
+ 200
1016
+ """
1017
+ _response = self._client_wrapper.httpx_client.request(
1018
+ "v1/agents/search",
1019
+ method="POST",
1020
+ json={
1021
+ "search": convert_and_respect_annotation_metadata(
1022
+ object_=search, annotation=typing.Sequence[AgentsSearchRequestSearchItem], direction="write"
1023
+ ),
1024
+ "project_id": project_id,
1025
+ "combinator": combinator,
1026
+ "limit": limit,
1027
+ "after": after,
1028
+ "sortBy": sort_by,
1029
+ "ascending": ascending,
1030
+ },
1031
+ headers={
1032
+ "content-type": "application/json",
1033
+ },
1034
+ request_options=request_options,
1035
+ omit=OMIT,
1036
+ )
1037
+ try:
1038
+ if 200 <= _response.status_code < 300:
1039
+ _data = typing.cast(
1040
+ AgentsSearchResponse,
1041
+ construct_type(
1042
+ type_=AgentsSearchResponse, # type: ignore
1043
+ object_=_response.json(),
1044
+ ),
1045
+ )
1046
+ return HttpResponse(response=_response, data=_data)
1047
+ _response_json = _response.json()
1048
+ except JSONDecodeError:
1049
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1050
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1051
+
1052
+
1053
+ class AsyncRawAgentsClient:
1054
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
1055
+ self._client_wrapper = client_wrapper
1056
+
1057
+ async def list(
1058
+ self,
1059
+ *,
1060
+ name: typing.Optional[str] = None,
1061
+ tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
1062
+ match_all_tags: typing.Optional[bool] = None,
1063
+ before: typing.Optional[str] = None,
1064
+ after: typing.Optional[str] = None,
1065
+ limit: typing.Optional[int] = None,
1066
+ query_text: typing.Optional[str] = None,
1067
+ project_id: typing.Optional[str] = None,
1068
+ template_id: typing.Optional[str] = None,
1069
+ base_template_id: typing.Optional[str] = None,
1070
+ identity_id: typing.Optional[str] = None,
1071
+ identifier_keys: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
1072
+ include_relationships: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
1073
+ ascending: typing.Optional[bool] = None,
1074
+ sort_by: typing.Optional[str] = None,
1075
+ request_options: typing.Optional[RequestOptions] = None,
1076
+ ) -> AsyncHttpResponse[typing.List[AgentState]]:
1077
+ """
1078
+ List all agents associated with a given user.
1079
+
1080
+ This endpoint retrieves a list of all agents and their configurations
1081
+ associated with the specified user ID.
1082
+
1083
+ Parameters
1084
+ ----------
1085
+ name : typing.Optional[str]
1086
+ Name of the agent
1087
+
1088
+ tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
1089
+ List of tags to filter agents by
1090
+
1091
+ match_all_tags : typing.Optional[bool]
1092
+ If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed-in tags.
1093
+
1094
+ before : typing.Optional[str]
1095
+ Cursor for pagination
1096
+
1097
+ after : typing.Optional[str]
1098
+ Cursor for pagination
1099
+
1100
+ limit : typing.Optional[int]
1101
+ Limit for pagination
1102
+
1103
+ query_text : typing.Optional[str]
1104
+ Search agents by name
1105
+
1106
+ project_id : typing.Optional[str]
1107
+ Search agents by project ID
1108
+
1109
+ template_id : typing.Optional[str]
1110
+ Search agents by template ID
1111
+
1112
+ base_template_id : typing.Optional[str]
1113
+ Search agents by base template ID
1114
+
1115
+ identity_id : typing.Optional[str]
1116
+ Search agents by identity ID
1117
+
1118
+ identifier_keys : typing.Optional[typing.Union[str, typing.Sequence[str]]]
1119
+ Search agents by identifier keys
1120
+
1121
+ include_relationships : typing.Optional[typing.Union[str, typing.Sequence[str]]]
1122
+ Specify which relational fields (e.g., 'tools', 'sources', 'memory') to include in the response. If not provided, all relationships are loaded by default. Using this can optimize performance by reducing unnecessary joins.
1123
+
1124
+ ascending : typing.Optional[bool]
1125
+ Whether to sort agents oldest to newest (True) or newest to oldest (False, default)
1126
+
1127
+ sort_by : typing.Optional[str]
1128
+ Field to sort by. Options: 'created_at' (default), 'last_run_completion'
1129
+
1130
+ request_options : typing.Optional[RequestOptions]
1131
+ Request-specific configuration.
1132
+
1133
+ Returns
1134
+ -------
1135
+ AsyncHttpResponse[typing.List[AgentState]]
1136
+ Successful Response
1137
+ """
1138
+ _response = await self._client_wrapper.httpx_client.request(
1139
+ "v1/agents/",
1140
+ method="GET",
1141
+ params={
1142
+ "name": name,
1143
+ "tags": tags,
1144
+ "match_all_tags": match_all_tags,
1145
+ "before": before,
1146
+ "after": after,
1147
+ "limit": limit,
1148
+ "query_text": query_text,
1149
+ "project_id": project_id,
1150
+ "template_id": template_id,
1151
+ "base_template_id": base_template_id,
1152
+ "identity_id": identity_id,
1153
+ "identifier_keys": identifier_keys,
1154
+ "include_relationships": include_relationships,
1155
+ "ascending": ascending,
1156
+ "sort_by": sort_by,
1157
+ },
1158
+ request_options=request_options,
1159
+ )
1160
+ try:
1161
+ if 200 <= _response.status_code < 300:
1162
+ _data = typing.cast(
1163
+ typing.List[AgentState],
1164
+ construct_type(
1165
+ type_=typing.List[AgentState], # type: ignore
1166
+ object_=_response.json(),
1167
+ ),
1168
+ )
1169
+ return AsyncHttpResponse(response=_response, data=_data)
1170
+ if _response.status_code == 422:
1171
+ raise UnprocessableEntityError(
1172
+ headers=dict(_response.headers),
1173
+ body=typing.cast(
1174
+ HttpValidationError,
1175
+ construct_type(
1176
+ type_=HttpValidationError, # type: ignore
1177
+ object_=_response.json(),
1178
+ ),
1179
+ ),
1180
+ )
1181
+ _response_json = _response.json()
1182
+ except JSONDecodeError:
1183
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1184
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1185
+
1186
+ async def create(
1187
+ self,
1188
+ *,
1189
+ name: typing.Optional[str] = OMIT,
1190
+ memory_blocks: typing.Optional[typing.Sequence[CreateBlock]] = OMIT,
1191
+ tools: typing.Optional[typing.Sequence[str]] = OMIT,
1192
+ tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1193
+ source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1194
+ block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1195
+ tool_rules: typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]] = OMIT,
1196
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1197
+ system: typing.Optional[str] = OMIT,
1198
+ agent_type: typing.Optional[AgentType] = OMIT,
1199
+ llm_config: typing.Optional[LlmConfig] = OMIT,
1200
+ embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
1201
+ initial_message_sequence: typing.Optional[typing.Sequence[MessageCreate]] = OMIT,
1202
+ include_base_tools: typing.Optional[bool] = OMIT,
1203
+ include_multi_agent_tools: typing.Optional[bool] = OMIT,
1204
+ include_base_tool_rules: typing.Optional[bool] = OMIT,
1205
+ include_default_source: typing.Optional[bool] = OMIT,
1206
+ description: typing.Optional[str] = OMIT,
1207
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1208
+ model: typing.Optional[str] = OMIT,
1209
+ embedding: typing.Optional[str] = OMIT,
1210
+ context_window_limit: typing.Optional[int] = OMIT,
1211
+ embedding_chunk_size: typing.Optional[int] = OMIT,
1212
+ max_tokens: typing.Optional[int] = OMIT,
1213
+ max_reasoning_tokens: typing.Optional[int] = OMIT,
1214
+ enable_reasoner: typing.Optional[bool] = OMIT,
1215
+ from_template: typing.Optional[str] = OMIT,
1216
+ template: typing.Optional[bool] = OMIT,
1217
+ project: typing.Optional[str] = OMIT,
1218
+ tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
1219
+ memory_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
1220
+ project_id: typing.Optional[str] = OMIT,
1221
+ template_id: typing.Optional[str] = OMIT,
1222
+ base_template_id: typing.Optional[str] = OMIT,
1223
+ identity_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1224
+ message_buffer_autoclear: typing.Optional[bool] = OMIT,
1225
+ enable_sleeptime: typing.Optional[bool] = OMIT,
1226
+ response_format: typing.Optional[CreateAgentRequestResponseFormat] = OMIT,
1227
+ timezone: typing.Optional[str] = OMIT,
1228
+ max_files_open: typing.Optional[int] = OMIT,
1229
+ per_file_view_window_char_limit: typing.Optional[int] = OMIT,
1230
+ request_options: typing.Optional[RequestOptions] = None,
1231
+ ) -> AsyncHttpResponse[AgentState]:
1232
+ """
1233
+ Create a new agent with the specified configuration.
1234
+
1235
+ Parameters
1236
+ ----------
1237
+ name : typing.Optional[str]
1238
+ The name of the agent.
1239
+
1240
+ memory_blocks : typing.Optional[typing.Sequence[CreateBlock]]
1241
+ The blocks to create in the agent's in-context memory.
1242
+
1243
+ tools : typing.Optional[typing.Sequence[str]]
1244
+ The tools used by the agent.
1245
+
1246
+ tool_ids : typing.Optional[typing.Sequence[str]]
1247
+ The ids of the tools used by the agent.
1248
+
1249
+ source_ids : typing.Optional[typing.Sequence[str]]
1250
+ The ids of the sources used by the agent.
1251
+
1252
+ block_ids : typing.Optional[typing.Sequence[str]]
1253
+ The ids of the blocks used by the agent.
1254
+
1255
+ tool_rules : typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]]
1256
+ The tool rules governing the agent.
1257
+
1258
+ tags : typing.Optional[typing.Sequence[str]]
1259
+ The tags associated with the agent.
1260
+
1261
+ system : typing.Optional[str]
1262
+ The system prompt used by the agent.
1263
+
1264
+ agent_type : typing.Optional[AgentType]
1265
+ The type of agent.
1266
+
1267
+ llm_config : typing.Optional[LlmConfig]
1268
+ The LLM configuration used by the agent.
1269
+
1270
+ embedding_config : typing.Optional[EmbeddingConfig]
1271
+ The embedding configuration used by the agent.
1272
+
1273
+ initial_message_sequence : typing.Optional[typing.Sequence[MessageCreate]]
1274
+ The initial set of messages to put in the agent's in-context memory.
1275
+
1276
+ include_base_tools : typing.Optional[bool]
1277
+ If true, attaches the Letta core tools (e.g. core_memory related functions).
1278
+
1279
+ include_multi_agent_tools : typing.Optional[bool]
1280
+ If true, attaches the Letta multi-agent tools (e.g. sending a message to another agent).
1281
+
1282
+ include_base_tool_rules : typing.Optional[bool]
1283
+ If true, attaches the Letta base tool rules (e.g. deny all tools not explicitly allowed).
1284
+
1285
+ include_default_source : typing.Optional[bool]
1286
+ If true, automatically creates and attaches a default data source for this agent.
1287
+
1288
+ description : typing.Optional[str]
1289
+ The description of the agent.
1290
+
1291
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1292
+ The metadata of the agent.
1293
+
1294
+ model : typing.Optional[str]
1295
+ The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
1296
+
1297
+ embedding : typing.Optional[str]
1298
+ The embedding configuration handle used by the agent, specified in the format provider/model-name.
1299
+
1300
+ context_window_limit : typing.Optional[int]
1301
+ The context window limit used by the agent.
1302
+
1303
+ embedding_chunk_size : typing.Optional[int]
1304
+ The embedding chunk size used by the agent.
1305
+
1306
+ max_tokens : typing.Optional[int]
1307
+ The maximum number of tokens to generate, including reasoning step. If not set, the model will use its default value.
1308
+
1309
+ max_reasoning_tokens : typing.Optional[int]
1310
+ The maximum number of tokens to generate for reasoning step. If not set, the model will use its default value.
1311
+
1312
+ enable_reasoner : typing.Optional[bool]
1313
+ Whether to enable internal extended thinking step for a reasoner model.
1314
+
1315
+ from_template : typing.Optional[str]
1316
+ The template id used to configure the agent
1317
+
1318
+ template : typing.Optional[bool]
1319
+ Whether the agent is a template
1320
+
1321
+ project : typing.Optional[str]
1322
+ Deprecated: Project should now be passed via the X-Project header instead of in the request body. If using the sdk, this can be done via the new x_project field below.
1323
+
1324
+ tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
1325
+ The environment variables for tool execution specific to this agent.
1326
+
1327
+ memory_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
1328
+ The variables that should be set for the agent.
1329
+
1330
+ project_id : typing.Optional[str]
1331
+ The id of the project the agent belongs to.
1332
+
1333
+ template_id : typing.Optional[str]
1334
+ The id of the template the agent belongs to.
1335
+
1336
+ base_template_id : typing.Optional[str]
1337
+ The base template id of the agent.
1338
+
1339
+ identity_ids : typing.Optional[typing.Sequence[str]]
1340
+ The ids of the identities associated with this agent.
1341
+
1342
+ message_buffer_autoclear : typing.Optional[bool]
1343
+ If set to True, the agent will not remember previous messages (though the agent will still retain state via core memory blocks and archival/recall memory). Not recommended unless you have an advanced use case.
1344
+
1345
+ enable_sleeptime : typing.Optional[bool]
1346
+ If set to True, memory management will move to a background agent thread.
1347
+
1348
+ response_format : typing.Optional[CreateAgentRequestResponseFormat]
1349
+ The response format for the agent.
1350
+
1351
+ timezone : typing.Optional[str]
1352
+ The timezone of the agent (IANA format).
1353
+
1354
+ max_files_open : typing.Optional[int]
1355
+ Maximum number of files that can be open at once for this agent. Setting this too high may exceed the context window, which will break the agent.
1356
+
1357
+ per_file_view_window_char_limit : typing.Optional[int]
1358
+ The per-file view window character limit for this agent. Setting this too high may exceed the context window, which will break the agent.
1359
+
1360
+ request_options : typing.Optional[RequestOptions]
1361
+ Request-specific configuration.
1362
+
1363
+ Returns
1364
+ -------
1365
+ AsyncHttpResponse[AgentState]
1366
+ Successful Response
1367
+ """
1368
+ _response = await self._client_wrapper.httpx_client.request(
1369
+ "v1/agents/",
1370
+ method="POST",
1371
+ json={
1372
+ "name": name,
1373
+ "memory_blocks": convert_and_respect_annotation_metadata(
1374
+ object_=memory_blocks, annotation=typing.Sequence[CreateBlock], direction="write"
1375
+ ),
1376
+ "tools": tools,
1377
+ "tool_ids": tool_ids,
1378
+ "source_ids": source_ids,
1379
+ "block_ids": block_ids,
1380
+ "tool_rules": convert_and_respect_annotation_metadata(
1381
+ object_=tool_rules, annotation=typing.Sequence[CreateAgentRequestToolRulesItem], direction="write"
1382
+ ),
1383
+ "tags": tags,
1384
+ "system": system,
1385
+ "agent_type": agent_type,
1386
+ "llm_config": convert_and_respect_annotation_metadata(
1387
+ object_=llm_config, annotation=LlmConfig, direction="write"
1388
+ ),
1389
+ "embedding_config": convert_and_respect_annotation_metadata(
1390
+ object_=embedding_config, annotation=EmbeddingConfig, direction="write"
1391
+ ),
1392
+ "initial_message_sequence": convert_and_respect_annotation_metadata(
1393
+ object_=initial_message_sequence, annotation=typing.Sequence[MessageCreate], direction="write"
1394
+ ),
1395
+ "include_base_tools": include_base_tools,
1396
+ "include_multi_agent_tools": include_multi_agent_tools,
1397
+ "include_base_tool_rules": include_base_tool_rules,
1398
+ "include_default_source": include_default_source,
1399
+ "description": description,
1400
+ "metadata": metadata,
1401
+ "model": model,
1402
+ "embedding": embedding,
1403
+ "context_window_limit": context_window_limit,
1404
+ "embedding_chunk_size": embedding_chunk_size,
1405
+ "max_tokens": max_tokens,
1406
+ "max_reasoning_tokens": max_reasoning_tokens,
1407
+ "enable_reasoner": enable_reasoner,
1408
+ "from_template": from_template,
1409
+ "template": template,
1410
+ "project": project,
1411
+ "tool_exec_environment_variables": tool_exec_environment_variables,
1412
+ "memory_variables": memory_variables,
1413
+ "project_id": project_id,
1414
+ "template_id": template_id,
1415
+ "base_template_id": base_template_id,
1416
+ "identity_ids": identity_ids,
1417
+ "message_buffer_autoclear": message_buffer_autoclear,
1418
+ "enable_sleeptime": enable_sleeptime,
1419
+ "response_format": convert_and_respect_annotation_metadata(
1420
+ object_=response_format, annotation=CreateAgentRequestResponseFormat, direction="write"
1421
+ ),
1422
+ "timezone": timezone,
1423
+ "max_files_open": max_files_open,
1424
+ "per_file_view_window_char_limit": per_file_view_window_char_limit,
1425
+ },
1426
+ headers={
1427
+ "content-type": "application/json",
1428
+ },
1429
+ request_options=request_options,
1430
+ omit=OMIT,
1431
+ )
1432
+ try:
1433
+ if 200 <= _response.status_code < 300:
1434
+ _data = typing.cast(
1435
+ AgentState,
1436
+ construct_type(
1437
+ type_=AgentState, # type: ignore
1438
+ object_=_response.json(),
1439
+ ),
1440
+ )
1441
+ return AsyncHttpResponse(response=_response, data=_data)
1442
+ if _response.status_code == 422:
1443
+ raise UnprocessableEntityError(
1444
+ headers=dict(_response.headers),
1445
+ body=typing.cast(
1446
+ HttpValidationError,
1447
+ construct_type(
1448
+ type_=HttpValidationError, # type: ignore
1449
+ object_=_response.json(),
1450
+ ),
1451
+ ),
1452
+ )
1453
+ _response_json = _response.json()
1454
+ except JSONDecodeError:
1455
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1456
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1457
+
1458
+ async def count(self, *, request_options: typing.Optional[RequestOptions] = None) -> AsyncHttpResponse[int]:
1459
+ """
1460
+ Get the count of all agents associated with a given user.
1461
+
1462
+ Parameters
1463
+ ----------
1464
+ request_options : typing.Optional[RequestOptions]
1465
+ Request-specific configuration.
1466
+
1467
+ Returns
1468
+ -------
1469
+ AsyncHttpResponse[int]
1470
+ Successful Response
1471
+ """
1472
+ _response = await self._client_wrapper.httpx_client.request(
1473
+ "v1/agents/count",
1474
+ method="GET",
1475
+ request_options=request_options,
1476
+ )
1477
+ try:
1478
+ if 200 <= _response.status_code < 300:
1479
+ _data = typing.cast(
1480
+ int,
1481
+ construct_type(
1482
+ type_=int, # type: ignore
1483
+ object_=_response.json(),
1484
+ ),
1485
+ )
1486
+ return AsyncHttpResponse(response=_response, data=_data)
1487
+ if _response.status_code == 422:
1488
+ raise UnprocessableEntityError(
1489
+ headers=dict(_response.headers),
1490
+ body=typing.cast(
1491
+ HttpValidationError,
1492
+ construct_type(
1493
+ type_=HttpValidationError, # type: ignore
1494
+ object_=_response.json(),
1495
+ ),
1496
+ ),
1497
+ )
1498
+ _response_json = _response.json()
1499
+ except JSONDecodeError:
1500
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1501
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1502
+
1503
+ async def export_file(
1504
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
1505
+ ) -> AsyncHttpResponse[str]:
1506
+ """
1507
+ Export the serialized JSON representation of an agent, formatted with indentation.
1508
+
1509
+ Parameters
1510
+ ----------
1511
+ agent_id : str
1512
+
1513
+ request_options : typing.Optional[RequestOptions]
1514
+ Request-specific configuration.
1515
+
1516
+ Returns
1517
+ -------
1518
+ AsyncHttpResponse[str]
1519
+ Successful Response
1520
+ """
1521
+ _response = await self._client_wrapper.httpx_client.request(
1522
+ f"v1/agents/{jsonable_encoder(agent_id)}/export",
1523
+ method="GET",
1524
+ request_options=request_options,
1525
+ )
1526
+ try:
1527
+ if 200 <= _response.status_code < 300:
1528
+ _data = typing.cast(
1529
+ str,
1530
+ construct_type(
1531
+ type_=str, # type: ignore
1532
+ object_=_response.json(),
1533
+ ),
1534
+ )
1535
+ return AsyncHttpResponse(response=_response, data=_data)
1536
+ if _response.status_code == 422:
1537
+ raise UnprocessableEntityError(
1538
+ headers=dict(_response.headers),
1539
+ body=typing.cast(
1540
+ HttpValidationError,
1541
+ construct_type(
1542
+ type_=HttpValidationError, # type: ignore
1543
+ object_=_response.json(),
1544
+ ),
1545
+ ),
1546
+ )
1547
+ _response_json = _response.json()
1548
+ except JSONDecodeError:
1549
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1550
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1551
+
1552
+ async def import_file(
1553
+ self,
1554
+ *,
1555
+ file: core.File,
1556
+ append_copy_suffix: typing.Optional[bool] = None,
1557
+ override_existing_tools: typing.Optional[bool] = None,
1558
+ project_id: typing.Optional[str] = None,
1559
+ strip_messages: typing.Optional[bool] = None,
1560
+ request_options: typing.Optional[RequestOptions] = None,
1561
+ ) -> AsyncHttpResponse[AgentState]:
1562
+ """
1563
+ Import a serialized agent file and recreate the agent in the system.
1564
+
1565
+ Parameters
1566
+ ----------
1567
+ file : core.File
1568
+ See core.File for more documentation
1569
+
1570
+ append_copy_suffix : typing.Optional[bool]
1571
+ If set to True, appends "_copy" to the end of the agent name.
1572
+
1573
+ override_existing_tools : typing.Optional[bool]
1574
+ If set to True, existing tools can get their source code overwritten by the uploaded tool definitions. Note that Letta core tools can never be updated externally.
1575
+
1576
+ project_id : typing.Optional[str]
1577
+ The project ID to associate the uploaded agent with.
1578
+
1579
+ strip_messages : typing.Optional[bool]
1580
+ If set to True, strips all messages from the agent before importing.
1581
+
1582
+ request_options : typing.Optional[RequestOptions]
1583
+ Request-specific configuration.
1584
+
1585
+ Returns
1586
+ -------
1587
+ AsyncHttpResponse[AgentState]
1588
+ Successful Response
1589
+ """
1590
+ _response = await self._client_wrapper.httpx_client.request(
1591
+ "v1/agents/import",
1592
+ method="POST",
1593
+ params={
1594
+ "append_copy_suffix": append_copy_suffix,
1595
+ "override_existing_tools": override_existing_tools,
1596
+ "project_id": project_id,
1597
+ "strip_messages": strip_messages,
1598
+ },
1599
+ data={},
1600
+ files={
1601
+ "file": file,
1602
+ },
1603
+ request_options=request_options,
1604
+ omit=OMIT,
1605
+ force_multipart=True,
1606
+ )
1607
+ try:
1608
+ if 200 <= _response.status_code < 300:
1609
+ _data = typing.cast(
1610
+ AgentState,
1611
+ construct_type(
1612
+ type_=AgentState, # type: ignore
1613
+ object_=_response.json(),
1614
+ ),
1615
+ )
1616
+ return AsyncHttpResponse(response=_response, data=_data)
1617
+ if _response.status_code == 422:
1618
+ raise UnprocessableEntityError(
1619
+ headers=dict(_response.headers),
1620
+ body=typing.cast(
1621
+ HttpValidationError,
1622
+ construct_type(
1623
+ type_=HttpValidationError, # type: ignore
1624
+ object_=_response.json(),
1625
+ ),
1626
+ ),
1627
+ )
1628
+ _response_json = _response.json()
1629
+ except JSONDecodeError:
1630
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1631
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1632
+
1633
+ async def retrieve(
1634
+ self,
1635
+ agent_id: str,
1636
+ *,
1637
+ include_relationships: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
1638
+ request_options: typing.Optional[RequestOptions] = None,
1639
+ ) -> AsyncHttpResponse[AgentState]:
1640
+ """
1641
+ Get the state of the agent.
1642
+
1643
+ Parameters
1644
+ ----------
1645
+ agent_id : str
1646
+
1647
+ include_relationships : typing.Optional[typing.Union[str, typing.Sequence[str]]]
1648
+ Specify which relational fields (e.g., 'tools', 'sources', 'memory') to include in the response. If not provided, all relationships are loaded by default. Using this can optimize performance by reducing unnecessary joins.
1649
+
1650
+ request_options : typing.Optional[RequestOptions]
1651
+ Request-specific configuration.
1652
+
1653
+ Returns
1654
+ -------
1655
+ AsyncHttpResponse[AgentState]
1656
+ Successful Response
1657
+ """
1658
+ _response = await self._client_wrapper.httpx_client.request(
1659
+ f"v1/agents/{jsonable_encoder(agent_id)}",
1660
+ method="GET",
1661
+ params={
1662
+ "include_relationships": include_relationships,
1663
+ },
1664
+ request_options=request_options,
1665
+ )
1666
+ try:
1667
+ if 200 <= _response.status_code < 300:
1668
+ _data = typing.cast(
1669
+ AgentState,
1670
+ construct_type(
1671
+ type_=AgentState, # type: ignore
1672
+ object_=_response.json(),
1673
+ ),
1674
+ )
1675
+ return AsyncHttpResponse(response=_response, data=_data)
1676
+ if _response.status_code == 422:
1677
+ raise UnprocessableEntityError(
1678
+ headers=dict(_response.headers),
1679
+ body=typing.cast(
1680
+ HttpValidationError,
1681
+ construct_type(
1682
+ type_=HttpValidationError, # type: ignore
1683
+ object_=_response.json(),
1684
+ ),
1685
+ ),
1686
+ )
1687
+ _response_json = _response.json()
1688
+ except JSONDecodeError:
1689
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1690
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1691
+
1692
+ async def delete(
1693
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
1694
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
1695
+ """
1696
+ Delete an agent.
1697
+
1698
+ Parameters
1699
+ ----------
1700
+ agent_id : str
1701
+
1702
+ request_options : typing.Optional[RequestOptions]
1703
+ Request-specific configuration.
1704
+
1705
+ Returns
1706
+ -------
1707
+ AsyncHttpResponse[typing.Optional[typing.Any]]
1708
+ Successful Response
1709
+ """
1710
+ _response = await self._client_wrapper.httpx_client.request(
1711
+ f"v1/agents/{jsonable_encoder(agent_id)}",
1712
+ method="DELETE",
1713
+ request_options=request_options,
1714
+ )
1715
+ try:
1716
+ if _response is None or not _response.text.strip():
1717
+ return AsyncHttpResponse(response=_response, data=None)
1718
+ if 200 <= _response.status_code < 300:
1719
+ _data = typing.cast(
1720
+ typing.Optional[typing.Any],
1721
+ construct_type(
1722
+ type_=typing.Optional[typing.Any], # type: ignore
1723
+ object_=_response.json(),
1724
+ ),
1725
+ )
1726
+ return AsyncHttpResponse(response=_response, data=_data)
1727
+ if _response.status_code == 422:
1728
+ raise UnprocessableEntityError(
1729
+ headers=dict(_response.headers),
1730
+ body=typing.cast(
1731
+ HttpValidationError,
1732
+ construct_type(
1733
+ type_=HttpValidationError, # type: ignore
1734
+ object_=_response.json(),
1735
+ ),
1736
+ ),
1737
+ )
1738
+ _response_json = _response.json()
1739
+ except JSONDecodeError:
1740
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1741
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1742
+
1743
+ async def modify(
1744
+ self,
1745
+ agent_id: str,
1746
+ *,
1747
+ name: typing.Optional[str] = OMIT,
1748
+ tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1749
+ source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1750
+ block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1751
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1752
+ system: typing.Optional[str] = OMIT,
1753
+ tool_rules: typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]] = OMIT,
1754
+ llm_config: typing.Optional[LlmConfig] = OMIT,
1755
+ embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
1756
+ message_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1757
+ description: typing.Optional[str] = OMIT,
1758
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1759
+ tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
1760
+ project_id: typing.Optional[str] = OMIT,
1761
+ template_id: typing.Optional[str] = OMIT,
1762
+ base_template_id: typing.Optional[str] = OMIT,
1763
+ identity_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1764
+ message_buffer_autoclear: typing.Optional[bool] = OMIT,
1765
+ model: typing.Optional[str] = OMIT,
1766
+ embedding: typing.Optional[str] = OMIT,
1767
+ enable_sleeptime: typing.Optional[bool] = OMIT,
1768
+ response_format: typing.Optional[UpdateAgentResponseFormat] = OMIT,
1769
+ last_run_completion: typing.Optional[dt.datetime] = OMIT,
1770
+ last_run_duration_ms: typing.Optional[int] = OMIT,
1771
+ timezone: typing.Optional[str] = OMIT,
1772
+ max_files_open: typing.Optional[int] = OMIT,
1773
+ per_file_view_window_char_limit: typing.Optional[int] = OMIT,
1774
+ request_options: typing.Optional[RequestOptions] = None,
1775
+ ) -> AsyncHttpResponse[AgentState]:
1776
+ """
1777
+ Update an existing agent
1778
+
1779
+ Parameters
1780
+ ----------
1781
+ agent_id : str
1782
+
1783
+ name : typing.Optional[str]
1784
+ The name of the agent.
1785
+
1786
+ tool_ids : typing.Optional[typing.Sequence[str]]
1787
+ The ids of the tools used by the agent.
1788
+
1789
+ source_ids : typing.Optional[typing.Sequence[str]]
1790
+ The ids of the sources used by the agent.
1791
+
1792
+ block_ids : typing.Optional[typing.Sequence[str]]
1793
+ The ids of the blocks used by the agent.
1794
+
1795
+ tags : typing.Optional[typing.Sequence[str]]
1796
+ The tags associated with the agent.
1797
+
1798
+ system : typing.Optional[str]
1799
+ The system prompt used by the agent.
1800
+
1801
+ tool_rules : typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]]
1802
+ The tool rules governing the agent.
1803
+
1804
+ llm_config : typing.Optional[LlmConfig]
1805
+ The LLM configuration used by the agent.
1806
+
1807
+ embedding_config : typing.Optional[EmbeddingConfig]
1808
+ The embedding configuration used by the agent.
1809
+
1810
+ message_ids : typing.Optional[typing.Sequence[str]]
1811
+ The ids of the messages in the agent's in-context memory.
1812
+
1813
+ description : typing.Optional[str]
1814
+ The description of the agent.
1815
+
1816
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1817
+ The metadata of the agent.
1818
+
1819
+ tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
1820
+ The environment variables for tool execution specific to this agent.
1821
+
1822
+ project_id : typing.Optional[str]
1823
+ The id of the project the agent belongs to.
1824
+
1825
+ template_id : typing.Optional[str]
1826
+ The id of the template the agent belongs to.
1827
+
1828
+ base_template_id : typing.Optional[str]
1829
+ The base template id of the agent.
1830
+
1831
+ identity_ids : typing.Optional[typing.Sequence[str]]
1832
+ The ids of the identities associated with this agent.
1833
+
1834
+ message_buffer_autoclear : typing.Optional[bool]
1835
+ If set to True, the agent will not remember previous messages (though the agent will still retain state via core memory blocks and archival/recall memory). Not recommended unless you have an advanced use case.
1836
+
1837
+ model : typing.Optional[str]
1838
+ The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
1839
+
1840
+ embedding : typing.Optional[str]
1841
+ The embedding configuration handle used by the agent, specified in the format provider/model-name.
1842
+
1843
+ enable_sleeptime : typing.Optional[bool]
1844
+ If set to True, memory management will move to a background agent thread.
1845
+
1846
+ response_format : typing.Optional[UpdateAgentResponseFormat]
1847
+ The response format for the agent.
1848
+
1849
+ last_run_completion : typing.Optional[dt.datetime]
1850
+ The timestamp when the agent last completed a run.
1851
+
1852
+ last_run_duration_ms : typing.Optional[int]
1853
+ The duration in milliseconds of the agent's last run.
1854
+
1855
+ timezone : typing.Optional[str]
1856
+ The timezone of the agent (IANA format).
1857
+
1858
+ max_files_open : typing.Optional[int]
1859
+ Maximum number of files that can be open at once for this agent. Setting this too high may exceed the context window, which will break the agent.
1860
+
1861
+ per_file_view_window_char_limit : typing.Optional[int]
1862
+ The per-file view window character limit for this agent. Setting this too high may exceed the context window, which will break the agent.
1863
+
1864
+ request_options : typing.Optional[RequestOptions]
1865
+ Request-specific configuration.
1866
+
1867
+ Returns
1868
+ -------
1869
+ AsyncHttpResponse[AgentState]
1870
+ Successful Response
1871
+ """
1872
+ _response = await self._client_wrapper.httpx_client.request(
1873
+ f"v1/agents/{jsonable_encoder(agent_id)}",
1874
+ method="PATCH",
1875
+ json={
1876
+ "name": name,
1877
+ "tool_ids": tool_ids,
1878
+ "source_ids": source_ids,
1879
+ "block_ids": block_ids,
1880
+ "tags": tags,
1881
+ "system": system,
1882
+ "tool_rules": convert_and_respect_annotation_metadata(
1883
+ object_=tool_rules, annotation=typing.Sequence[UpdateAgentToolRulesItem], direction="write"
1884
+ ),
1885
+ "llm_config": convert_and_respect_annotation_metadata(
1886
+ object_=llm_config, annotation=LlmConfig, direction="write"
1887
+ ),
1888
+ "embedding_config": convert_and_respect_annotation_metadata(
1889
+ object_=embedding_config, annotation=EmbeddingConfig, direction="write"
1890
+ ),
1891
+ "message_ids": message_ids,
1892
+ "description": description,
1893
+ "metadata": metadata,
1894
+ "tool_exec_environment_variables": tool_exec_environment_variables,
1895
+ "project_id": project_id,
1896
+ "template_id": template_id,
1897
+ "base_template_id": base_template_id,
1898
+ "identity_ids": identity_ids,
1899
+ "message_buffer_autoclear": message_buffer_autoclear,
1900
+ "model": model,
1901
+ "embedding": embedding,
1902
+ "enable_sleeptime": enable_sleeptime,
1903
+ "response_format": convert_and_respect_annotation_metadata(
1904
+ object_=response_format, annotation=UpdateAgentResponseFormat, direction="write"
1905
+ ),
1906
+ "last_run_completion": last_run_completion,
1907
+ "last_run_duration_ms": last_run_duration_ms,
1908
+ "timezone": timezone,
1909
+ "max_files_open": max_files_open,
1910
+ "per_file_view_window_char_limit": per_file_view_window_char_limit,
1911
+ },
1912
+ headers={
1913
+ "content-type": "application/json",
1914
+ },
1915
+ request_options=request_options,
1916
+ omit=OMIT,
1917
+ )
1918
+ try:
1919
+ if 200 <= _response.status_code < 300:
1920
+ _data = typing.cast(
1921
+ AgentState,
1922
+ construct_type(
1923
+ type_=AgentState, # type: ignore
1924
+ object_=_response.json(),
1925
+ ),
1926
+ )
1927
+ return AsyncHttpResponse(response=_response, data=_data)
1928
+ if _response.status_code == 422:
1929
+ raise UnprocessableEntityError(
1930
+ headers=dict(_response.headers),
1931
+ body=typing.cast(
1932
+ HttpValidationError,
1933
+ construct_type(
1934
+ type_=HttpValidationError, # type: ignore
1935
+ object_=_response.json(),
1936
+ ),
1937
+ ),
1938
+ )
1939
+ _response_json = _response.json()
1940
+ except JSONDecodeError:
1941
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1942
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1943
+
1944
+ async def summarize_agent_conversation(
1945
+ self, agent_id: str, *, max_message_length: int, request_options: typing.Optional[RequestOptions] = None
1946
+ ) -> AsyncHttpResponse[None]:
1947
+ """
1948
+ Summarize an agent's conversation history to a target message length.
1949
+
1950
+ This endpoint summarizes the current message history for a given agent,
1951
+ truncating and compressing it down to the specified `max_message_length`.
1952
+
1953
+ Parameters
1954
+ ----------
1955
+ agent_id : str
1956
+
1957
+ max_message_length : int
1958
+ Maximum number of messages to retain after summarization.
1959
+
1960
+ request_options : typing.Optional[RequestOptions]
1961
+ Request-specific configuration.
1962
+
1963
+ Returns
1964
+ -------
1965
+ AsyncHttpResponse[None]
1966
+ """
1967
+ _response = await self._client_wrapper.httpx_client.request(
1968
+ f"v1/agents/{jsonable_encoder(agent_id)}/summarize",
1969
+ method="POST",
1970
+ params={
1971
+ "max_message_length": max_message_length,
1972
+ },
1973
+ request_options=request_options,
1974
+ )
1975
+ try:
1976
+ if 200 <= _response.status_code < 300:
1977
+ return AsyncHttpResponse(response=_response, data=None)
1978
+ if _response.status_code == 422:
1979
+ raise UnprocessableEntityError(
1980
+ headers=dict(_response.headers),
1981
+ body=typing.cast(
1982
+ HttpValidationError,
1983
+ construct_type(
1984
+ type_=HttpValidationError, # type: ignore
1985
+ object_=_response.json(),
1986
+ ),
1987
+ ),
1988
+ )
1989
+ _response_json = _response.json()
1990
+ except JSONDecodeError:
1991
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1992
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1993
+
1994
+ async def search(
1995
+ self,
1996
+ *,
1997
+ search: typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]] = OMIT,
1998
+ project_id: typing.Optional[str] = OMIT,
1999
+ combinator: typing.Optional[typing.Literal["AND"]] = OMIT,
2000
+ limit: typing.Optional[float] = OMIT,
2001
+ after: typing.Optional[str] = OMIT,
2002
+ sort_by: typing.Optional[AgentsSearchRequestSortBy] = OMIT,
2003
+ ascending: typing.Optional[bool] = OMIT,
2004
+ request_options: typing.Optional[RequestOptions] = None,
2005
+ ) -> AsyncHttpResponse[AgentsSearchResponse]:
2006
+ """
2007
+ <Note>This endpoint is only available on Letta Cloud.</Note>
2008
+
2009
+ Search deployed agents.
2010
+
2011
+ Parameters
2012
+ ----------
2013
+ search : typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]]
2014
+
2015
+ project_id : typing.Optional[str]
2016
+
2017
+ combinator : typing.Optional[typing.Literal["AND"]]
2018
+
2019
+ limit : typing.Optional[float]
2020
+
2021
+ after : typing.Optional[str]
2022
+
2023
+ sort_by : typing.Optional[AgentsSearchRequestSortBy]
2024
+
2025
+ ascending : typing.Optional[bool]
2026
+
2027
+ request_options : typing.Optional[RequestOptions]
2028
+ Request-specific configuration.
2029
+
2030
+ Returns
2031
+ -------
2032
+ AsyncHttpResponse[AgentsSearchResponse]
2033
+ 200
2034
+ """
2035
+ _response = await self._client_wrapper.httpx_client.request(
2036
+ "v1/agents/search",
2037
+ method="POST",
2038
+ json={
2039
+ "search": convert_and_respect_annotation_metadata(
2040
+ object_=search, annotation=typing.Sequence[AgentsSearchRequestSearchItem], direction="write"
2041
+ ),
2042
+ "project_id": project_id,
2043
+ "combinator": combinator,
2044
+ "limit": limit,
2045
+ "after": after,
2046
+ "sortBy": sort_by,
2047
+ "ascending": ascending,
2048
+ },
2049
+ headers={
2050
+ "content-type": "application/json",
2051
+ },
2052
+ request_options=request_options,
2053
+ omit=OMIT,
2054
+ )
2055
+ try:
2056
+ if 200 <= _response.status_code < 300:
2057
+ _data = typing.cast(
2058
+ AgentsSearchResponse,
2059
+ construct_type(
2060
+ type_=AgentsSearchResponse, # type: ignore
2061
+ object_=_response.json(),
2062
+ ),
2063
+ )
2064
+ return AsyncHttpResponse(response=_response, data=_data)
2065
+ _response_json = _response.json()
2066
+ except JSONDecodeError:
2067
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2068
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)