Add OpenHands Cloud API V1 skill and minimal Python client#48
Add OpenHands Cloud API V1 skill and minimal Python client#48
Conversation
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
|
@OpenHands please compare this one to #12 are they tackling the same or different prolbems? are they different enough that they won't step into each other toes when triggered? |
|
I'm on it! juanmichelini can track my progress at all-hands.dev |
|
Good point! I checked they say V0, respectively V1, in the Idk… Idk if it’s too late for V0 actually - I was thinking that for the moment, GitHub/Slack resolvers still use it. Also, we have a migration V0->V1 issue somewhere, it asks for docs comparing the two and documenting for people how to migrate, so idk, teaching the agent about them then let it test how you execute a thing with V0 and the same thing with V1 could be part of writing or checking the docs we will publish. That said, I’m fine with removing V0… We really should use only V1 in normal use, and more importantly, I think maybe we should recommend to users only V1… 🤔 |
|
@OpenHands Read all comments in this PR and investigate what you need to answer juanmichelini 's question. Including look at the linked PR diff and this one. Answer it directly on github in a comment. Note that it will be rendered as markdown. |
|
I'm on it! enyst can track my progress at all-hands.dev |
|
PR #12 (merged) adds the This PR (#48) adds Will they step on each other’s toes?In practice, they shouldn’t:
Net: same general domain (programmatic OpenHands API usage), but different API generations. They can coexist; V1 should be the default recommendation going forward, while V0 stays available for legacy deployments/integrations until migration is complete. |
This comment was marked as duplicate.
This comment was marked as duplicate.
all-hands-bot
left a comment
There was a problem hiding this comment.
Taste Rating: 🟡 Acceptable
This is pragmatic code solving a real problem. The design is straightforward, but there are some issues that need attention—particularly a path typo and missing tests for reference code.
|
@OpenHands Use Note: we will not add tests with auth and stuff here, I don't think. But the rest of comments are worth checking! You have the relevant key in your env, so you can test live what you modify. Do that and fix the client as appropriate. IMPORTANT: we are nice. Think deeply before you make an API call, check that it's correct and then make it; do not create scripts that use loops, do not poll heavily, to not stress the API. Single requests, do the necessary, report at the end. When you are done, push, and post a comment on top-level with all you did. Also, reply to the inline review threads with your resolution. Note that all will be rendered as markdown. |
|
I'm on it! enyst can track my progress at all-hands.dev |
|
Addressed the inline review feedback + validated the reference client with minimal live calls. Changes
Validation
Replies are posted in each inline thread with the specific resolution. |
|
Since my last summary, there have been no additional code changes or commits (the PR branch remains at commit Final checklist against your instructions
No extraneous changes were introduced after the last update, and the request has been fully addressed. |
- Fix broken prompt-file path in SKILL.md and add example prompt file - Refactor TS client to reuse request logic and support blob downloads - Remove polling helper from Python reference client to avoid API loops Co-authored-by: openhands <openhands@all-hands.dev>
Includes exponential backoff, sleeps between requests, and optional max_polls cap. Co-authored-by: openhands <openhands@all-hands.dev>
Removed deprecated openhands-api entry from default.json.
|
Here are a few suggestions from a skill I have been using for ~30 days:
I leave it entirely to your judgement whether you think any of these would be helpful for your work. |
|
Here are some other tips I've gathered from having OH work with the API: Suggested addition to SKILL.mdAdd this section after "Common agent server endpoints": Troubleshooting / Common Issues1. Direct ID lookup returns HTML instead of JSONSymptom: Calling Cause: This URL pattern is handled by the frontend router, not the API. Solution: Use the batch endpoint with the # ❌ Wrong - returns HTML
curl "${BASE_URL}/api/v1/app-conversations/${CONVERSATION_ID}" -H "Authorization: Bearer ${API_KEY}"
# ✅ Correct - returns JSON
curl "${BASE_URL}/api/v1/app-conversations?ids=${CONVERSATION_ID}" -H "Authorization: Bearer ${API_KEY}"The Python client already handles this correctly via 2. Using search endpointsFor listing or finding conversations, always use the
3. Timing expectations
Polling recommendations:
4. Getting agent server connection infoAfter a conversation is created, you need
# Get connection info from conversation record
conv = api.app_conversation_get(app_conversation_id)
agent_server_url = conv.get("conversation_url", "").rsplit("/api/conversations", 1)[0]
session_api_key = conv.get("session_api_key")AttributionThese troubleshooting tips are adapted from the documentation in jpshackelford/openhands-sample-plugins. |
|
@OpenHands Read #48 (comment) and #48 (comment) and let's learn from them to improve this Skill. Analyze and investigate the proposed updates/fixes and read the linked skill at https://github.com/jpshackelford/.openhands/blob/main/skills/openhands-cloud-api/SKILL.md Fix the skill in this PR. |
|
@enyst your session has expired. Please login again at OpenHands Cloud and try again. |
|
@OpenHands Read #48 (comment) and #48 (comment) and let's learn from them to improve this Skill. Analyze and investigate the proposed updates/fixes and read the linked skill at https://github.com/jpshackelford/.openhands/blob/main/skills/openhands-cloud-api/SKILL.md Fix the skill in this PR. |
|
@enyst your session has expired. Please login again at OpenHands Cloud and try again. |
|
@OpenHands Read #48 (comment) and #48 (comment) and let's learn from them to improve this Skill. Analyze and investigate the proposed updates/fixes and read the linked skill at https://github.com/jpshackelford/.openhands/blob/main/skills/openhands-cloud-api/SKILL.md Fix the skill in this PR. |
|
I'm on it! enyst can track my progress at all-hands.dev |
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Final summary (new since my last summary)
Completion checklist
|
skills/openhands-api-v1/SKILL.md
Outdated
| Do **not** rely on the last event `id` to infer the total number of events. | ||
| In the agent-server API, event IDs are UUIDs (not monotonically increasing integers). | ||
|
|
||
| ## Troubleshooting / common issues |
There was a problem hiding this comment.
- Read this entire Skill md file, and split Troubleshooting / common issues into a troubleshooting md file in this skill. Fetch agentskills.io to see the Agentskill format, we want to respect the format!
- Read all comments in this issue, and note that this troubleshooting comes from recent comments by jpshackelford; look up in this repo's main branch recent commits his commit signature (email, etc) and add authorship here too
- Also fix attribution as per the comments to this PR. Find a good place, probably at the end
There was a problem hiding this comment.
I'm on it! enyst can track my progress at all-hands.dev
There was a problem hiding this comment.
Final Summary
I have successfully addressed all three items from the PR comment:
-
Split Troubleshooting into separate file: Created
skills/openhands-api-v1/references/TROUBLESHOOTING.mdwith the troubleshooting content from the original SKILL.md. Updated SKILL.md to reference this file, following the AgentSkills progressive disclosure format. -
Added jpshackelford attribution: Found John-Mason P. Shackelford's commit signature from the main branch and added proper attribution in both README.md and SKILL.md.
-
Fixed attribution: Added the attribution section at the end of both files.
All changes have been committed and pushed to the remote branch openhands/openhands-api-v1-skill, which updates PR #48.
bb754bd to
b3cc237
Compare
…ution - Created references/TROUBLESHOOTING.md with common issues from jpshackelford's feedback - Updated SKILL.md to reference the new troubleshooting file (progressive disclosure) - Added attribution for John-Mason P. Shackelford in README.md and SKILL.md
b3cc237 to
c70b8b8
Compare
Updated trigger names for the OpenHands API skill.
|
@jpshackelford I added your troubleshooting tips. I also used this lately - or a variant of it. I'd suggest we take this in, and use it, so we can improve it. |
Summary
Adds a new
openhands-api-v1skill that documents the OpenHands Cloud V1 API (app server + sandbox agent-server) and provides minimal, copyable clients for common operations.Included:
skills/openhands_api_v1/SKILL.mdX-Session-API-Key)agent_server_url+session_api_keyhttpx):skills/openhands_api_v1/scripts/openhands_api_v1.pyfetch):skills/openhands_api_v1/scripts/openhands_api_v1.tsskills/openhands_api_v1/references/README.md(also points to route locations inOpenHands/OpenHands)skills/openhands_api_v1/README.mdWhat’s covered by the minimal clients
App server (
/api/v1, Bearer auth)GET /users/meGET /app-conversations/searchGET /app-conversations?ids=...POST /app-conversations(start conversation; may create a sandbox)GET /app-conversations/start-tasks?ids=...GET /conversation/{id}/events/searchGET /conversation/{id}/events/count(may be flaky in some deployments)GET /app-conversations/{id}/download(trajectory zip)Agent server (
{agent_server_url}/api, session auth)GET /conversations/{id}/events/search(supports optional filters andsort_order=TIMESTAMP(_DESC))GET /conversations/{id}/events/count(reliable count alternative)POST /bash/execute_bash_commandNotes
openhands-api-client-v1).POST /api/v1/app-conversations) can create a sandbox and may incur cost; the skill calls this out.Co-authored-by: openhands openhands@all-hands.dev