fix(Structured Output Parser Node, Auto-fixing Output Parser Node, Tools Agent Node): Structured output improvements (#13908)

Co-authored-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
Eugene
2025-03-13 18:20:24 +03:00
committed by GitHub
parent 31037484a5
commit 5b6b78709e
7 changed files with 138 additions and 13 deletions

View File

@@ -221,3 +221,22 @@ export const getConnectedTools = async (
return finalTools;
};
/**
* Sometimes model output is wrapped in an additional object property.
* This function unwraps the output if it is in the format { output: { output: { ... } } }
*/
export function unwrapNestedOutput(output: Record<string, unknown>): Record<string, unknown> {
if (
'output' in output &&
Object.keys(output).length === 1 &&
typeof output.output === 'object' &&
output.output !== null &&
'output' in output.output &&
Object.keys(output.output).length === 1
) {
return output.output as Record<string, unknown>;
}
return output;
}