Make an agent answer in a fixed format
Open in AgentumPurpose
Kian's order script needs an answer it can read the same way every time, not a paragraph of prose. Require the agent's final answer to follow a JSON Schema, so other programs can rely on its shape.
Before you start
The custom agent must belong to your current workspace, you need permission to manage agents, and you must know the JSON Schema you want. The chosen model must support structured answers.
Steps
- Open "Agents", find your agent under "My agents" and select it. In the window, open "Agent actions" (the three dots) and choose "Edit agent".
- Open "Structured output" and turn it on. While it is off, the fields cannot be edited.
- Under "Format details", enter a "Schema name" (start with an English letter; then use English letters, digits, underscores or hyphens; up to 64 characters) and a "Schema description" (up to 500 characters).
- Under "Response format", edit the "JSON Schema". The root must be an object with a "properties" object, and every property needs a type: object, array, string, number, integer, boolean or null. Names in "required" must exist in "properties", arrays need "items" and an "enum" cannot be empty.
- Read the message under the editor. It confirms that the schema is valid (the server checks it again when you save) or describes the problem. Syntax errors may identify a line and column; schema errors identify the invalid requirement or field. "Format JSON" tidies a valid schema and does nothing for an invalid one.
- Select "Save".
Expected result
| Field | Limit |
|---|---|
| Schema name | 1 to 64 characters |
| Schema description | Up to 500 characters |
| JSON Schema | Under 50 KB |
| Property name | 1 to 100 characters |
| Nesting depth | Up to 12 levels |
The agent's final answer follows the schema. The schema does not give the agent new tools.
Troubleshooting
| Problem | What to do |
|---|---|
| "Save" is disabled | Structured output is on and the schema is invalid. Fix the message shown under the editor. |
| "Invalid JSON at line 3, column 5." (any line and column) | Fix the JSON syntax at that spot, such as a missing comma or quote. |
| "The root schema type must be object." | Make the top-level "type" an object and add "properties". |
| The model cannot follow the schema | Simplify the schema or choose a different model in "Model". |