RFC: Support for bidirectional communication (prompting the user)
Pwuts opened this issue · comments
The protocol currently supports making requests to an agent service. However, some agents may need to be able to communicate with the user in order to function optimally. For example:
- User: please buy me a new set of cutting boards
- AI: would you like wooden or plastic cutting boards?
- User: I like wood
- AI: searches for wooden cutting boards and places an order on Amazon
Adding a way for agents to prompt the user would greatly increase the versatility of the protocol imo.
Proposal
Two primary options:
-
Extension of the protocol with a status
awaiting_input
, and a way to resolve this status with additional input for an existing task or step -
Extension of the
task
endpoint with acallback
(or similar) attribute through which a client can specify a callback URL which may be polled with prompts for the user until they are resolved.
Example:- Giving the agent a task
POST /agent/tasks { "input": "Please find a nice olive wood cutting board on Amazon and order it for me.", "callback_url": "https://my-service.url/agents/203820/callbacks" }
- The agent wants more info
POST https://my-service.url/agents/203820/callbacks { "prompt": "What is your budget for this purchase?" }
{ "prompt_id": 123, "status": "pending", "created": "2023-08-23T13:49:51.141Z", "last_updated": "2023-08-23T13:49:51.141Z" }
- The agent polls the client until the prompt is resolved
GET https://my-service.url/agents/203820/callbacks/123
Responses:
{ "prompt_id": 123, "status": "pending", "created": "2023-08-23T13:49:51.141Z", "last_updated": "2023-08-23T13:49:51.141Z" }
{ "prompt_id": 123, "status": "resolved", "answer": "I don't want to spend more than €40 on this purchase", "created": "2023-08-23T13:49:51.141Z", "last_updated": "2023-08-23T13:53:12.634Z", }
{ "prompt_id": 123, "status": "rejected", "created": "2023-08-23T13:49:51.141Z", "last_updated": "2023-08-23T13:53:12.634Z", }
Alternatives
- Extending the protocol with full chatting capabilities:
-
GET /agent/tasks/<task_id>/chats
List chats regarding task<task_id>
-
POST /agent/tasks/<task_id>/chats
Start a new chat regarding task<task_id>
-
POST /agent/tasks/<task_id>/chats/<chat_id>/messages
Post a new message in an existing chat -
GET /agent/tasks/<task_id>/chats/<chat_id>/messages
Get all messages in a chat -
POST /agent/tasks/<task_id>/chats/<chat_id>/close
Close/resolve a chat
-
Interesting, I feel like chats are better implemented with websockets - What do you think? @jzanecook
This might be one of the perfect examples for a plugin referencing #71 since it's something that not all agents might have.
Can you attend a meeting the Agent protocol meeting on the 12th to discuss this?