Skip to main content

Structured Outputs

Structured outputs allow you to define a specific sequence of steps for the AI response, ensuring consistent and predictable results. Instead of getting a single free-form text block, you get a response broken down into specific sections that you define.

What are Structured Outputs?

Structured outputs let you specify a schema of "steps" that the AI must follow. Each step has a name (ID) and specific instructions. When enabled, the AI is forced to generate a response that strictly follows this structure, returning content for each step in order.

This is particularly useful for:

  • Chain of Thought: Forcing the AI to "think" or "reason" before providing a final answer.
  • Separation of Concerns: Keeping the reasoning separate from the final output.
  • Forcing Specific Answers: Ensuring the AI addresses specific points or follows a specific format.

Configuring Structured Outputs

To enable structured outputs, open your agent settings (Edit Template) and look for the Steps section.

  1. Enable the checkbox to activate structured outputs.
  2. Add steps to define the structure of the response.

Step Types

Currently, the system supports the following step types:

Text

A standard text block. You provide a name (ID) and instructions for what this section should contain. The AI will generate text based on your instructions.

Reasoning

A special block designed for "Chain of Thought" reasoning.

  • Thinking Title: The title displayed while the AI is generating this section.
  • Result Title: The title displayed for the final content of this section.
  • Hidden: You can choose to hide the AI generated output for this step from the final chat interface. This is useful if you want the AI to do some internal reasoning that the user doesn't need to see.

How it Works

Under the hood, the system converts your defined steps into a strict JSON schema. The AI is then instructed (and forced via the model's structured output capabilities) to return a JSON object where each key corresponds to a step you defined.

This mechanism ensures that the AI must provide an answer for every step you've configured, and it must follow the instructions for each step. This is a powerful way to control the AI's behavior and ensure high-quality, structured responses.

Example Use Case: Reasoning before Answering

A common pattern is to have two steps:

  1. Reasoning Step:
    • Name: thought_process
    • Type: Reasoning
    • Instructions: "Analyze the user's request, consider potential edge cases, and plan your response."
    • Hidden: Checked (optional, if you want to hide the thinking process)
  2. Final Answer Step:
    • Name: final_response
    • Type: Text
    • Instructions: "Provide the final answer to the user based on your analysis."

This setup forces the AI to think through the problem first, which often leads to better quality answers in the final response.