Skip to main content
Use this recipe when one agent workflow should:
  • run through the TypeScript Agent SDK
  • rely on managed web search
  • return strict structured JSON
  • recover near-valid malformed JSON deterministically

1. Install the SDKs

2. Define one narrow output contract

Keep the first research output small enough that operators can inspect it easily in logs.

3. Create the agent

Use parseOutput so the runtime returns typed data instead of raw text.

4. Configure the gateway-backed adapter once

This is the important part:
  • responseFormat keeps the output schema explicit
  • plugins enables response healing for near-valid JSON
  • gatewayTools exposes managed web search to the model
  • toolChoice forces the search tool when this workflow should always ground itself

5. Run the workflow

6. What to verify in logs

After one successful run, inspect the request detail view and confirm:
  • requested native web search tools or managed search activity is present
  • search results and citations were persisted
  • plugin execution shows response-healing only when recovery was needed
  • the final output matches the JSON schema you asked for

7. When to use this pattern

Use this recipe when:
  • the workflow is mostly one-shot research, not a deep local-tool loop
  • the model should ground itself before answering
  • downstream callers want typed JSON instead of prose
Do not use this pattern when:
  • the workflow already knows the exact URLs and phaseo:web_fetch is enough
  • the agent needs rich local tools more than upstream-native tools
  • the output contract is loose enough that strict JSON adds more overhead than value
Last modified on July 26, 2026