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