(
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
)
| 11 | * based on the presence of a '#python' marker |
| 12 | */ |
| 13 | export 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 | } |
no test coverage detected