Skip to content

Commit 9e04a53

Browse files
aduminucmtrinell
andauthored
V0.2 ap (#36)
* feat: start from AP in JSON format * feat: ACP update on top of AP * fix: remove additionalProperties * docs: update docs for 0.2 * fix: add 409 * fix: improve description for blocking runs and Record URL * fix: resume_stateless_run operationId * fix: change operationId for resume_thread_run --------- Co-authored-by: Marco Trinelli (mtrinell) <mtrinell@cisco.com>
1 parent cad602c commit 9e04a53

File tree

5 files changed

+3059
-1530
lines changed

5 files changed

+3059
-1530
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ See [ACP Documentation](https://agntcy.github.io/acp-spec)
2020

2121
See [IoA Documentation](https://docs.agntcy.org) for more info on Internet of Agents.
2222

23-
See ACP specification in [YAML Format](openapi.yaml) or browse its [OpenAPI visualization](https://agntcy.github.io/acp-spec/docs/openapi.html)
23+
See ACP specification in [JSON Format](openapi.json) or browse its [OpenAPI visualization](https://agntcy.github.io/acp-spec/docs/openapi.html)
2424

2525

2626
## Roadmap

docs/README.md

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ sequenceDiagram
6666
C->>+S: GET /runs/{run_id}
6767
S->>-C: Run={run_id, status}
6868
end
69-
C->>+S: GET /runs/{run_id}/output
69+
C->>+S: GET /runs/{run_id}/wait
7070
S->>-C: RunOutput={type="result", result}
7171
```
7272
In the sequence above:
@@ -77,7 +77,7 @@ In the sequence above:
7777
1. The server returns a run object which includes the run identifier and a status, the status at the beginning will be `pending`.
7878
1. The client retrieves the status of the run until completion.
7979
1. The server returns the run object with the updated status.
80-
1. The client request the output of the run.
80+
1. The client request the output of the run with the `wait` endpoint, which returns immediately, since the run is done.
8181
1. The server returns the final result of the run.
8282

8383
>
@@ -93,14 +93,14 @@ sequenceDiagram
9393
participant S as ACP Server
9494
C->>+S: POST /runs {agent_id, input, config, metadata}
9595
S->>-C: Run={run_id, status="pending"}
96-
C->>+S: GET /runs/{run_id}/output {"block_timeout"=60}
96+
C->>+S: GET /runs/{run_id}/wait
9797
S->>-C: RunOutput={type="result", result}
9898
```
9999

100100
In the sequence above:
101101
1. The client requests to start a run on a specific agent.
102102
1. The server returns a run object.
103-
1. The client request the output of the run providing additional `block_timeout` parameter, and blocks until run status changes or timeout expires.
103+
1. The client request the output of the run with the `wait` endpoint. In this case the request and blocks until run status changes.
104104
1. The server returns the final result of the run. Note that in case the timeout had expired before, the server would have returned no content.
105105

106106
#### Start a Run of an Agent with a callback
@@ -115,14 +115,14 @@ sequenceDiagram
115115
C->>+S: POST /runs {agent_id, input, config, metadata, callback={POST /callme}}
116116
S->>-C: Run={run_id, status="pending"}
117117
S->>C: POST /callme Run={run_id, status="success"}
118-
C->>+S: GET /runs/{run_id}/output
118+
C->>+S: GET /runs/{run_id}/wait
119119
S->>-C: RunOutput={type="result", result}
120120
```
121121
In the sequence above:
122122
1. The client requests to start a run on a specific agent, providing an additional `callback`.
123123
1. The server returns a run object.
124124
1. Upon status change, the server calls the provided call back with the run object.
125-
1. The client request the output of the run.
125+
1. The client request the output of the run with the `wait` endpoint, which returns immediately, since the run is done.
126126
1. The server return the final result of the run.
127127

128128
### Run Interrupt and Resume
@@ -148,12 +148,12 @@ sequenceDiagram
148148
participant S as ACP Server
149149
C->>+S: POST /runs {agent_id, input, config, metadata}
150150
S->>-C: Run={run_id, status="pending"}
151-
C->>+S: GET /runs/{run_id}/output {"block_timeout"=60}
151+
C->>+S: GET /runs/{run_id}/wait
152152
S->>-C: RunOutput={type="interrupt", interrupt_type, interrupt_payload}
153153
note over C: collect needed input
154154
C->>+S: POST /runs/{run_id} {interrupt_type, resume_payload}
155155
S->>-C: Run={run_id, status="pending"}
156-
C->>+S: GET /runs/{run_id}/output
156+
C->>+S: GET /runs/{run_id}/wait
157157
S->>-C: RunOutput={type="result", result}
158158
```
159159
In the sequence above:
@@ -174,6 +174,8 @@ Subsequent runs on the same thread use the previously created state, together wi
174174

175175
The server offers ways to retrieve the current thread state, the history of the runs on a thread, and the evolution of the thread states over execution of runs.
176176

177+
Runs over the same thread can be executed on different agents, as long as the agents support the same thread state format.
178+
177179
>
178180
> Note that the format of the thread state is not specified by ACP, but it is (optionally) defined in the agent ACP descriptor. If specified, it can be retrieved by the client, if not it's not accessible to the client.
179181
>
@@ -186,45 +188,47 @@ sequenceDiagram
186188
participant C as ACP Client
187189
participant S as ACP Server
188190
rect rgb(240,240,240)
189-
C->>+S: POST /runs {agent_id, message="Hello, my name is John?", config, metadata}
190-
S->>-C: Run={run_id, status="pending", thread_id}
191-
C->>+S: GET /runs/{run_id}/output {"block_timeout"=60}
191+
C->>+S: POST /threads
192+
S->>-C: Thread={thread_id, status="idle"}
193+
C->>+S: POST /threads/{thread_id}/runs {agent_id, message="Hello, my name is John?", config, metadata}
194+
S->>-C: Run={run_id, status="pending"}
195+
C->>+S: GET /threads/{thread_id}/runs/{run_id}/wait
192196
S->>-C: RunOutput={type="result", result={"message"="Hello John, how can I help?"}}
193197
end
194198
note right of S: state=[<br/>"Hello, my name is John?",<br/>"Hello John, how can I help?"<br/>]
195199
rect rgb(240,240,240)
196-
C->>+S: POST /runs {agent_id, message="Can you remind my name?", config, metadata, thread_id}
197-
S->>-C: Run={run_id, status="pending", thread_id}
198-
C->>+S: GET /runs/{run_id}/output {"block_timeout"=60}
200+
C->>+S: POST /threads/{thread_id}/runs {agent_id, message="Can you remind my name?", config, metadata}
201+
S->>-C: Run={run_id, status="pending"}
202+
C->>+S: GET /threads/{thread_id}/runs/{run_id}/wait
199203
S->>-C: RunOutput={type="result", result={"message"="Yes, your name is John"}}
200204
end
201205
note right of S: state=[<br/>"Hello, my name is John?",<br/>"Hello John, how can I help?"<br/>"Can you remind my name?",<br/>"Yes, your name is John"<br/>]
202-
C->>+S: GET /threads/{thread_id}/state {thread_id}
203-
S->>-C: ThreadState=[<br/>"Hello, my name is John?",<br/>"Hello John, how can I help?"<br/>"Can you remind my name?",<br/>"Yes, your name is John"<br/>]
206+
C->>+S: GET /threads/{thread_id}
207+
S->>-C: Thread{thread_id, status="idle", values=[<br/>"Hello, my name is John?",<br/>"Hello John, how can I help?"<br/>"Can you remind my name?",<br/>"Yes, your name is John"<br/>]}
204208
```
205209
In the sequence above:
206-
1. The client starts the first run and provides the first message of the chat.
207-
1. The server returns the run object which **includes a thread ID** because the server supports thread runs.
210+
1. The client requests to create a thread on the server
211+
1. The server returns a thread object that contains a thread ID
212+
1. The client starts the first run on the created thread and provides the first message of the chat.
213+
1. The server returns the run object.
208214
1. The client requests the run output.
209215
1. The server returns the run output which is the next chat message from the agent and leaves a state with the current chat history.
210-
1. The client starts a new run providing:
211-
* The same thread ID, which means that the run will use the existing state associated with the thread.
212-
* The input for the run, i.e. the next message in the chat (assuming the existence of the chat history on the server).
216+
1. The client starts a new run on the same thread providing the input for the run, i.e. the next message in the chat (assuming the existence of the chat history on the server).
213217
1. The server starts the runs using the existing chat history and returns the run object.
214218
1. The client requests the run output.
215219
1. The server updates the thread state and returns the run output.
216220
1. Finally, the client requests the thread state (this is an optional operation).
217-
1. The server returns the current thread state which collects the whole chat history.
221+
1. The server returns the current thread object which collects the whole chat history.
218222

219223
### Output Streaming
220-
ACP supports output streaming. Agent can stream intermediate results of a Run to provide better response time and user experience.
224+
ACP supports output streaming. Agent can stream partial results of a Run to provide better response time and user experience.
221225

222226
ACP implements streaming using Server Sent Events specified here: https://html.spec.whatwg.org/multipage/server-sent-events.html.
223227

224228
In a nutshell, the client keeps the HTTP connection open and receives a stream of events from the server, where each event carries an update of the run result.
225229

226230
ACP supports 2 streaming modes:
227-
1. **result** where each event contains a full instance of the RunResult, which fully replace the previous update.
231+
1. **values** where each event contains a full instance of the agent output, which fully replace the previous update.
228232
2. **custom** where the schema of the event is left unspecified by ACP, which it can be specified in the specific agent ACP descriptor under `spec.custom_streaming_update`
229233

230234
#### Start a Run and stream output until completion
@@ -233,23 +237,21 @@ ACP supports 2 streaming modes:
233237
sequenceDiagram
234238
participant C as ACP Client
235239
participant S as ACP Server
236-
C->>+S: POST /runs {agent_id, input, config, metadata, streaming='result'}
240+
C->>+S: POST /runs/stream {agent_id, input, config, metadata, stream_mode='values'}
237241
S->>-C: Run={run_id, status="pending"}
238-
C->>+S: GET /runs/{run_id}/stream
239242
rect rgb(240,240,240)
240-
S->>C: StreamEvent={id="1", event="agent_event", data={run_id, type="result", result={"message": "Hello"}}}
241-
S->>C: StreamEvent={id="2", event="agent_event", data={run_id, type="result", result={"message": "Hello, how"}}}
242-
S->>C: StreamEvent={id="2", event="agent_event", data={run_id, type="result", result={"message": "Hello, how can"}}}
243-
S->>C: StreamEvent={id="3", event="agent_event", data={run_id, type="result", result={"message": "Hello, how can I help"}}}
244-
S->>C: StreamEvent={id="4", event="agent_event", data={run_id, type="result", result={"message": "Hello, how can I help you"}}}
245-
S->>C: StreamEvent={id="5", event="agent_event", data={run_id, type="result", result={"message": "Hello, how can I help you today"}}}
243+
S->>C: StreamEvent={id="1", event="agent_event", data={run_id, type="values", result={"message": "Hello"}}}
244+
S->>C: StreamEvent={id="2", event="agent_event", data={run_id, type="values", result={"message": "Hello, how"}}}
245+
S->>C: StreamEvent={id="2", event="agent_event", data={run_id, type="values", result={"message": "Hello, how can"}}}
246+
S->>C: StreamEvent={id="3", event="agent_event", data={run_id, type="values", result={"message": "Hello, how can I help"}}}
247+
S->>C: StreamEvent={id="4", event="agent_event", data={run_id, type="values", result={"message": "Hello, how can I help you"}}}
248+
S->>C: StreamEvent={id="5", event="agent_event", data={run_id, type="values", result={"message": "Hello, how can I help you today"}}}
246249
S->>C: Close Connection
247250
end
248251
```
249252

250253
In the sequence above:
251-
1. The client requests to start a run on a specific agent specifying streaming mode = 'result'.
252-
1. The server returns a run object.
254+
1. The client requests to start a run on a specific agent specifying stream_mode = 'values' and waits immediately for the streaming.
253255
1. The client requests the output streaming and keeps the connection open.
254256
1. The server returns an event with message="Hello".
255257
1. The server returns an event with updated message "Hello, how".

docs/openapi.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
</head>
88
<body>
9-
<script id="api-reference" data-url="../openapi.yaml"></script>
9+
<script id="api-reference" data-url="../openapi.json"></script>
1010
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
1111
</body>
1212
</html>

0 commit comments

Comments
 (0)