feat: Structured output for recipes (#3188)

This commit is contained in:
Jarrod Sibbison
2025-07-02 12:16:57 +10:00
committed by GitHub
parent 620474b76e
commit 0a00b0f588
13 changed files with 754 additions and 7 deletions

View File

@@ -36,6 +36,7 @@ After creating recipe files, you can use [`goose` CLI commands](/docs/guides/goo
| `prompt` | String | A template prompt that can include parameter substitutions; required in headless (non-interactive) mode |
| `parameters` | Array | List of parameter definitions |
| `extensions` | Array | List of extension configurations |
| `response` | Object | Configuration for structured output validation |
## Parameters
@@ -106,6 +107,54 @@ extensions:
description: "For searching logs using Presidio"
```
## Structured Output with `response`
The `response` field enables recipes to enforce a final structured JSON output from Goose. When you specify a `json_schema`, Goose will:
1. **Validate the output**: Validates the output JSON against your JSON schema with basic JSON schema validations
2. **Final structured output**: Ensure the final output of the agent is a response matching your JSON structure
This **Enables automation** by returning consistent, parseable results for scripts and workflows.
### Basic Structure
```yaml
response:
json_schema:
type: object
properties:
# Define your fields here, with their type and description
required:
# List required field names
```
### Simple Example
```yaml
version: "1.0.0"
title: "Task Summary"
description: "Summarize completed tasks"
prompt: "Summarize the tasks you completed"
response:
json_schema:
type: object
properties:
summary:
type: string
description: "Brief summary of work done"
tasks_completed:
type: number
description: "Number of tasks finished"
next_steps:
type: array
items:
type: string
description: "Recommended next actions"
required:
- summary
- tasks_completed
```
## Template Support
Recipes support Jinja-style template syntax in both `instructions` and `prompt` fields:
@@ -164,6 +213,22 @@ extensions:
timeout: 300
bundled: true
description: "Query codesearch directly from goose"
response:
json_schema:
type: object
properties:
result:
type: string
description: "The main result of the task"
details:
type: array
items:
type: string
description: "Additional details of steps taken"
required:
- result
- status
```
## Template Inheritance