MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / poll_conversation

Function poll_conversation

scripts/issue_good_first_issue_check_openhands.py:281–306  ·  view source on GitHub ↗
(
    app_conversation_id: str, poll_interval_seconds: int, max_wait_seconds: int
)

Source from the content-addressed store, hash-verified

279
280
281def poll_conversation(
282 app_conversation_id: str, poll_interval_seconds: int, max_wait_seconds: int
283) -> dict[str, Any]:
284 deadline = time.time() + max_wait_seconds
285 while time.time() < deadline:
286 payload = request_json(
287 OPENHANDS_BASE_URL,
288 f'/api/v1/app-conversations?ids={urllib.parse.quote(app_conversation_id)}',
289 headers={'Authorization': openhands_headers()['Authorization']},
290 )
291 item = extract_first_item(payload)
292 if item is None:
293 time.sleep(poll_interval_seconds)
294 continue
295 execution_status = str(item.get('execution_status', '')).lower()
296 if execution_status in FAILED_EXECUTION_STATUSES:
297 raise RuntimeError(
298 'OpenHands conversation ended with '
299 f'{execution_status}: {json.dumps(item)}'
300 )
301 if execution_status in SUCCESSFUL_TERMINAL_EXECUTION_STATUSES:
302 return item
303 time.sleep(poll_interval_seconds)
304 raise TimeoutError(
305 f'Timed out waiting for conversation {app_conversation_id} to finish running'
306 )
307
308
309def validate_event_search_results(events: list[dict[str, Any]]) -> list[dict[str, Any]]:

Callers 1

mainFunction · 0.70

Calls 4

request_jsonFunction · 0.70
openhands_headersFunction · 0.70
extract_first_itemFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected