agent-protocol icon indicating copy to clipboard operation
agent-protocol copied to clipboard

RFC: Support for bidirectional communication (prompting the user)

Open Pwuts opened this issue 2 years ago • 3 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:

  1. User: please buy me a new set of cutting boards
  2. AI: would you like wooden or plastic cutting boards?
  3. User: I like wood
  4. 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:

  1. 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

  2. Extension of the task endpoint with a callback (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:

    1. 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"
    }
    
    1. 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"
    }
    
    1. 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

Pwuts avatar Aug 23 '23 09:08 Pwuts

Interesting, I feel like chats are better implemented with websockets - What do you think? @jzanecook

hackgoofer avatar Sep 21 '23 01:09 hackgoofer

This might be one of the perfect examples for a plugin referencing #71 since it's something that not all agents might have.

jzanecook avatar Sep 21 '23 02:09 jzanecook

Can you attend a meeting the Agent protocol meeting on the 12th to discuss this?

ntindle avatar Dec 05 '23 17:12 ntindle