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