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

Function postProcess

app/src/utils/post-processor.ts:13–35  ·  view source on GitHub ↗
(
    agentId: string,
    response: string | null, // null when the agent runs a decision model
    code: string,
    iterationId: string, // <-- New parameter
    getToken?: TokenProvider,
    preprocessResult?: PreProcessorResult,
    decision: Decision | null = null // System One answers when the agent runs a decision model
)

Source from the content-addressed store, hash-verified

11 * based on the presence of a '#python' marker
12 */
13export async function postProcess(
14 agentId: string,
15 response: string | null, // null when the agent runs a decision model
16 code: string,
17 iterationId: string, // <-- New parameter
18 getToken?: TokenProvider,
19 preprocessResult?: PreProcessorResult,
20 decision: Decision | null = null // System One answers when the agent runs a decision model
21): Promise<boolean> {
22 Logger.debug(agentId, 'Starting response post-processing', { iterationId });
23
24 if (code.trim().startsWith('#python')) {
25 Logger.debug(agentId, 'Detected Python code, using Python handler', { iterationId });
26 // Lazy load Python handler - only loads when Python code is executed!
27 const { executePython } = await import('./handlers/python');
28 return await executePython(response ?? '', agentId, code);
29 } else {
30 Logger.debug(agentId, 'Using JavaScript handler', { iterationId });
31 // Pass iterationId, getToken, and preprocessResult to JavaScript handler
32 return await executeJavaScript(response, agentId, code, iterationId, getToken, preprocessResult, decision);
33 }
34 // No catch - let errors bubble up naturally to main_loop
35}

Callers 2

handleRunCodeFunction · 0.90
executeAgentIterationFunction · 0.90

Calls 3

executeJavaScriptFunction · 0.90
executePythonFunction · 0.85
debugMethod · 0.45

Tested by

no test coverage detected