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

Function executeTestIteration

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

Source from the content-addressed store, hash-verified

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

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