|
| 1 | +--- |
| 2 | +name: openhands-api-v1-troubleshooting |
| 3 | +description: Common issues and solutions when using the OpenHands Cloud API V1. |
| 4 | +--- |
| 5 | + |
| 6 | +# Troubleshooting / Common Issues |
| 7 | + |
| 8 | +This file documents common issues encountered when working with the OpenHands Cloud API V1. |
| 9 | + |
| 10 | +## 1. Direct ID lookup returns HTML instead of JSON |
| 11 | + |
| 12 | +**Symptom:** Calling `GET /api/v1/app-conversations/{id}` returns HTML (the frontend app) instead of JSON. |
| 13 | + |
| 14 | +**Cause:** In OpenHands Cloud, this URL pattern is handled by the frontend router, not the API. |
| 15 | + |
| 16 | +**Solution:** Use the batch endpoint with the `ids` query parameter: |
| 17 | + |
| 18 | +```bash |
| 19 | +# ❌ Wrong (returns HTML) |
| 20 | +curl "${BASE_URL:-https://app.all-hands.dev}/api/v1/app-conversations/${APP_CONVERSATION_ID}" \ |
| 21 | + -H "Authorization: Bearer ${OPENHANDS_API_KEY}" \ |
| 22 | + -H "Accept: application/json" |
| 23 | + |
| 24 | +# ✅ Correct (returns JSON) |
| 25 | +curl "${BASE_URL:-https://app.all-hands.dev}/api/v1/app-conversations?ids=${APP_CONVERSATION_ID}" \ |
| 26 | + -H "Authorization: Bearer ${OPENHANDS_API_KEY}" \ |
| 27 | + -H "Accept: application/json" |
| 28 | +``` |
| 29 | + |
| 30 | +## 2. "Service Temporarily Unavailable" when calling sandbox/agent-server endpoints |
| 31 | + |
| 32 | +This usually means the sandbox runtime is not currently reachable. |
| 33 | + |
| 34 | +- Check the conversation record (`GET /api/v1/app-conversations?ids=...`) for a `runtime_status`-like field. |
| 35 | +- If the sandbox is paused, call `POST /api/v1/sandboxes/{sandbox_id}/resume`. |
| 36 | +- If the start-task isn't `READY` yet, poll `GET /api/v1/app-conversations/start-tasks?ids=...` for a bit. |
| 37 | + |
| 38 | +## 3. 404s when downloading trajectory or reading events |
| 39 | + |
| 40 | +Common causes: |
| 41 | + |
| 42 | +- Using a **start_task_id** where an **app_conversation_id** is required (see above). |
| 43 | +- Using the wrong event path (V1 is `/api/v1/conversation/{id}/events/...`). |
| 44 | +- The conversation was deleted or you don't have access. |
| 45 | + |
| 46 | +## 4. Timing expectations (typical, varies by load) |
| 47 | + |
| 48 | +| Operation | Typical duration | |
| 49 | +|---|---:| |
| 50 | +| `POST /api/v1/app-conversations` returns | < 1s | |
| 51 | +| start-task becomes `READY` | 5–15s | |
| 52 | +| sandbox responds to agent-server calls | usually immediately after `READY` | |
| 53 | + |
| 54 | +**Polling guidance:** poll every 3–5 seconds with a reasonable timeout (2–3 minutes). The minimal client implements polite exponential backoff. |
| 55 | + |
| 56 | +## Practical Tips |
| 57 | + |
| 58 | +- **Save responses locally for analysis** — When debugging, pipe API responses to a file: |
| 59 | + ```bash |
| 60 | + curl ... > response.json |
| 61 | + # Then analyze with jq or python |
| 62 | + ``` |
| 63 | + |
| 64 | +- **Use jq for quick filtering** — For fast event inspection: |
| 65 | + ```bash |
| 66 | + curl ... | jq '.items[] | select(.kind == "ErrorEvent")' |
| 67 | + ``` |
| 68 | + |
| 69 | +- **Check runtime_status before querying events** — Always verify the sandbox is ready: |
| 70 | + ```bash |
| 71 | + # Get conversation to check runtime_status |
| 72 | + GET /api/v1/app-conversations?ids=<id> |
| 73 | + # Only query events if runtime_status shows READY |
| 74 | + ``` |
| 75 | + |
| 76 | +- **Use trajectory zip for offline analysis** — Download the full trajectory: |
| 77 | + ```bash |
| 78 | + GET /api/v1/app-conversations/{id}/download |
| 79 | + ``` |
| 80 | + Then analyze all event files locally without making multiple API calls. |
| 81 | + |
| 82 | +- **Monitor start-task status** — When starting conversations, poll the start-task until ready before querying events or executing agent commands. |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +*Content adapted from user feedback and real-world usage patterns.* |
0 commit comments