Even though I’ve enabled the ‘Return Intermediate Steps’ option, the output still only returns the basic response. The detailed token usage and intermediate steps aren’t appearing in the output data at all.
Has anyone else encountered this issue? Is there a specific expression or perhaps an additional Code node required to properly extract these JSON fields?
Hi @tiboo Welcome to the community!
The video of nate herk is nice but that version of n8n is very old and currently n8n does not fully expose that token data into the output of the AI agent, what i have done is that:
Turn save execution progress (In the workflow settings) on so that it saves everything.
And to get that current execution ID you can use this expression {{$execution.id}}
Then just call the n8n API of executions using HTTP request , with that ID to get complete execution data and there might be some field like tokenUsage.
Like this might sound lengthy but is pretty much easy if once settled up!
And you can read this for more clear approach:
or if you want something like an estimator this has already been created
Yeah the execution API approach is really the only reliable way to get token data right now, the AI Agent node just doesn’t surface it properly in the output even with intermediate steps on. If you want something more structured there’s a community workflow called Token Estim8r that automates the whole thing and logs costs to Google Sheets, worth checking out.