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

Function executeTestIteration

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

Source from the content-addressed store, hash-verified

486 * Execute a single test iteration - this is a simplified version for testing in the UI
487 */
488export 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}

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