@@ -147,6 +147,7 @@ Default core tools:
147147| Programmatic | ` program ` |
148148| Delegation | ` task ` , ` parallel_task ` |
149149| Skills | ` search_skills ` , ` Skill ` |
150+ | Structured Output | ` generate_object ` |
150151
151152Intent-gated tools:
152153
@@ -193,7 +194,41 @@ script can call every registered tool except `program`; use `allowedTools` or
193194structured summaries, findings, artifact references, and suggested next actions.
194195Raw output belongs in trace storage.
195196
196- ### 5. Runtime Observability Is A Contract
197+ ### 5. Structured Output
198+
199+ When the agent needs to produce machine-readable results, ` generate_object `
200+ forces schema-validated JSON output from any LLM provider:
201+
202+ ``` typescript
203+ const result = await session .tool (' generate_object' , {
204+ schema: {
205+ type: ' object' ,
206+ required: [' sentiment' , ' confidence' ],
207+ properties: {
208+ sentiment: { type: ' string' , enum: [' positive' , ' negative' , ' neutral' ] },
209+ confidence: { type: ' number' , minimum: 0 , maximum: 1 },
210+ },
211+ },
212+ prompt: ' Classify: "This product is amazing!"' ,
213+ schema_name: ' sentiment' ,
214+ });
215+
216+ const { object } = JSON .parse (result .output );
217+ // { sentiment: "positive", confidence: 0.95 }
218+ ```
219+
220+ The tool works in two modes:
221+ - ** Agent-driven** : The LLM sees ` generate_object ` in its tool list and calls it
222+ autonomously when structured output is needed.
223+ - ** Direct call** : ` session.tool('generate_object', ...) ` bypasses LLM decision-making
224+ for deterministic structured extraction.
225+
226+ Reliability comes from three layers: tool-call mode forces the LLM to produce
227+ JSON as tool arguments, a built-in schema validator catches violations, and an
228+ automatic repair loop feeds errors back to the model (up to ` max_repair_attempts `
229+ retries). Streaming mode emits partial objects as ` tool_output_delta ` events.
230+
231+ ### 6. Runtime Observability Is A Contract
197232
198233Product UIs and harnesses should build from typed runtime state rather than
199234parsing final answer text. Every ` send(...) ` or ` stream(...) ` creates run-scoped
@@ -281,7 +316,7 @@ if latest:
281316 session.cancel_run(latest[" id" ])
282317```
283318
284- ### 6 . AHP-Supervised Background Advice
319+ ### 7 . AHP-Supervised Background Advice
285320
286321A3S Code keeps the core session runtime focused on the main agent. Background
287322advice, context supplements, and proposed PTC scripts are caller-owned AHP
@@ -312,7 +347,7 @@ advice through the host UI or by explicitly calling session APIs. Proposed PTC
312347scripts remain proposals until the caller runs them through the normal
313348` program ` , permission, confirmation, and trace paths.
314349
315- ### 7 . Delegated Tasks Isolate Context
350+ ### 8 . Delegated Tasks Isolate Context
316351
317352Delegated tasks are not there to create more chat. They isolate local work.
318353
@@ -335,7 +370,7 @@ Delegated child runs should return:
335370
336371The parent should not ingest the full child transcript.
337372
338- ### 8 . Safety Has One Gate
373+ ### 9 . Safety Has One Gate
339374
340375All side effects should pass through one authorization path.
341376
@@ -347,7 +382,7 @@ Allow | Ask | Deny
347382
348383This keeps ` bash ` , writes, network calls, MCP calls, and release actions auditable.
349384
350- ### 9 . Completion Requires Verification
385+ ### 10 . Completion Requires Verification
351386
352387A coding agent is not done because it produced text. It is done when the goal is satisfied and the result has been checked.
353388
@@ -661,13 +696,14 @@ Full reference and guides: [a3s.dev/docs/code](https://a3s.dev/docs/code)
661696
662697- [ SDK API Design Contract] ( manual/SDK_API_DESIGN.md )
663698- [ Sessions] ( https://a3s.dev/docs/code/sessions )
664- - [ AHP Protocol ] ( https://a3s.dev/docs/code/ahp )
665- - [ Tools ] ( https://a3s.dev/docs/code/tools )
699+ - [ Tools & Structured Output ] ( https://a3s.dev/docs/code/tools )
700+ - [ AHP Protocol ] ( https://a3s.dev/docs/code/ahp-integration )
666701- [ Skills] ( https://a3s.dev/docs/code/skills )
667702- [ Memory] ( https://a3s.dev/docs/code/memory )
668703- [ Security] ( https://a3s.dev/docs/code/security )
669704- [ Hooks] ( https://a3s.dev/docs/code/hooks )
670705- [ Examples] ( https://a3s.dev/docs/code/examples )
706+ - [ Tutorials] ( https://a3s.dev/tutorials )
671707
672708---
673709
0 commit comments