feat: Structured output for recipes#3188
Conversation
…ructured-output * origin/main: (22 commits) feat(desktop): Prioritize suffix when truncating path in header (#3110) chore(release): release version 1.0.31 (#3185) feat: additional sub recipes via command line (#3163) Add Internal Recipes To Recipes Cookbook (#3179) pipe the argument to storage (#3184) docs: removing comment (#3183) docs: add generator option to create recipe (#3182) update the path for temporal (#3131) docs: add link to Square MCP (#3181) attempt to fix build #3 (#3180) attempt fix folde permissions for windows build (#3178) attempt to fix windows cli permission issue (#3177) allow to use dev/null for no-session mode (#3176) feat: change naming of recipe creation in more menu links (#3175) Docs: Add Recipe video to landing page (#3173) Docs: Create new directory when starting new session (#3174) fixes cron parsing issues (#3172) fix: handle Windows package subdirectory in CLI installation script (#3171) fixed the npx/uvx content (#3170) Mark helper scripts as executable (#3169) ...
DOsinga
left a comment
There was a problem hiding this comment.
can you also update the recipe documentation?
| return (request_id, Ok(ToolCallResult::from(result))); | ||
| } | ||
|
|
||
| if tool_call.name == FINAL_OUTPUT_TOOL_NAME { |
There was a problem hiding this comment.
oof this function is a bit of a mess! your addition is of course in line with what the rest looks like, but we should fix this at some point so if you feel the itch ...
| pub struct Response { | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub json_schema: Option<serde_json::Value>, | ||
| } |
There was a problem hiding this comment.
do you have a strong preference about making this nested? in the ticket we talk about just having a output_json_schema field
There was a problem hiding this comment.
yeah I think we should leave ourselves open to alternative response formats and extra controls (I expect someone will ask for a 'max_attempts' option to prevent unlimited attempts at some stage... I'm building a MAX_TURNS option into goose atm which I think is a better version).
| } | ||
| }, | ||
| "required": ["final_output"] | ||
| }), |
There was a problem hiding this comment.
couldn't we just insert the json schema at this point? asking the llm to do it in this format probably works, but since the tool takes a json schema, why not use that?
There was a problem hiding this comment.
🔥 Very nice, that cleans up the code a bit too.
| "Invalid JSON format: {}\n\nExpected format:\n{}\n\nPlease provide valid JSON that matches the expected schema.", | ||
| e, | ||
| serde_json::to_string_pretty(self.response.json_schema.as_ref().unwrap()).unwrap_or_else(|_| "Invalid schema".to_string()) | ||
| )); |
There was a problem hiding this comment.
does it recover from this?
There was a problem hiding this comment.
yes. I managed to fudge the agent to do it wrong the first time to test with goose. I've implemented this pattern a few times and it has worked pretty well.
| } | ||
| } | ||
|
|
||
| #[cfg(test)] |
There was a problem hiding this comment.
there are a lot of tests here. I would suggest to remove the ones that will never find a bug. the tests in the recipe mod feel more useful
There was a problem hiding this comment.
Old TDD habits 🙃 . Removing some.
|
* main: feat: Structured output for recipes (#3188) Fix cost tracking accuracy and OpenRouter model pricing (#3189) docs: update cli install instructions for windows (#3205) Docs: Cost tracking on the desktop app (#3204) feat: Adding streamable-http transport support for backend, desktop and cli (#2942) fix: use the correct `contains` syntax on create-recipe-pr.yml (#3193)
* main: fix: Pass Google AI API key in HTTP header, not query param (block#3192) docs: add linter to CONTRIBUTING.md (block#3168) feat: Structured output for recipes (block#3188) Fix cost tracking accuracy and OpenRouter model pricing (block#3189) docs: update cli install instructions for windows (block#3205) Docs: Cost tracking on the desktop app (block#3204) feat: Adding streamable-http transport support for backend, desktop and cli (block#2942) fix: use the correct `contains` syntax on create-recipe-pr.yml (block#3193)
* main: (37 commits) fix: fix desktop recipe url generation (block#3209) feat: improve UX for saving recipes (block#3214) fix: Pass Google AI API key in HTTP header, not query param (block#3192) docs: add linter to CONTRIBUTING.md (block#3168) feat: Structured output for recipes (block#3188) Fix cost tracking accuracy and OpenRouter model pricing (block#3189) docs: update cli install instructions for windows (block#3205) Docs: Cost tracking on the desktop app (block#3204) feat: Adding streamable-http transport support for backend, desktop and cli (block#2942) fix: use the correct `contains` syntax on create-recipe-pr.yml (block#3193) Temporarily Remove GH Copilot Provider (block#3199) docs: fix tab navigation (block#3201) feat: use tiktoken-rs instead of tokenizers, single global tokenizer (block#3115) add playwright-mcp server to extensions list (block#3010) Add `/extension` path for extension installation (block#3011) feat(desktop): Prioritize suffix when truncating path in header (block#3110) chore(release): release version 1.0.31 (block#3185) feat: additional sub recipes via command line (block#3163) Add Internal Recipes To Recipes Cookbook (block#3179) pipe the argument to storage (block#3184) ...
* main: (150 commits) Defend against invalid sessions (block#3229) Clean up session file optionality for --no-session (block#3230) Feat: Support Recipe Parameters in Goose desktop app (block#3155) docs: update recipe example (block#3222) Add native OAuth 2.0 authentication support to MCP client (block#3213) build: Check in Cargo.lock changes (block#3220) fix: fix desktop recipe url generation (block#3209) feat: improve UX for saving recipes (block#3214) fix: Pass Google AI API key in HTTP header, not query param (block#3192) docs: add linter to CONTRIBUTING.md (block#3168) feat: Structured output for recipes (block#3188) Fix cost tracking accuracy and OpenRouter model pricing (block#3189) docs: update cli install instructions for windows (block#3205) Docs: Cost tracking on the desktop app (block#3204) feat: Adding streamable-http transport support for backend, desktop and cli (block#2942) fix: use the correct `contains` syntax on create-recipe-pr.yml (block#3193) Temporarily Remove GH Copilot Provider (block#3199) docs: fix tab navigation (block#3201) feat: use tiktoken-rs instead of tokenizers, single global tokenizer (block#3115) add playwright-mcp server to extensions list (block#3010) ...
Signed-off-by: Adam Tarantino <tarantino.adam@gmail.com>
Signed-off-by: Soroosh <soroosh.sarabadani@gmail.com>
Signed-off-by: Kyle Santiago <kyle@privkey.io>
Main Changes
response.json_schemakey in recipe yaml.goose runwith recipes currently.Other Details
final_toolto output the expected messageThis PR does not add support to use structured output when running a recipe that defines it via the Desktop app. Future PR.
Example
Recipe
Usage