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