( agentId: string, systemPrompt: string, modelName: string, getToken?: TokenProvider )
| 472 | * Execute a single test iteration - this is a simplified version for testing in the UI |
| 473 | */ |
| 474 | export async function executeTestIteration( |
| 475 | agentId: string, |
| 476 | systemPrompt: string, |
| 477 | modelName: string, |
| 478 | getToken?: TokenProvider |
| 479 | ): Promise<string> { |
| 480 | try { |
| 481 | Logger.debug(agentId, `Starting test iteration with model ${modelName}`); |
| 482 | |
| 483 | // Pre-process the prompt (even for tests) |
| 484 | const processedPrompt = await preProcess(agentId, systemPrompt); |
| 485 | |
| 486 | let token: string | undefined; |
| 487 | // Check if the getToken function was provided before trying to call it. |
| 488 | if (getToken) { |
| 489 | Logger.debug(agentId, 'Requesting fresh API token for test run...'); |
| 490 | token = await getToken(); |
| 491 | } |
| 492 | |
| 493 | // Send the prompt to inference server and get response |
| 494 | Logger.info(agentId, `Sending prompt to inference server (model: ${modelName})`); |
| 495 | const { response, decision } = await ModelManager.getInstance().sendPrompt(modelName, processedPrompt, token); |
| 496 | // Since this is a one-off test, we don't use the StreamManager and just stop the capture. |
| 497 | // This assumes the pre-processor for tests might call startScreenCapture directly. |
| 498 | // If test logic changes, this might need updating. |
| 499 | // stopScreenCapture(); // Note: This might need re-evaluation based on test flow. |
| 500 | |
| 501 | // Decision models: show the full System One answer(s) in the test panel |
| 502 | return response ?? JSON.stringify(decision, null, 2); |
| 503 | } catch (error) { |
| 504 | const errorMessage = error instanceof Error ? error.message : 'Unknown error'; |
| 505 | Logger.error(agentId, `Error in test iteration: ${errorMessage}`, error); |
| 506 | throw error; |
| 507 | } |
| 508 | } |
no test coverage detected