fix: Missing final structured output should provide guidance to model (#4654)

This commit is contained in:
Jarrod Sibbison
2025-09-17 07:53:35 +10:00
committed by GitHub
parent e7a767528c
commit 7f51e078a9
3 changed files with 68 additions and 15 deletions
+1
View File
@@ -1308,6 +1308,7 @@ impl Agent {
let message = Message::user().with_text(FINAL_OUTPUT_CONTINUATION_MESSAGE);
messages_to_add.push(message.clone());
yield AgentEvent::Message(message);
messages.extend(messages_to_add);
continue
} else {
let message = Message::assistant().with_text(final_output_tool.final_output.clone().unwrap());
+6 -6
View File
@@ -38,17 +38,17 @@ impl FinalOutputTool {
pub fn tool(&self) -> Tool {
let instructions = formatdoc! {r#"
This tool collects the final output for a user and provides validation for structured JSON final output against a predefined schema.
The final_output tool collects the final output for the user and provides validation for structured JSON final output against a predefined schema.
This tool MUST be used for the final output to the user.
This final_output tool MUST be called with the final output for the user.
Purpose:
- Collects the final output for a user
- Collects the final output for the user
- Ensures that final outputs conform to the expected JSON structure
- Provides clear validation feedback when outputs don't match the schema
Usage:
- Call the `final_output` tool with your JSON final output
- Call the `final_output` tool with your JSON final output passed as the argument.
The expected JSON schema format is:
@@ -83,8 +83,8 @@ impl FinalOutputTool {
formatdoc! {r#"
# Final Output Instructions
You MUST use the `final_output` tool to collect the final output for a user.
The final output MUST be a valid JSON object that matches the following expected schema:
You MUST use the `final_output` tool to collect the final output for the user rather than providing the output directly in your response.
The final output MUST be a valid JSON object that is provided to the `final_output` tool when called and it must match the following schema:
{}