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

Function main

scripts/issue_good_first_issue_check_openhands.py:460–560  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

458
459
460def main() -> int:
461 args = parse_args()
462 issue = fetch_issue(args.repository, args.issue_number)
463 if issue.get('pull_request'):
464 raise RuntimeError(f'#{args.issue_number} is a pull request, not an issue')
465
466 prompt = build_prompt(args.repository, issue)
467 start_task = start_conversation(prompt, args.repository, args.issue_number)
468 app_conversation_id = start_task.get('app_conversation_id')
469 conversation_url = ''
470
471 if not app_conversation_id:
472 task_id = start_task.get('id')
473 if not task_id:
474 raise RuntimeError(f'Missing id in start task response: {start_task}')
475 ready_task = poll_start_task(
476 task_id,
477 args.poll_interval_seconds,
478 args.max_wait_seconds,
479 )
480 app_conversation_id = ready_task.get('app_conversation_id')
481 if not app_conversation_id:
482 raise RuntimeError(f'Missing app_conversation_id in response: {ready_task}')
483
484 conversation = poll_conversation(
485 app_conversation_id,
486 args.poll_interval_seconds,
487 args.max_wait_seconds,
488 )
489 conversation_url = (
490 conversation.get('conversation_url')
491 or f'{OPENHANDS_BASE_URL}/conversations/{app_conversation_id}'
492 )
493 session_api_key_value = conversation.get('session_api_key')
494 if session_api_key_value and not isinstance(session_api_key_value, str):
495 raise RuntimeError(
496 'session_api_key had unexpected type in the OpenHands conversation: '
497 f'{type(session_api_key_value).__name__}'
498 )
499 session_api_key = session_api_key_value or ''
500 agent_server_url = extract_agent_server_url(conversation_url)
501
502 agent_text = ''
503 if agent_server_url and session_api_key:
504 try:
505 agent_text = fetch_agent_server_final_response(
506 app_conversation_id,
507 agent_server_url,
508 session_api_key,
509 )
510 except RuntimeError:
511 agent_text = ''
512 if not agent_text:
513 events = fetch_app_server_events(app_conversation_id)
514 try:
515 agent_text = extract_last_agent_text(events)
516 except RuntimeError as exc:
517 if not session_api_key:

Calls 14

parse_argsFunction · 0.70
fetch_issueFunction · 0.70
build_promptFunction · 0.70
start_conversationFunction · 0.70
poll_start_taskFunction · 0.70
poll_conversationFunction · 0.70
extract_agent_server_urlFunction · 0.70
fetch_app_server_eventsFunction · 0.70
extract_last_agent_textFunction · 0.70
normalize_resultFunction · 0.70

Tested by

no test coverage detected