The idea is:
To make all metadata from AI Agent node outputs, such as generationInfo
(including model_name
, finish_reason
, etc.) and tokenUsage
, directly available in the output JSON of the node for downstream use.
Currently, while this information is visible within the node’s execution logs in the n8n UI, it is not easily accessible via standard expressions ($json.propertyName
) in subsequent nodes.
My use case:
I am building workflows that interact with Large Language Models (LLMs) via the AI Agent node. For each interaction, I need to log critical metadata alongside the generated text. This includes:
- The specific LLM
model_name
that was actually used. - The
finish_reason
to understand why a generation stopped. tokenUsage
details (prompt, completion, total tokens) for cost tracking and performance analysis.
Without direct access to these fields in the node’s output, it is challenging to reliably capture this information for persistent storage (e.g., in a database) or for conditional logic within the workflow.
I think it would be beneficial to add this because:
This feature would significantly enhance the utility of the AI Agent node by providing comprehensive access to its output. It would:
- Improve Data Integrity: Allow users to store complete records of LLM interactions, which is crucial for auditing, debugging, and future analysis.
- Enable Advanced Analytics: Facilitate robust cost tracking, model performance monitoring, and usage analysis without manual extraction or complex workarounds.
- Simplify Workflow Design: Reduce the need for custom code nodes or convoluted expressions to parse data that is already generated by the node but not fully exposed.
- Align with User Expectations: Users naturally expect all data visible in a node’s output logs to be programmatically accessible.
Any resources to support this?
The information is already present in the node’s internal output structure, as can be observed in the n8n UI execution logs for the AI Agent node. For example, model_name
is typically found at item.json.generations[0].generationInfo.model_name
within the node’s output.