Ai Suite
4. Prompting

Structured Output

Structured Output

When an Agent implements Laravel\Ai\Contracts\HasStructuredOutput in PHP (such as Jev or JudgeAgent) or has Structured Output (JSON) enabled in the Agent Editor, the AI Suite automatically extracts the structured array response and makes its keys available for downstream routing.

Enabling Structured Output

  1. In the UI (/ai-suite#/agent/{id}/edit):
    • Open the agent in the Edit Agent screen.
    • Check the Structured Output (JSON) checkbox above the CRAFT Prompt Engine section and click Save Changes.
    • On the Agent Detail page (/ai-suite#/agent/{id}), an amber Structured Output (JSON) badge is displayed.
  2. In PHP (app/Ai/Agents/*.php):
    • Implement Laravel\Ai\Contracts\HasStructuredOutput on your Agent class and define the schema(JsonSchema $schema): array method.

Using Structured Output in Workflows

  • In Enum Nodes: Only agents with Structured Output (JSON) enabled appear in the Agent Class dropdown of an Enum module in the Visual Workflow Editor.
  • In If / Else & Statement Nodes: When a structured agent outputs a JSON object (e.g., {"decision": "APPROVE", "score": 92}), a connected Statement node can inspect specific properties using the Match Key (Dot-notation) field (e.g., decision or score).