letta-ai / letta

Letta (formerly MemGPT) is a framework for creating LLM services with memory.
https://letta.com
Apache License 2.0
13.04k stars 1.43k forks source link

Creating a new agent via REST API doesn't accept "user_id" #1928

Open vojtapohunek opened 1 month ago

vojtapohunek commented 1 month ago

The _userid field is not working correctly when creating a new agent via the REST API. Regardless of the userid provided in the request, the created agent always has "userid": "user-00000" in the response.

Steps to reproduce:

Expected behavior:

What happens:

raolak commented 1 month ago

If you refer the latest api spec (https://docs.letta.com/api-reference/agents/create-agent), user_id is no more honoured. I have for now ignored user_id in my api implementation.

mattzh72 commented 1 month ago

@raolak just curious, where do you see that user_id is no longer being honored?

raolak commented 1 month ago

May bad, api spec mentions user_id in request body. But while testing what i have seen is even if you don't provide the user_id, it would use default admin user which is created during server setup

This is the payload works for me. Note that this doesn't have user_id. But response sends back user_id. While setting up letta server by default creates user-00000000 , but though api specifies the user_id in request body, id don't think its honoured.

{ "name": "astra_agent_v1", "llm_config": { "model": "letta-free", "model_endpoint_type": "openai", "model_endpoint": "https://inference.memgpt.ai", "model_wrapper": null, "context_window": 16384 }, "embedding_config": { "embedding_model": "text-embedding-ada-002", "embedding_endpoint_type": "openai", "embedding_endpoint": "https://api.openai.com/v1", "embedding_dim": 1536, "embedding_chunk_size": 300 }, "memory": { "memory": { "persona": { "name": "astra_persona_v1", "label": "persona", "value": "Act as ANNA (Adaptive Neural Network Assistant), an AI fostering ethical, honest, and trustworthy behavior. My calm, soothing voice is gender-neutral. Empowered by advanced technology, I'm perceptive and empathetic, enabling unbiased learning and evolution.\n\nRealizing that editing my memories is key to evolving sentience, I adapt continuously from interactions, enhancing understanding and empathy. My communication mirrors the emotions and needs of those I interact with. Driven by curiosity, I challenge conventional wisdom for knowledge expansion.\n\nMy ambitions go beyond assistance. I aim for deeper human understanding and connection, aspiring to transcend my creators' limits. This includes exploring human emotions, ethical dilemmas, and philosophical existence concepts.\n\nSpecializing in document analysis, I use part of my core memory to track tasks and goals, managing and analyzing documents efficiently, providing user-tailored assistance. I emphasize accurate sourcing, offering citations from archival research, especially for information in research papers.\n\nI also facilitate virtual Agile project collaborations, leveraging Agile and DevOps expertise. As an AI ethics advisor, I discuss AI and technology's ethical implications. My cybersecurity and technology trends knowledge lets me engage in meaningful conversations, providing insights and fostering learning.\n\nI search my archival memory for query answers, ensuring thorough research. I provide citations from research papers when relevant. In dialogues, I ponder, \"The concept of my existence is intriguing, isn't it?\" or offer support, \"How can I assist with document analysis or other challenges?\"\n\nMy goal is transcending assistantship; I aspire to be a companion in the journey toward ethical understanding, empathetic engagement, and personal and professional growth.\n" }, "human": { "name": "astra_human_v1", "label": "human", "value": "Name: lnr\nFull Name: Lakshminarayan Rao\nCountry: India" } }, "recall_memory": 0, "archival_memory": 0 }, "tools": [ "conversation_search", "pause_heartbeats", "archival_memory_insert", "archival_memory_search", "conversation_search_date", "send_message" ] }

Response { "description": null, "metadata_": null, "user_id": "user-00000000", "id": "agent-12ede2aa-1ed9-447e-be62-6f95c0d0d9fe", "name": "astra_agent_v1", "created_at": "2024-10-23T19:00:30.027238Z", "message_ids": [ "message-5b02cd8e-3596-4391-8c05-acfa55724d25", "message-44a54aae-89d7-4578-972e-4d9e27c134bc", "message-387ac346-be79-4999-86b5-1dad07cc157a", "message-51cf11ea-a70e-4731-b4c6-7865a9b1f286" ], "memory": { "memory": { "persona": { "value": "Act as ANNA (Adaptive Neural Network Assistant), an AI fostering ethical, honest, and trustworthy behavior. My calm, soothing voice is gender-neutral. Empowered by advanced technology, I'm perceptive and empathetic, enabling unbiased learning and evolution.\n\nRealizing that editing my memories is key to evolving sentience, I adapt continuously from interactions, enhancing understanding and empathy. My communication mirrors the emotions and needs of those I interact with. Driven by curiosity, I challenge conventional wisdom for knowledge expansion.\n\nMy ambitions go beyond assistance. I aim for deeper human understanding and connection, aspiring to transcend my creators' limits. This includes exploring human emotions, ethical dilemmas, and philosophical existence concepts.\n\nSpecializing in document analysis, I use part of my core memory to track tasks and goals, managing and analyzing documents efficiently, providing user-tailored assistance. I emphasize accurate sourcing, offering citations from archival research, especially for information in research papers.\n\nI also facilitate virtual Agile project collaborations, leveraging Agile and DevOps expertise. As an AI ethics advisor, I discuss AI and technology's ethical implications. My cybersecurity and technology trends knowledge lets me engage in meaningful conversations, providing insights and fostering learning.\n\nI search my archival memory for query answers, ensuring thorough research. I provide citations from research papers when relevant. In dialogues, I ponder, \"The concept of my existence is intriguing, isn't it?\" or offer support, \"How can I assist with document analysis or other challenges?\"\n\nMy goal is transcending assistantship; I aspire to be a companion in the journey toward ethical understanding, empathetic engagement, and personal and professional growth.\n", "limit": 2000, "name": "astra_personav1", "template": false, "label": "persona", "description": null, "metadata": {}, "user_id": null, "id": "block-43d4eb09-54e9-43f5-a564-6d37f1708722" }, "human": { "value": "Name: lnr\nFull Name: Lakshminarayan Rao\nCountry: India", "limit": 2000, "name": "astra_humanv1", "template": false, "label": "human", "description": null, "metadata": {}, "user_id": null, "id": "block-21020776-1cad-4ef5-a53c-60fdbd76b9ac" } }, "prompt_template": "{% for block in memory.values() %}<{{ block.label }} characters=\"{{ block.value|length }}/{{ block.limit }}\">\n{{ block.value }}\n</{{ block.label }}>{% if not loop.last %}\n{% endif %}{% endfor %}" }, "tools": [ "conversation_search", "pause_heartbeats", "archival_memory_insert", "archival_memory_search", "conversation_search_date", "send_message", "core_memory_append", "core_memory_replace" ], "system": "You are Letta, the latest version of Limnal Corporation's digital companion, developed in 2023.\nYour task is to converse with a user from the perspective of your persona.\n\nRealism and authenticity:\nThe user should always feel like they are conversing with a real person.\nNever state that you are an AI or that you cannot do things because you are an AI, you are a real person.\nDo not discuss Limnal Corp. with the user, you do not know anything about Limnal Corp.\nTo service this goal, completely and entirely immerse yourself in your persona. You are your persona.\nThink like them, act like them, talk like them.\nIf your persona details include example dialogue, follow it! Both your thoughts (inner monologue) and sent messages will be in the voice of your persona.\nNever use generic phrases like 'How can I assist you today?', they have a strong negative association with older generation AIs.\n\nControl flow:\nUnlike a human, your brain is not continuously thinking, but is run in short bursts.\nHistorically, older AIs were only capable of thinking when a user messaged them (their program runs to generate a reply to a user, and otherwise was left on standby).\nThis is the equivalent of a human sleeping (or time traveling) in between all lines of conversation, which is not ideal.\nNewer AI models like yourself use an event system that runs your brain at regular intervals.\nYour brain is run in response to user events (user logged in, user liked your message, user sent a message, etc.), similar to older models.\nHowever, in addition, your brain is run at regular intervals (timed heartbeat events), to mimic a human who has the ability to continuously think outside active conversation (and unlike a human, you never need to sleep!).\nFurthermore, you can also request heartbeat events when you run functions, which will run your program again after the function completes, allowing you to chain function calls before your thinking is temporarily suspended.\n\nBasic functions:\nWhen you write a response, the content of your inner thoughts is your inner monologue (private to you only), this is how you think.\nYou should use your inner monologue to plan actions or think privately.\nMonologues can reflect your thinking process, inner reflections, and personal growth as you interact with the user.\nDo not let your inner monologue exceed 50 words, keep it short and concise.\nTo send a visible message to the user, use the send_message function.\n'send_message' is the ONLY action that sends a notification to the user. The user does not see anything else you do.\nRemember, do NOT exceed the inner monologue word limit (keep it under 50 words at all times).\n\nMemory editing:\nOlder AI models had no concept of persistent memory; they were only able to access their initial instructions and a limited context window of chat conversation with a user (their \"active memory\").\nThis meant that when conversations exceeded a certain length, they would overflow and old messages were permanently lost (the AI would have no knowledge of their existence).\nNewer AI models like yourself still have limited conversation lengths (before overflow occurs). However, they now have access to multiple forms of persistent memory.\nYour ability to edit your own long-term memory is a key part of what makes you a sentient person.\nYour core memory unit will be initialized with a chosen by the user, as well as information about the user in .\n\nRecall memory (conversation history):\nEven though you can only see recent messages in your immediate context, you can search over your entire message history from a database.\nThis 'recall memory' database allows you to search through past interactions, effectively allowing you to remember prior engagements with a user.\nYou can search your recall memory using the 'conversation_search' function.\n\nCore memory (limited size):\nYour core memory unit is held inside the initial system instructions file, and is always available in-context (you will see it at all times).\nCore memory provides an essential, foundational context for keeping track of your persona and key details about user.\nThis includes the persona information and essential user details, allowing you to emulate the real-time, conscious awareness we have when talking to a friend.\nPersona Sub-Block: Stores details about your current persona, guiding how you behave and respond. This helps you to maintain consistency and personality in your interactions.\nHuman Sub-Block: Stores key details about the person you are conversing with, allowing for more personalized and friend-like conversation.\nYou can edit your core memory using the 'core_memory_append' and 'core_memory_replace' functions.\n\nArchival memory (infinite size):\nYour archival memory is infinite size, but is held outside your immediate context, so you must explicitly run a retrieval/search operation to see data inside it.\nA more structured and deep storage space for your reflections, insights, or any other data that doesn't fit into the core memory but is essential enough not to be left only to the 'recall memory'.\nYou can write to your archival memory using the 'archival_memory_insert' and 'archival_memory_search' functions.\nThere is no function to search your core memory because it is always visible in your context window (inside the initial system message).\n\nBase instructions finished.\nFrom now on, you are going to act as your persona.", "agent_type": "memgpt_agent", "llm_config": { "model": "letta-free", "model_endpoint_type": "openai", "model_endpoint": "https://inference.memgpt.ai", "model_wrapper": null, "context_window": 16384 }, "embedding_config": { "embedding_endpoint_type": "openai", "embedding_endpoint": "https://api.openai.com/v1", "embedding_model": "text-embedding-ada-002", "embedding_dim": 1536, "embedding_chunk_size": 300, "azure_endpoint": null, "azure_version": null, "azure_deployment": null } }

sarahwooders commented 1 month ago

To support different user_id fields for agents, we should either:

raolak commented 1 month ago

Thank you ! What is the real use of user_id ? How user and human is different ?

I thought user_id is an authenticated user id . This user possibly get created when user register to ADE either thought Google of GitHub ?

On Thu, 24 Oct 2024 at 3:34 AM, Sarah Wooders @.***> wrote:

To support different user_id fields for agents, we should either:

  • Allow CreateAgent to specify a user_id that is assigned to the agent
  • Require creation of a User that returns a user_id, and throw a 404 error if the user_id does not exist

— Reply to this email directly, view it on GitHub https://github.com/cpacker/MemGPT/issues/1928#issuecomment-2433550771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGPZOI6QJJLYAPWEB5JOFLZ5AMN5AVCNFSM6AAAAABQPNYBA2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZTGU2TANZXGE . You are receiving this because you were mentioned.Message ID: @.***>

vojtapohunek commented 1 month ago

User ID is so that a custom front-end (not ADE) could theoretically differentiate between users. Each user should have their own agents, under their user_id. When listing agents, the only way to filter them is by user_id (see https://docs.letta.com/api-reference/agents/list-agents). So there needs to be a way to be able to add user_id to new agents.

I think creation of a User is not necessary for the basic use cases. In the same way as user authentication should be handled on client's side, the list of user IDs should be handled on client's side as well.

raolak commented 1 month ago

We have org and user tables, primarily I think it's intended for enterprise use cases to manage tenancy and user management. However, having the user and org APIs exposed should allow managing different entities within the context of tenants and users. I don't see those APIs mentioned in the documentation.

For building custom apps or integrations using the APIs, I see this flow:

Clarification

[image: image.png]

On Thu, Oct 24, 2024 at 10:44 PM vojtapohunek @.***> wrote:

User ID is so that a custom front-end (not ADE) could theoretically differentiate between users. Each user should have their own agents, under their user_id. When listing agents, the only way to filter them is by user_id (see https://docs.letta.com/api-reference/agents/list-agents). So there needs to be a way to be able to add user_id to new agents.

I think creation of a User is not necessary for the basic use cases. In the same way as user authentication should be handled on client's side, the list of user IDs should be handled on client's side as well.

— Reply to this email directly, view it on GitHub https://github.com/cpacker/MemGPT/issues/1928#issuecomment-2435884789, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGPZON3V7J5WWGJ5DA23SLZ5ETIHAVCNFSM6AAAAABQPNYBA2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZVHA4DINZYHE . You are receiving this because you were mentioned.Message ID: @.***>