Title: AI Agent (Tools Agent) triggers JSON too early in chat flow

Hi everyone,

I’m using an AI Agent (Tools Agent) in a conversational chat flow in n8n to collect structured data from users and then trigger a Stripe checkout.

The current flow is structured like this:

[When chat message received] → [AI Agent] → [Check Fields (JavaScript)] → [IF isComplete] → [Stripe Checkout]


### Problem:

From the **very first interaction**, even if the user just says “hello”, the AI Agent tries to build the full JSON output. It often includes empty or default values for fields (e.g. empty `"name"`, `null` `"age  but still **passes it downstream**. This causes:

* `Check Fields` to receive a partially filled JSON,
* the `IF` node to sometimes interpret it as valid (depending on how it's written),
* and worst of all: **the Stripe Checkout node is triggered prematurely**, before the user has completed the conversation.

This happens despite not using any **Structured Output Parser**. The system message includes detailed instructions (role, rules, step-by-step inputs), but it seems the AI Agent is too eager to output final JSON too soon.

### What I want to achieve:

1. **Keep the conversation going** and **only output the final JSON** once all required fields are collected.
2. Prevent the AI from prematurely outputting incomplete JSON or triggering downstream nodes.
3. Optionally store intermediate variables in memory, and **generate the JSON explicitly at the end**, once the user confirms.

---

### Questions:

* Is there a way to **prevent the AI Agent from generating final output until explicitly instructed**?
* Should I restructure the flow into two agents — one for data collection and one for JSON formatting?
* Are there best practices for building **chat-style flows** that should only advance to Stripe or generation once all required fields are confirmed?

Thanks in advance for your help. 

![Captura de pantalla 2025-05-14 070951|690x205](upload://nI7yReYWJwNC4wCDs4t1YNSo27v.png)

Hey!

I think the Tools Agent in n8n try to complete the task “as fast as possible”, so if your system message already asks for structured output, the agent may start building the JSON too early.
That’s because the agent doesn’t have memory or awareness of past messages unless you explicitly manage that context.

So you can try to:

  1. Use a memory mechanism to collect inputs over multiple messages

  2. Don’t generate final JSON until explicitly told

Modify your system message to say:

“Only generate the full JSON output when you are explicitly instructed to do so (e.g., after the user says ‘done’ or ‘yes, let’s continue’). Otherwise, just ask the next relevant question.”

  1. Add a guard clause in your flow
    In your “Check Fields” JS node, do a stricter validation.

Alternative: split into 2 agents
Your idea could be fine: you could use one agent for collection, then a second agent to cleanly generate the final JSON.
This works especially well if the collection agent stores partial values and only passes everything to the second agent once the user says “done”.