(
app_conversation_id: str, poll_interval_seconds: int, max_wait_seconds: int
)
| 302 | |
| 303 | |
| 304 | def poll_conversation( |
| 305 | app_conversation_id: str, poll_interval_seconds: int, max_wait_seconds: int |
| 306 | ) -> dict[str, Any]: |
| 307 | deadline = time.time() + max_wait_seconds |
| 308 | while time.time() < deadline: |
| 309 | payload = request_json( |
| 310 | OPENHANDS_BASE_URL, |
| 311 | f'/api/v1/app-conversations?ids={urllib.parse.quote(app_conversation_id)}', |
| 312 | headers={'Authorization': openhands_headers()['Authorization']}, |
| 313 | ) |
| 314 | item = extract_first_item(payload) |
| 315 | if item is None: |
| 316 | time.sleep(poll_interval_seconds) |
| 317 | continue |
| 318 | execution_status = str(item.get('execution_status', '')).lower() |
| 319 | if execution_status in FAILED_EXECUTION_STATUSES: |
| 320 | raise RuntimeError( |
| 321 | 'OpenHands conversation ended with ' |
| 322 | f'{execution_status}: {json.dumps(item)}' |
| 323 | ) |
| 324 | if execution_status in SUCCESSFUL_TERMINAL_EXECUTION_STATUSES: |
| 325 | return item |
| 326 | time.sleep(poll_interval_seconds) |
| 327 | raise TimeoutError( |
| 328 | f'Timed out waiting for conversation {app_conversation_id} to finish running' |
| 329 | ) |
| 330 | |
| 331 | |
| 332 | def validate_event_search_results(events: list[dict[str, Any]]) -> list[dict[str, Any]]: |
no test coverage detected