MCPcopy Create free account
hub / github.com/Roy3838/Observer / executeTestIteration

Function executeTestIteration

app/src/utils/main_loop.ts:464–497  ·  view source on GitHub ↗
(
  agentId: string,
  systemPrompt: string,
  modelName: string,
  getToken?: TokenProvider
)

Source from the content-addressed store, hash-verified

462 * Execute a single test iteration - this is a simplified version for testing in the UI
463 */
464export async function executeTestIteration(
465 agentId: string,
466 systemPrompt: string,
467 modelName: string,
468 getToken?: TokenProvider
469): Promise<string> {
470 try {
471 Logger.debug(agentId, `Starting test iteration with model ${modelName}`);
472
473 // Pre-process the prompt (even for tests)
474 const processedPrompt = await preProcess(agentId, systemPrompt);
475
476 let token: string | undefined;
477 // Check if the getToken function was provided before trying to call it.
478 if (getToken) {
479 Logger.debug(agentId, 'Requesting fresh API token for test run...');
480 token = await getToken();
481 }
482
483 // Send the prompt to inference server and get response
484 Logger.info(agentId, `Sending prompt to inference server (model: ${modelName})`);
485 const response = await ModelManager.getInstance().sendPrompt(modelName, processedPrompt, token);
486 // Since this is a one-off test, we don't use the StreamManager and just stop the capture.
487 // This assumes the pre-processor for tests might call startScreenCapture directly.
488 // If test logic changes, this might need updating.
489 // stopScreenCapture(); // Note: This might need re-evaluation based on test flow.
490
491 return response;
492 } catch (error) {
493 const errorMessage = error instanceof Error ? error.message : 'Unknown error';
494 Logger.error(agentId, `Error in test iteration: ${errorMessage}`, error);
495 throw error;
496 }
497}

Callers 1

handleRunModelFunction · 0.90

Calls 6

preProcessFunction · 0.90
infoMethod · 0.80
sendPromptMethod · 0.80
errorMethod · 0.80
debugMethod · 0.45
getInstanceMethod · 0.45

Tested by

no test coverage detected