()
| 319 | |
| 320 | |
| 321 | def main(): |
| 322 | parser = argparse.ArgumentParser(description="Live test CodeAgent quality") |
| 323 | parser.add_argument("--model", default="gpt-4.1", help="Model to use") |
| 324 | parser.add_argument("--test-id", type=int, default=0, help="Test case ID (0=all)") |
| 325 | parser.add_argument("--no-sandbox", action="store_true", help="Skip sandbox exec-fix") |
| 326 | parser.add_argument("--tree-search", action="store_true", help="Enable tree search") |
| 327 | parser.add_argument("--output-dir", default="test_outputs", help="Output directory") |
| 328 | args = parser.parse_args() |
| 329 | |
| 330 | # Setup LLM client |
| 331 | base_url = os.environ.get("OPENAI_BASE_URL", "") |
| 332 | api_key = os.environ.get("OPENAI_API_KEY", "") |
| 333 | if not base_url or not api_key: |
| 334 | print("ERROR: Set OPENAI_BASE_URL and OPENAI_API_KEY environment variables") |
| 335 | sys.exit(1) |
| 336 | |
| 337 | llm_config = LLMConfig( |
| 338 | base_url=base_url, |
| 339 | api_key=api_key, |
| 340 | primary_model=args.model, |
| 341 | fallback_models=[], |
| 342 | max_tokens=16384, |
| 343 | temperature=0.7, |
| 344 | timeout_sec=300, |
| 345 | ) |
| 346 | llm = LLMClient(llm_config) |
| 347 | |
| 348 | # Quick connectivity test |
| 349 | print(f"Testing LLM connectivity ({args.model})... ", end="", flush=True) |
| 350 | ok, msg = llm.preflight() |
| 351 | if not ok: |
| 352 | print(f"FAILED: {msg}") |
| 353 | sys.exit(1) |
| 354 | print("OK") |
| 355 | |
| 356 | pm = PromptManager() |
| 357 | |
| 358 | # Select test cases |
| 359 | if args.test_id > 0: |
| 360 | if args.test_id not in TEST_CASES: |
| 361 | print(f"ERROR: Unknown test ID {args.test_id}. Available: {list(TEST_CASES.keys())}") |
| 362 | sys.exit(1) |
| 363 | cases = {args.test_id: TEST_CASES[args.test_id]} |
| 364 | else: |
| 365 | cases = TEST_CASES |
| 366 | |
| 367 | # Output directory |
| 368 | output_dir = Path(args.output_dir) |
| 369 | output_dir.mkdir(parents=True, exist_ok=True) |
| 370 | |
| 371 | all_reports = [] |
| 372 | |
| 373 | for test_id, tc in cases.items(): |
| 374 | print(f"\n{'='*60}") |
| 375 | print(f"Test {test_id}: {tc['name']}") |
| 376 | print(f"{'='*60}") |
| 377 | |
| 378 | stage_dir = output_dir / f"test_{test_id}" |
no test coverage detected