Support for Stateful Agents #322
Replies: 8 comments
-
I don't think this statement holds exactly true. Appropriate transport mechanism must be used and that is indeed critical but statefulness/statelessness of the agents layer has little to do with it. One can achieve stateful agents even with a simple REST API. |
Beta Was this translation helpful? Give feedback.
-
|
Comparing current (template) with the alternative (session) approach. They are quite identical in many aspects:
I personally like the alternative approach better since it fairly simplifies the protocol. However, we must figure out the destruction mechanism. |
Beta Was this translation helpful? Give feedback.
-
|
Shifting gears a bit. Up until now we were mostly thinking (at least I was) about user-managed stateful agents. What about agent-managed stateful agents?
As an example, we could make memory as a standalone ACP feature. Stateful agents could be instantiated with a reference to such memory (now a simple sessionId starts to break down a bit). It would then be possible to interact with the memory between agent runs. |
Beta Was this translation helpful? Give feedback.
-
|
I skimmed through the modelcontextprotocol/modelcontextprotocol#102 so here are my two cents. The problem statement is as follows:
Basically saying that stateful connections are problems for replication and load balancing. I'd say we have to ask ourselves if these two things are desirable for the ACP. Should it be made to handle thousands of connections? In a P2P setup, this probably won't be the case. Also, such horizontal scaling would complicate not only transport but also agent implementation, moving in the direction of something quite complex (like a job-backed service with redis as centralized authority) to ensure consistency across load balancing. |
Beta Was this translation helpful? Give feedback.
-
|
These are important questions to tackle. Using websocket feels like the natural choice to me for supporting agent-to-agent communication in a safe, reliable and efficient manner. It also follows the MCP standard. Whether agent communication requires statefullness would depend on the use case. There may or may not be a need for the receiving agent to have data available to them for performing their actions. And there might be a need for the requesting agent to know of the state of the other agent. I don't think that session ID sufficiently captures the requirements of what kind of states agents need to be aware of each other? This could well be a requirement if using simple REST calls, because the communication exchange is by its very definition stateless and requires an "injection" of state, whereas Websocket establishes a realtime communication channel. In summary, I think that we should add more examples of the type of states agents might have to be aware of, use Websocket and request/confirm the type of states to be exchanged when establishing the connection. Food for thought! |
Beta Was this translation helpful? Give feedback.
-
|
Thank you @pilartomas and @bjornslib for the discussion. The latest draft of ACP Alpha spec moved towards REST for the transport (eventually with SSE support for streaming). While websockets are still on our radar (and might be a natural evolution in terms of progressive enhancement), we believe that the protocol should start with the simplest and most scalable transport, which is stateless request-response. Statefulness would be supported through |
Beta Was this translation helpful? Give feedback.
-
|
Do we need to think about multi-tenancy here? For example, in a multi-agent system where agents A and B are both communicating with Z: graph TD;
A<-->Z;
B<-->Z;
Do we have safeguards baked in to prevent Z from telling B about A? Or would we need to run separate instances of Z to prevent leakage, something like: graph TD;
A<-->Z1;
B<-->Z2;
|
Beta Was this translation helpful? Give feedback.
-
|
Given that the new version of ACP has separated from BeeAI Platform and now includes a support for stateful agents, I think it's fair to close this discussion. Feel free to reopen in ACP's repo: https://github.com/i-am-bee/acp/discussions. New docs site for ACP is available here: https://agentcommunicationprotocol.dev. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
Supporting both stateless and stateful agents enables ACP to handle a broader range of use cases, particularly complex or long-lived interactions requiring persistent context. Such agents can offer more natural, efficient, and sophisticated user experiences. The following are some agent examples:
supervisor: A long-lived agent managing multi-step tasks.Stateless vs Stateful Agents
Problem
ACP in Pre-alpha supports both stateful and stateless agents. Stateful agents utilize agent templates, but this feature is currently undocumented. The transport mechanisms (e.g., SSE, WebSockets) inherently maintain stateful connections, raising questions about the adequacy and clarity of the existing implementation. This implementation must be clearly evaluated and documented.
Selecting appropriate transport mechanisms is critical. Incorporating stateful behavior should not overly complicate ACP nor compromise its scalability and performance.
Current Stateless Implementation
The agent author provides a single method to instantiate, run, and destroy an agent:
{ "id": "msg-001", "jsonrpc": "2.0", "method": "agents/run", "params": { "name": "agent-name", "input": { "prompt": "Hello world" } } }Current Stateful Implementation
The agent author provides three separate methods:
create,runanddestroyof an agent. Thecreatemethod returns an instance ID, generated by the agent provider. Therunmethod can be called repeatedly.Create:
{ "id": "msg-001", "jsonrpc": "2.0", "method": "agents/create", "params": { "templateName": "agent-name", "config": {} } }Run:
{ "id": "msg-002", "jsonrpc": "2.0", "method": "agents/run", "params": { "name": "agent-name-001", "input": { "prompt": "Hello world" } } }Destroy:
{ "id": "msg-003", "jsonrpc": "2.0", "method": "agents/destroy", "params": { "name": "agent-name-001" } }Open Questions
Alternative Proposal
Passing
sessionIdthrough_metaobject.{ "id": "msg-001", "jsonrpc": "2.0", "method": "agents/run", "params": { "name": "agent-name", "input": { "prompt": "Hello world" }, "_meta": { "sessionId": "session-123" } } }Goal
ACP should flexibly support stateful and stateless agents while maintaining simplicity and scalability.
Specifically, ACP should:
Additional Resources
Call to action
Beta Was this translation helpful? Give feedback.
All reactions