@@ -57,6 +57,7 @@ public class SchemaOnlyTool extends ToolBase {
5757
5858 private final Boolean strict ;
5959 private final Boolean deferLoading ;
60+ private final Map <String , Object > outputSchema ;
6061
6162 /**
6263 * Creates a new SchemaOnlyTool from a ToolSchema.
@@ -71,7 +72,8 @@ public SchemaOnlyTool(ToolSchema schema) {
7172 schema .getDescription (),
7273 schema .getParameters (),
7374 schema .getStrict (),
74- schema .getDeferLoading ());
75+ schema .getDeferLoading (),
76+ schema .getOutputSchema ());
7577 }
7678
7779 /**
@@ -109,6 +111,32 @@ public SchemaOnlyTool(
109111 Map <String , Object > parameters ,
110112 Boolean strict ,
111113 Boolean deferLoading ) {
114+ this (name , description , parameters , strict , deferLoading , null );
115+ }
116+
117+ /**
118+ * Creates a new SchemaOnlyTool with the specified name, description, parameters, strict mode,
119+ * deferred loading, and output schema.
120+ *
121+ * <p>The parameters and output schema maps are defensively copied to prevent external
122+ * mutations from affecting the tool's internal state.
123+ *
124+ * @param name The tool name
125+ * @param description The tool description
126+ * @param parameters The tool parameters schema
127+ * @param strict Whether the tool should use strict schema validation (null if unspecified)
128+ * @param deferLoading Whether to defer loading this tool's schema until tool search (null if
129+ * unspecified)
130+ * @param outputSchema The structured output schema the tool declares, if any
131+ * @throws NullPointerException if name or description is null
132+ */
133+ public SchemaOnlyTool (
134+ String name ,
135+ String description ,
136+ Map <String , Object > parameters ,
137+ Boolean strict ,
138+ Boolean deferLoading ,
139+ Map <String , Object > outputSchema ) {
112140 super (
113141 ToolBase .builder ()
114142 .name (Objects .requireNonNull (name , "name cannot be null" ))
@@ -123,6 +151,10 @@ public SchemaOnlyTool(
123151 .concurrencySafe (true ));
124152 this .strict = strict ;
125153 this .deferLoading = deferLoading ;
154+ this .outputSchema =
155+ outputSchema != null
156+ ? Collections .unmodifiableMap (new HashMap <>(outputSchema ))
157+ : null ;
126158 }
127159
128160 /**
@@ -152,6 +184,11 @@ public Boolean getDeferLoading() {
152184 return deferLoading ;
153185 }
154186
187+ @ Override
188+ public Map <String , Object > getOutputSchema () {
189+ return outputSchema ;
190+ }
191+
155192 /**
156193 * Throws a ToolSuspendException to signal that this tool requires external execution.
157194 *
0 commit comments