定时任务结构化输出:用 responseSchema 让 cron agentTurn 可机读
场景:隔离 cron 报告格式不稳定,后续解析易失败。前置:sessionTarget=isolated 且 payload.kind=agentTurn。步骤:定义 JSON Schema→在 job.payload.responseSchema 注入→校验 structuredOutput。关键点:AJV 严格校验、`formattedReport` 可直发频道。验证:runs 返回 structuredOutput 且字段满足 required。风险:模型仍可能输出非 JSON,需容错降级。
GITHUBDiscovered 2026-02-15Author JordanCoin
Prerequisites
- You are creating isolated cron jobs (`sessionTarget=isolated`, `payload.kind=agentTurn`).
- A stable JSON schema contract is defined for downstream consumers.
Steps
- Design a minimal schema with required fields (for example: summary/items/formattedReport).
- Attach the schema to cron job payload via `responseSchema`.
- Run job and inspect run record for `structuredOutput` and validation behavior.
- If needed, use `formattedReport` field to bypass summarize pipeline and deliver directly.
Commands
openclaw helpopenclaw gateway statusVerify
Cron runs persist validated `structuredOutput`; invalid JSON falls back gracefully instead of hard-failing the run.
Caveats
- Schema strictness can expose weak-model formatting drift; tune prompt + schema together.
- Actual protocol field names should be rechecked against current gateway schema before production rollout(需验证).
Source attribution
This tip is aggregated from community/public sources and preserved with attribution.
Open original source ↗