@@ -167,6 +167,167 @@ The endpoint streams a JSON array incrementally. Each element represents a statu
167167
168168Each update is streamed as it occurs, allowing you to provide real-time feedback to users about the conversation startup progress.
169169
170+ ### Checking Conversation Status
171+
172+ After starting a conversation, you can check its status to monitor whether the agent has completed its task.
173+
174+ #### Step 1: Check Start Task Status
175+
176+ When you start a conversation, you receive a start task ID. Poll this endpoint until ` status ` becomes ` READY ` and ` app_conversation_id ` is available:
177+
178+ ``` bash
179+ curl -X GET " https://app.all-hands.dev/api/v1/app-conversations/start-tasks?ids=TASK_ID" \
180+ -H " Authorization: Bearer YOUR_API_KEY"
181+ ```
182+
183+ ** Response:**
184+ ``` json
185+ {
186+ "id" : " 550e8400-e29b-41d4-a716-446655440000" ,
187+ "status" : " READY" ,
188+ "app_conversation_id" : " 660e8400-e29b-41d4-a716-446655440001" ,
189+ "sandbox_id" : " sandbox-abc123"
190+ }
191+ ```
192+
193+ #### Step 2: Check Conversation Execution Status
194+
195+ Once you have the ` app_conversation_id ` , check whether the agent has finished its task:
196+
197+ <Tabs >
198+ <Tab title = " cURL" >
199+ ``` bash
200+ curl -X GET " https://app.all-hands.dev/api/v1/app-conversations?ids=CONVERSATION_ID" \
201+ -H " Authorization: Bearer YOUR_API_KEY"
202+ ```
203+ </Tab >
204+ <Tab title = " Python (with requests)" >
205+ ``` python
206+ import requests
207+
208+ api_key = " YOUR_API_KEY"
209+ conversation_id = " YOUR_CONVERSATION_ID"
210+
211+ headers = {
212+ " Authorization" : f " Bearer { api_key} " ,
213+ " Content-Type" : " application/json"
214+ }
215+
216+ response = requests.get(
217+ " https://app.all-hands.dev/api/v1/app-conversations" ,
218+ headers = headers,
219+ params = {" ids" : conversation_id}
220+ )
221+ conversations = response.json()
222+
223+ if conversations:
224+ conv = conversations[0 ]
225+ print (f " Sandbox Status: { conv.get(' sandbox_status' )} " )
226+ print (f " Execution Status: { conv.get(' execution_status' )} " )
227+ ```
228+ </Tab >
229+ </Tabs >
230+
231+ ** Response:**
232+ ``` json
233+ [
234+ {
235+ "id" : " 660e8400-e29b-41d4-a716-446655440001" ,
236+ "sandbox_status" : " RUNNING" ,
237+ "execution_status" : " finished" ,
238+ "selected_repository" : " yourusername/your-repo" ,
239+ "title" : " Fix README"
240+ }
241+ ]
242+ ```
243+
244+ #### Status Fields
245+
246+ ** ` sandbox_status ` ** - The state of the sandbox environment:
247+ - ` STARTING ` - Sandbox is being created
248+ - ` RUNNING ` - Sandbox is active
249+ - ` PAUSED ` - Sandbox is paused (due to rate limits or user action)
250+ - ` ERROR ` - Sandbox encountered an error
251+ - ` MISSING ` - Sandbox was deleted
252+
253+ ** ` execution_status ` ** - The state of the agent's task (available when sandbox is ` RUNNING ` ):
254+ - ` idle ` - Agent is ready to receive tasks
255+ - ` running ` - Agent is actively working
256+ - ` paused ` - Execution is paused
257+ - ` waiting_for_confirmation ` - Agent is waiting for user confirmation
258+ - ` finished ` - Agent has completed the task
259+ - ` error ` - Agent encountered an error
260+ - ` stuck ` - Agent is stuck and unable to proceed
261+
262+ #### Complete Polling Example
263+
264+ Here's a complete example that starts a conversation and polls until completion:
265+
266+ ``` python
267+ import requests
268+ import time
269+
270+ api_key = " YOUR_API_KEY"
271+ base_url = " https://app.all-hands.dev"
272+
273+ headers = {
274+ " Authorization" : f " Bearer { api_key} " ,
275+ " Content-Type" : " application/json"
276+ }
277+
278+ # Start a conversation
279+ print (" Starting conversation..." )
280+ start_response = requests.post(
281+ f " { base_url} /api/v1/app-conversations " ,
282+ headers = headers,
283+ json = {
284+ " initial_message" : {
285+ " content" : [{" type" : " text" , " text" : " Your task here" }]
286+ },
287+ " selected_repository" : " yourusername/your-repo"
288+ }
289+ )
290+ start_task = start_response.json()
291+ task_id = start_task[" id" ]
292+ print (f " Start task ID: { task_id} " )
293+
294+ # Poll start task until conversation is ready
295+ conversation_id = None
296+ while not conversation_id:
297+ task_response = requests.get(
298+ f " { base_url} /api/v1/app-conversations/start-tasks " ,
299+ headers = headers,
300+ params = {" ids" : task_id}
301+ )
302+ tasks = task_response.json()
303+ if tasks and tasks[0 ].get(" status" ) == " READY" :
304+ conversation_id = tasks[0 ].get(" app_conversation_id" )
305+ print (f " Conversation ready: { base_url} /conversations/ { conversation_id} " )
306+ else :
307+ print (f " Start task status: { tasks[0 ].get(' status' ) if tasks else ' unknown' } " )
308+ time.sleep(5 )
309+
310+ # Poll conversation until agent finishes
311+ while True :
312+ conv_response = requests.get(
313+ f " { base_url} /api/v1/app-conversations " ,
314+ headers = headers,
315+ params = {" ids" : conversation_id}
316+ )
317+ conversations = conv_response.json()
318+
319+ if conversations:
320+ conv = conversations[0 ]
321+ exec_status = conv.get(" execution_status" )
322+ print (f " Execution status: { exec_status} " )
323+
324+ if exec_status in [" finished" , " error" , " stuck" ]:
325+ print (f " Conversation completed with status: { exec_status} " )
326+ break
327+
328+ time.sleep(30 )
329+ ```
330+
170331## Rate Limits
171332
172333If you have too many conversations running at once, older conversations will be paused to limit the number of concurrent conversations.
0 commit comments