@@ -94,6 +94,14 @@ export default defineToolPlugin({
9494 parameters: Type .Object ({
9595 symbol: Type .String ({ description: " Ticker symbol, for example OPEN." }),
9696 }),
97+ outputSchema: Type .Object (
98+ {
99+ symbol: Type .String (),
100+ configured: Type .Boolean (),
101+ baseUrl: Type .String (),
102+ },
103+ { additionalProperties: false },
104+ ),
97105 async execute({ symbol }, config , context ) {
98106 context .signal ?.throwIfAborted ();
99107 return {
@@ -185,6 +193,54 @@ tool({
185193Use a factory tool when you need a custom ` AgentToolResult ` or want to reuse an
186194existing ` api.registerTool ` implementation.
187195
196+ ## Output contracts
197+
198+ Add ` outputSchema ` when a tool returns stable JSON-compatible data. It describes
199+ the original value stored in ` AgentToolResult.details ` , not the formatted text
200+ in ` content ` :
201+
202+ ``` typescript
203+ tool ({
204+ name: " shipment_list" ,
205+ description: " List shipments." ,
206+ parameters: Type .Object ({
207+ buyer: Type .Optional (Type .String ()),
208+ }),
209+ outputSchema: Type .Array (
210+ Type .Object (
211+ {
212+ id: Type .String (),
213+ buyer: Type .String (),
214+ paid: Type .Boolean (),
215+ tons: Type .Number (),
216+ },
217+ { additionalProperties: false },
218+ ),
219+ ),
220+ execute : ({ buyer }) => listShipments (buyer ),
221+ });
222+ ```
223+
224+ [ Code Mode] ( /tools/code-mode ) and [ Tool Search] ( /tools/tool-search ) turn this
225+ schema into a bounded TypeScript-style output hint. That lets a model call and
226+ transform a known result in one program instead of spending another model turn
227+ observing its shape.
228+
229+ OpenClaw compiles the schema before executing a catalog call, then validates the
230+ final ` details ` value after tool hooks before returning it through the bridge.
231+ An invalid schema cannot run the tool; a result mismatch fails the completed
232+ call. Include every non-throwing result variant, including structured error
233+ variants, or omit the schema when the result is not stable. Do not put secrets
234+ or sensitive values in schema descriptions because trusted output metadata can
235+ become model-visible.
236+ Use ` { additionalProperties: false } ` on object layers when you want a complete
237+ compact output hint; open or truncated schemas remain available through
238+ ` tools.describe(...) ` but are not advertised as complete quick-index contracts.
239+
240+ Factory tools declare ` outputSchema ` on the concrete ` AnyAgentTool ` they
241+ return. The static ` tool({ factory }) ` declaration does not accept a separate
242+ output schema because it could drift from the runtime tool.
243+
188244## Configuration
189245
190246` configSchema ` is optional. Omit it and OpenClaw applies a strict empty object
0 commit comments