From 0fb7879384eff33b69ee60ce0fc78797fc660015 Mon Sep 17 00:00:00 2001 From: Archer Date: Thu, 5 Nov 2026 09:49:24 -0600 Subject: [PATCH] fix(opencode-claimant): unwrap v2 session envelope + use /prompt route First live fire after #6263 launched nothing: every create failed its location check. Verified live against the server: POST /api/session returns 200 with the session under a {"data": ...} envelope, so claimant.py read id/location at the top level, got None for both, and deleted every session it created. poll.py and the working launch driver unwrap the envelope; claimant.py did not - a latent defect from its untracked life, invisible while the standing claimant ran in shadow. send_prompt had the same class of defect: it posted a {"content","role"} body to /api/session//messages, a shape that never landed a prompt on the v2 server. The proven route (used by the launch driver that bound 29 tasks) is POST /api/session//prompt with {"text": ...}. Prompt content is unchanged. --- pm-stack/opencode-claimant/claimant.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pm-stack/opencode-claimant/claimant.py b/pm-stack/opencode-claimant/claimant.py index f789a6f3c6..d2d3c9a3f8 100755 --- a/pm-stack/opencode-claimant/claimant.py +++ b/pm-stack/opencode-claimant/claimant.py @@ -578,6 +578,11 @@ def create_session(task_id, queue, issue_number, route_model): except Exception as e: print(f"Session creation failed for task {task_id}: {e}", file=sys.stderr) return None, None + + # The v2 server wraps the created session in a {"data": ...} + # envelope; the session (id, location) lives inside it. + if isinstance(session, dict) and isinstance(session.get("data"), dict): + session = session["data"] # Verify location.directory matches requested if session.get("location", {}).get("directory") != REPO_PRIMARY: @@ -684,12 +689,11 @@ def send_prompt(task_id, worker_id, queue, issue_number, session_id): return False payload = { - "content": prompt_text, - "role": "user" + "text": prompt_text } - + req = urllib.request.Request( - f"{OPENCODE_URL.rstrip('/')}/api/session/{session_id}/messages", + f"{OPENCODE_URL.rstrip('/')}/api/session/{session_id}/prompt", data=json.dumps(payload).encode(), method="POST" )