[{"data":1,"prerenderedAt":1443},["ShallowReactive",2],{"article:function-calling-structured-output":3},{"meta":4,"raw":18,"references":19,"prev":42,"next":50,"body":61,"toc":1433},{"slug":5,"title":6,"date":7,"updated":8,"tags":9,"summary":14,"draft":15,"lang":16,"minutes":17},"function-calling-structured-output","Function Calling 与结构化输出：让 LLM 可靠地动手","2026-03-17","2026-10-11",[10,11,12,13],"LLM","Tool Use","Agent","结构化输出","分清调用协议与输出格式，比较 OpenAI、Claude 的字段；用完整 schema 和工具循环说明参数验证、授权、并发、幂等与失败处理。",false,"zh-CN",6,"模型回答“工单已归档”，不代表数据库里真的有记录。Function Calling（工具调用）让模型提出操作请求，由程序执行并回传结果；Structured Outputs（结构化输出）约束回答的数据格式。**要完成动作，需要执行器；要返回一个对象，需要格式契约。**\n\n本文以客户端自定义工具为主，服务端内置工具的执行位置另看厂商文档。接口按 2026 年 10 月核对，例子中的业务工具为示意。\n\n## 一轮调用发生了什么\n\n程序声明工具名称、用途与参数 schema；模型返回调用请求；程序验证、授权并执行；将调用 ID 对应的结果回传；模型继续调用或回答。模型产生调用参数，不因此拥有真实权限。\n\n![工具调用循环：声明工具、生成调用、验证授权、执行、回传与终止](\u002Fdiagrams\u002Ffunction-calling.svg)\n\n*图 1 · 格式验证、业务授权和真实执行位于程序侧。*\n\n不同厂商的字段不能混用：\n\n| 接口 | 工具定义 | 调用参数 | 结果关联 |\n| --- | --- | --- | --- |\n| OpenAI Responses | `type: function`、`parameters` | `function_call.arguments` 是 JSON 字符串 | `function_call_output.call_id` |\n| OpenAI Chat Completions | `type: function`、嵌套 `function` | `tool_calls[].function.arguments` 是 JSON 字符串 | tool 消息的 `tool_call_id` |\n| Claude Messages | `input_schema` | `tool_use.input` 通常已解析成对象 | `tool_result.tool_use_id` |\n\nClaude 的多个客户端工具结果通常放在紧随助手消息的 user 内容块中；OpenAI 按各自接口的结果项或 tool 消息回传。错误标记也不同，`is_error` 不能当作所有接口的通用字段。[OpenAI 调用文档](https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Ffunction-calling)与 [Claude 调用文档](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Foverview)\n\n## Schema：格式约束要完整，业务含义要清晰\n\n工具 description 说明何时使用、何时不使用和结果含义；参数尽量用枚举、明确单位与可检验边界。下面是 **OpenAI Responses 风格**的工具定义：\n\n```json\n{\n  \"type\": \"function\",\n  \"name\": \"get_ticket\",\n  \"description\": \"读取已有工单；只用于存在 ticket_id 的记录，不用于创建、修改或归档工单。\",\n  \"strict\": true,\n  \"parameters\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"ticket_id\": { \"type\": \"string\" },\n      \"options\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"detail\": { \"type\": \"string\", \"enum\": [\"summary\", \"full\"] },\n          \"note\": { \"type\": [\"string\", \"null\"] }\n        },\n        \"required\": [\"detail\", \"note\"],\n        \"additionalProperties\": false\n      }\n    },\n    \"required\": [\"ticket_id\", \"options\"],\n    \"additionalProperties\": false\n  }\n}\n```\n\nOpenAI strict schema 要求各对象关闭额外属性，并把属性列入 required；可空字段用 `null` 表示。支持的是 JSON Schema 子集，非任意 schema 都可用。Claude 的声明形式和支持范围按其文档处理，不能只改字段名就保证兼容。\n\nStrict 降低参数形状错误，**不保证 ticket_id 存在、归当前用户所有，或模型选对了工具**。身份、租户和授权范围由会话上下文注入服务端；模型不能通过一个参数把自己变成管理员。\n\n## 工具循环：先完整，再执行\n\n以下为框架中立伪代码，`provider_adapter` 负责厂商差异：\n\n```text\nfor round in bounded_rounds:\n    response = await provider_adapter.generate(state)\n    record_usage_and_status(response)\n    if response.refused or response.incomplete:\n        return explicit_failure(response)\n\n    calls = provider_adapter.complete_calls(response)\n    if calls is empty:\n        return validated_final_answer(response)\n\n    results = bounded_execute(calls, handler = call => {\n        tool = registry.lookup(call.name)        # 未知工具拒绝\n        args = adapter.parse_complete_args(call) # 字符串解析或已解析对象\n        validate_schema_and_business(args)\n        authorize(current_user, tool, args)\n        return execute_with_deadline_and_idempotency(tool, args)\n    })\n    state = adapter.append_response_and_results(state, response, results)\nreturn explicit_failure(\"tool_round_limit\")\n```\n\n执行器把校验错误、超时和业务失败转成结构化结果，保留调用 ID；机密、堆栈和内部 SQL 不原样交给模型。流式参数要按调用 ID 聚合，等完整结束才解析，不能用“容错解析”把半截参数执行掉。\n\n厂商的截断、拒绝、暂停和完成状态分别处理；不能把 Claude 的 `stop_reason` 套到 Responses 上。`tool_choice` 是否能强制某工具取决于模型与接口，不能笼统说“新模型都已移除”。\n\n## 并行：独立读取可以，依赖写入不可以\n\n一个响应可能包含多次调用，但是否并行生成取决于模型与配置。程序不必无条件并发执行：两次独立检索可并发；“创建订单后付款”有依赖，应串行或拆成不同轮。\n\n并发要有上限、每调用截止时间和部分失败结果。写入工具用业务幂等键、唯一约束或事务防重复；模型请求重试和工具写入去重是不同问题，详见 [兜底设计](\u002Farticles\u002Fllm-fallback-design)。\n\n对发布、删除、支付等操作，把“草稿生成”与“提交”拆开。模型给出的 `suggested_status` 只能作为建议；最终状态由授权、业务规则、执行结果或审核机制确认。\n\n## 结构化输出：对象合法不等于对象正确\n\n抽取文档字段、分类反馈、生成报告适合结构化输出。Responses 的 `text.format`、Chat Completions 的 `response_format` 和 Claude 的 `output_config.format` 是不同配置位置。[OpenAI 结构化输出](https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Fstructured-outputs)\n\n消费结果前先看完成状态与拒绝，再解析并做 schema、业务校验。合法 JSON 中的日期也可能错误，引用 ID 也可能不存在；格式能力解决结构稳定，正确性仍由任务评测负责。\n\n## 工具体积与权限治理\n\n工具定义和结果占上下文，缓存只是改变重复处理成本。按任务加载工具、合并重叠工具、分页和按需读取都值得比较，工具数量没有统一的“最多十个”上限。\n\n大结果可返回摘要与受控引用，注明截断、总条数和后续 cursor；外部系统之间用有授权的 artifact ID，不能假设对方可读取本地路径。按角色少暴露工具有助于路由，**执行侧仍必须授权**。\n\n工具结果包含网页、日志等不受信任内容。模型读到“执行删除”的文字，不应因此获得删除能力。工具注册表、授权与高风险提交规则才是边界。\n\n## OpenAI 与 Anthropic：格式契约之外怎样改善工具使用\n\nOpenAI 的 Function Calling 与 Structured Outputs 文档提供 API 层面的 schema 和回传契约；Anthropic 的 [Writing effective tools](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fwriting-tools-for-agents)则从 Agent 使用工具的行为出发，讨论工具选择、命名、返回相关信息与 token 效率。两者可以结合：schema 限制格式，工具设计帮助模型正确选择和理解。\n\n工程推导：固定模型、任务集和业务权限，分别比较工具描述、重叠接口数量、结果字段与简洁\u002F详细模式。记录误选、参数错误、缺失 ID、重试次数和最终任务成功率；精简结果时保留后续动作所需的稳定 ID，不能只追求 token 最少。以相同预算比较，避免把工具优化与换模型的收益混在一起。\n\n执行循环与审批边界由[生产架构篇](\u002Farticles\u002Fproduction-agent-design)继续展开。\n\n## 落地检查\n\n1. API 适配器独立处理字段与回传格式。\n2. strict schema 校验完整，同时校验业务含义和身份权限。\n3. 流式调用参数完整后执行，按调用 ID 记录状态。\n4. 并行只用于独立操作，写入有幂等与审批语义。\n5. 限制轮数、并发、时间、费用和结果体积。\n6. 回归覆盖未知工具、截断、拒绝、重复调用和越权。\n\n长任务还需要 [上下文与记忆管理](\u002Farticles\u002Fcontext-memory-management)。\n\n## 参考资料\n\n- [OpenAI — Function calling](https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Ffunction-calling)\n- [OpenAI — Structured outputs](https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Fstructured-outputs)\n- [Claude — Tool use](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Foverview)\n- [Claude — Structured outputs](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fbuild-with-claude\u002Fstructured-outputs)\n- [Anthropic — Writing effective tools for AI agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fwriting-tools-for-agents)",[20,25,29,33,37],{"title":21,"url":22,"type":23,"note":24,"checked":8},"OpenAI — Function calling","https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Ffunction-calling","官方文档","工具定义、调用 ID、参数与结果回传的 API 契约；执行和授权由应用负责。",{"title":26,"url":27,"type":23,"note":28,"checked":8},"OpenAI — Structured outputs","https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Fstructured-outputs","结构化输出格式与 schema 限制；合法对象不自动保证事实正确。",{"title":30,"url":31,"type":23,"note":32,"checked":8},"Claude — Tool use","https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Foverview","Claude tool_use \u002F tool_result 的调用流程；与其他 API 的字段不能直接互换。",{"title":34,"url":35,"type":23,"note":36,"checked":8},"Claude — Structured outputs","https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fbuild-with-claude\u002Fstructured-outputs","Claude 结构化输出配置与限制；业务规则仍要独立校验。",{"title":38,"url":39,"type":40,"note":41,"checked":8},"Anthropic — Writing effective tools for AI agents","https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fwriting-tools-for-agents","工程报告","工具命名、相关结果和 token 效率的工程方法；优化要保留任务所需信息并评测。",{"slug":43,"title":44,"date":45,"updated":8,"tags":46,"summary":49,"draft":15,"lang":16,"minutes":17},"context-memory-management","上下文与记忆管理：Agent 的长期记忆怎么建","2026-04-21",[12,47,48,10],"上下文管理","记忆","区分会话状态、历史压缩与跨会话记忆；用来源、作用域、版本和有效期治理记忆，解释读写流程、遗忘、权限隔离与可验证的评测。",{"slug":51,"title":52,"date":53,"updated":8,"tags":54,"summary":59,"draft":15,"lang":16,"minutes":60},"rag-03-rerank-citation-eval","RAG 全链路（三）：重排、引用溯源与效果评估","2026-02-17",[55,56,57,58],"RAG","Rerank","评测","可信","按 token 预算选择重排后的证据，区分引用存在、引用支撑与事实正确；分层评估检索、生成和业务结果，并处理资料冲突、缺证据与超时。",5,{"type":62,"children":63},"root",[64,78,83,89,94,103,112,117,283,312,318,330,1151,1163,1175,1181,1194,1204,1209,1230,1236,1241,1254,1267,1273,1308,1313,1318,1323,1334,1339,1345,1358,1363,1376,1381,1416,1428],{"type":65,"tag":66,"props":67,"children":68},"element","p",{},[69,72],{"type":70,"value":71},"text","模型回答“工单已归档”，不代表数据库里真的有记录。Function Calling（工具调用）让模型提出操作请求，由程序执行并回传结果；Structured Outputs（结构化输出）约束回答的数据格式。",{"type":65,"tag":73,"props":74,"children":75},"strong",{},[76],{"type":70,"value":77},"要完成动作，需要执行器；要返回一个对象，需要格式契约。",{"type":65,"tag":66,"props":79,"children":80},{},[81],{"type":70,"value":82},"本文以客户端自定义工具为主，服务端内置工具的执行位置另看厂商文档。接口按 2026 年 10 月核对，例子中的业务工具为示意。",{"type":65,"tag":84,"props":85,"children":87},"h2",{"id":86},"一轮调用发生了什么",[88],{"type":70,"value":86},{"type":65,"tag":66,"props":90,"children":91},{},[92],{"type":70,"value":93},"程序声明工具名称、用途与参数 schema；模型返回调用请求；程序验证、授权并执行；将调用 ID 对应的结果回传；模型继续调用或回答。模型产生调用参数，不因此拥有真实权限。",{"type":65,"tag":66,"props":95,"children":96},{},[97],{"type":65,"tag":98,"props":99,"children":102},"img",{"alt":100,"src":101},"工具调用循环：声明工具、生成调用、验证授权、执行、回传与终止","\u002Fdiagrams\u002Ffunction-calling.svg",[],{"type":65,"tag":66,"props":104,"children":105},{},[106],{"type":65,"tag":107,"props":108,"children":109},"em",{},[110],{"type":70,"value":111},"图 1 · 格式验证、业务授权和真实执行位于程序侧。",{"type":65,"tag":66,"props":113,"children":114},{},[115],{"type":70,"value":116},"不同厂商的字段不能混用：",{"type":65,"tag":118,"props":119,"children":120},"table",{},[121,150],{"type":65,"tag":122,"props":123,"children":124},"thead",{},[125],{"type":65,"tag":126,"props":127,"children":128},"tr",{},[129,135,140,145],{"type":65,"tag":130,"props":131,"children":132},"th",{},[133],{"type":70,"value":134},"接口",{"type":65,"tag":130,"props":136,"children":137},{},[138],{"type":70,"value":139},"工具定义",{"type":65,"tag":130,"props":141,"children":142},{},[143],{"type":70,"value":144},"调用参数",{"type":65,"tag":130,"props":146,"children":147},{},[148],{"type":70,"value":149},"结果关联",{"type":65,"tag":151,"props":152,"children":153},"tbody",{},[154,201,246],{"type":65,"tag":126,"props":155,"children":156},{},[157,163,181,192],{"type":65,"tag":158,"props":159,"children":160},"td",{},[161],{"type":70,"value":162},"OpenAI Responses",{"type":65,"tag":158,"props":164,"children":165},{},[166,173,175],{"type":65,"tag":167,"props":168,"children":170},"code",{"className":169},[],[171],{"type":70,"value":172},"type: function",{"type":70,"value":174},"、",{"type":65,"tag":167,"props":176,"children":178},{"className":177},[],[179],{"type":70,"value":180},"parameters",{"type":65,"tag":158,"props":182,"children":183},{},[184,190],{"type":65,"tag":167,"props":185,"children":187},{"className":186},[],[188],{"type":70,"value":189},"function_call.arguments",{"type":70,"value":191}," 是 JSON 字符串",{"type":65,"tag":158,"props":193,"children":194},{},[195],{"type":65,"tag":167,"props":196,"children":198},{"className":197},[],[199],{"type":70,"value":200},"function_call_output.call_id",{"type":65,"tag":126,"props":202,"children":203},{},[204,209,225,235],{"type":65,"tag":158,"props":205,"children":206},{},[207],{"type":70,"value":208},"OpenAI Chat Completions",{"type":65,"tag":158,"props":210,"children":211},{},[212,217,219],{"type":65,"tag":167,"props":213,"children":215},{"className":214},[],[216],{"type":70,"value":172},{"type":70,"value":218},"、嵌套 ",{"type":65,"tag":167,"props":220,"children":222},{"className":221},[],[223],{"type":70,"value":224},"function",{"type":65,"tag":158,"props":226,"children":227},{},[228,234],{"type":65,"tag":167,"props":229,"children":231},{"className":230},[],[232],{"type":70,"value":233},"tool_calls[].function.arguments",{"type":70,"value":191},{"type":65,"tag":158,"props":236,"children":237},{},[238,240],{"type":70,"value":239},"tool 消息的 ",{"type":65,"tag":167,"props":241,"children":243},{"className":242},[],[244],{"type":70,"value":245},"tool_call_id",{"type":65,"tag":126,"props":247,"children":248},{},[249,254,263,274],{"type":65,"tag":158,"props":250,"children":251},{},[252],{"type":70,"value":253},"Claude Messages",{"type":65,"tag":158,"props":255,"children":256},{},[257],{"type":65,"tag":167,"props":258,"children":260},{"className":259},[],[261],{"type":70,"value":262},"input_schema",{"type":65,"tag":158,"props":264,"children":265},{},[266,272],{"type":65,"tag":167,"props":267,"children":269},{"className":268},[],[270],{"type":70,"value":271},"tool_use.input",{"type":70,"value":273}," 通常已解析成对象",{"type":65,"tag":158,"props":275,"children":276},{},[277],{"type":65,"tag":167,"props":278,"children":280},{"className":279},[],[281],{"type":70,"value":282},"tool_result.tool_use_id",{"type":65,"tag":66,"props":284,"children":285},{},[286,288,294,296,304,306],{"type":70,"value":287},"Claude 的多个客户端工具结果通常放在紧随助手消息的 user 内容块中；OpenAI 按各自接口的结果项或 tool 消息回传。错误标记也不同，",{"type":65,"tag":167,"props":289,"children":291},{"className":290},[],[292],{"type":70,"value":293},"is_error",{"type":70,"value":295}," 不能当作所有接口的通用字段。",{"type":65,"tag":297,"props":298,"children":301},"a",{"href":22,"rel":299},[300],"nofollow",[302],{"type":70,"value":303},"OpenAI 调用文档",{"type":70,"value":305},"与 ",{"type":65,"tag":297,"props":307,"children":309},{"href":31,"rel":308},[300],[310],{"type":70,"value":311},"Claude 调用文档",{"type":65,"tag":84,"props":313,"children":315},{"id":314},"schema格式约束要完整业务含义要清晰",[316],{"type":70,"value":317},"Schema：格式约束要完整，业务含义要清晰",{"type":65,"tag":66,"props":319,"children":320},{},[321,323,328],{"type":70,"value":322},"工具 description 说明何时使用、何时不使用和结果含义；参数尽量用枚举、明确单位与可检验边界。下面是 ",{"type":65,"tag":73,"props":324,"children":325},{},[326],{"type":70,"value":327},"OpenAI Responses 风格",{"type":70,"value":329},"的工具定义：",{"type":65,"tag":331,"props":332,"children":337},"pre",{"className":333,"code":334,"language":335,"meta":336,"style":336},"language-json shiki shiki-themes vitesse-light vitesse-light","{\n  \"type\": \"function\",\n  \"name\": \"get_ticket\",\n  \"description\": \"读取已有工单；只用于存在 ticket_id 的记录，不用于创建、修改或归档工单。\",\n  \"strict\": true,\n  \"parameters\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"ticket_id\": { \"type\": \"string\" },\n      \"options\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"detail\": { \"type\": \"string\", \"enum\": [\"summary\", \"full\"] },\n          \"note\": { \"type\": [\"string\", \"null\"] }\n        },\n        \"required\": [\"detail\", \"note\"],\n        \"additionalProperties\": false\n      }\n    },\n    \"required\": [\"ticket_id\", \"options\"],\n    \"additionalProperties\": false\n  }\n}\n","json","",[338],{"type":65,"tag":167,"props":339,"children":340},{"__ignoreMap":336},[341,353,399,437,475,505,529,567,592,653,678,715,739,859,942,951,1009,1035,1044,1053,1109,1133,1142],{"type":65,"tag":342,"props":343,"children":346},"span",{"class":344,"line":345},"line",1,[347],{"type":65,"tag":342,"props":348,"children":350},{"style":349},"--shiki-default:#999999;--shiki-dark:#999999",[351],{"type":70,"value":352},"{\n",{"type":65,"tag":342,"props":354,"children":356},{"class":344,"line":355},2,[357,363,369,374,379,385,390,394],{"type":65,"tag":342,"props":358,"children":360},{"style":359},"--shiki-default:#99841877;--shiki-dark:#99841877",[361],{"type":70,"value":362},"  \"",{"type":65,"tag":342,"props":364,"children":366},{"style":365},"--shiki-default:#998418;--shiki-dark:#998418",[367],{"type":70,"value":368},"type",{"type":65,"tag":342,"props":370,"children":371},{"style":359},[372],{"type":70,"value":373},"\"",{"type":65,"tag":342,"props":375,"children":376},{"style":349},[377],{"type":70,"value":378},":",{"type":65,"tag":342,"props":380,"children":382},{"style":381},"--shiki-default:#B5695977;--shiki-dark:#B5695977",[383],{"type":70,"value":384}," \"",{"type":65,"tag":342,"props":386,"children":388},{"style":387},"--shiki-default:#B56959;--shiki-dark:#B56959",[389],{"type":70,"value":224},{"type":65,"tag":342,"props":391,"children":392},{"style":381},[393],{"type":70,"value":373},{"type":65,"tag":342,"props":395,"children":396},{"style":349},[397],{"type":70,"value":398},",\n",{"type":65,"tag":342,"props":400,"children":402},{"class":344,"line":401},3,[403,407,412,416,420,424,429,433],{"type":65,"tag":342,"props":404,"children":405},{"style":359},[406],{"type":70,"value":362},{"type":65,"tag":342,"props":408,"children":409},{"style":365},[410],{"type":70,"value":411},"name",{"type":65,"tag":342,"props":413,"children":414},{"style":359},[415],{"type":70,"value":373},{"type":65,"tag":342,"props":417,"children":418},{"style":349},[419],{"type":70,"value":378},{"type":65,"tag":342,"props":421,"children":422},{"style":381},[423],{"type":70,"value":384},{"type":65,"tag":342,"props":425,"children":426},{"style":387},[427],{"type":70,"value":428},"get_ticket",{"type":65,"tag":342,"props":430,"children":431},{"style":381},[432],{"type":70,"value":373},{"type":65,"tag":342,"props":434,"children":435},{"style":349},[436],{"type":70,"value":398},{"type":65,"tag":342,"props":438,"children":440},{"class":344,"line":439},4,[441,445,450,454,458,462,467,471],{"type":65,"tag":342,"props":442,"children":443},{"style":359},[444],{"type":70,"value":362},{"type":65,"tag":342,"props":446,"children":447},{"style":365},[448],{"type":70,"value":449},"description",{"type":65,"tag":342,"props":451,"children":452},{"style":359},[453],{"type":70,"value":373},{"type":65,"tag":342,"props":455,"children":456},{"style":349},[457],{"type":70,"value":378},{"type":65,"tag":342,"props":459,"children":460},{"style":381},[461],{"type":70,"value":384},{"type":65,"tag":342,"props":463,"children":464},{"style":387},[465],{"type":70,"value":466},"读取已有工单；只用于存在 ticket_id 的记录，不用于创建、修改或归档工单。",{"type":65,"tag":342,"props":468,"children":469},{"style":381},[470],{"type":70,"value":373},{"type":65,"tag":342,"props":472,"children":473},{"style":349},[474],{"type":70,"value":398},{"type":65,"tag":342,"props":476,"children":477},{"class":344,"line":60},[478,482,487,491,495,501],{"type":65,"tag":342,"props":479,"children":480},{"style":359},[481],{"type":70,"value":362},{"type":65,"tag":342,"props":483,"children":484},{"style":365},[485],{"type":70,"value":486},"strict",{"type":65,"tag":342,"props":488,"children":489},{"style":359},[490],{"type":70,"value":373},{"type":65,"tag":342,"props":492,"children":493},{"style":349},[494],{"type":70,"value":378},{"type":65,"tag":342,"props":496,"children":498},{"style":497},"--shiki-default:#1E754F;--shiki-dark:#1E754F",[499],{"type":70,"value":500}," true",{"type":65,"tag":342,"props":502,"children":503},{"style":349},[504],{"type":70,"value":398},{"type":65,"tag":342,"props":506,"children":507},{"class":344,"line":17},[508,512,516,520,524],{"type":65,"tag":342,"props":509,"children":510},{"style":359},[511],{"type":70,"value":362},{"type":65,"tag":342,"props":513,"children":514},{"style":365},[515],{"type":70,"value":180},{"type":65,"tag":342,"props":517,"children":518},{"style":359},[519],{"type":70,"value":373},{"type":65,"tag":342,"props":521,"children":522},{"style":349},[523],{"type":70,"value":378},{"type":65,"tag":342,"props":525,"children":526},{"style":349},[527],{"type":70,"value":528}," {\n",{"type":65,"tag":342,"props":530,"children":532},{"class":344,"line":531},7,[533,538,542,546,550,554,559,563],{"type":65,"tag":342,"props":534,"children":535},{"style":359},[536],{"type":70,"value":537},"    \"",{"type":65,"tag":342,"props":539,"children":540},{"style":365},[541],{"type":70,"value":368},{"type":65,"tag":342,"props":543,"children":544},{"style":359},[545],{"type":70,"value":373},{"type":65,"tag":342,"props":547,"children":548},{"style":349},[549],{"type":70,"value":378},{"type":65,"tag":342,"props":551,"children":552},{"style":381},[553],{"type":70,"value":384},{"type":65,"tag":342,"props":555,"children":556},{"style":387},[557],{"type":70,"value":558},"object",{"type":65,"tag":342,"props":560,"children":561},{"style":381},[562],{"type":70,"value":373},{"type":65,"tag":342,"props":564,"children":565},{"style":349},[566],{"type":70,"value":398},{"type":65,"tag":342,"props":568,"children":570},{"class":344,"line":569},8,[571,575,580,584,588],{"type":65,"tag":342,"props":572,"children":573},{"style":359},[574],{"type":70,"value":537},{"type":65,"tag":342,"props":576,"children":577},{"style":365},[578],{"type":70,"value":579},"properties",{"type":65,"tag":342,"props":581,"children":582},{"style":359},[583],{"type":70,"value":373},{"type":65,"tag":342,"props":585,"children":586},{"style":349},[587],{"type":70,"value":378},{"type":65,"tag":342,"props":589,"children":590},{"style":349},[591],{"type":70,"value":528},{"type":65,"tag":342,"props":593,"children":595},{"class":344,"line":594},9,[596,601,606,610,614,619,623,627,631,635,639,644,648],{"type":65,"tag":342,"props":597,"children":598},{"style":359},[599],{"type":70,"value":600},"      \"",{"type":65,"tag":342,"props":602,"children":603},{"style":365},[604],{"type":70,"value":605},"ticket_id",{"type":65,"tag":342,"props":607,"children":608},{"style":359},[609],{"type":70,"value":373},{"type":65,"tag":342,"props":611,"children":612},{"style":349},[613],{"type":70,"value":378},{"type":65,"tag":342,"props":615,"children":616},{"style":349},[617],{"type":70,"value":618}," {",{"type":65,"tag":342,"props":620,"children":621},{"style":359},[622],{"type":70,"value":384},{"type":65,"tag":342,"props":624,"children":625},{"style":365},[626],{"type":70,"value":368},{"type":65,"tag":342,"props":628,"children":629},{"style":359},[630],{"type":70,"value":373},{"type":65,"tag":342,"props":632,"children":633},{"style":349},[634],{"type":70,"value":378},{"type":65,"tag":342,"props":636,"children":637},{"style":381},[638],{"type":70,"value":384},{"type":65,"tag":342,"props":640,"children":641},{"style":387},[642],{"type":70,"value":643},"string",{"type":65,"tag":342,"props":645,"children":646},{"style":381},[647],{"type":70,"value":373},{"type":65,"tag":342,"props":649,"children":650},{"style":349},[651],{"type":70,"value":652}," },\n",{"type":65,"tag":342,"props":654,"children":656},{"class":344,"line":655},10,[657,661,666,670,674],{"type":65,"tag":342,"props":658,"children":659},{"style":359},[660],{"type":70,"value":600},{"type":65,"tag":342,"props":662,"children":663},{"style":365},[664],{"type":70,"value":665},"options",{"type":65,"tag":342,"props":667,"children":668},{"style":359},[669],{"type":70,"value":373},{"type":65,"tag":342,"props":671,"children":672},{"style":349},[673],{"type":70,"value":378},{"type":65,"tag":342,"props":675,"children":676},{"style":349},[677],{"type":70,"value":528},{"type":65,"tag":342,"props":679,"children":681},{"class":344,"line":680},11,[682,687,691,695,699,703,707,711],{"type":65,"tag":342,"props":683,"children":684},{"style":359},[685],{"type":70,"value":686},"        \"",{"type":65,"tag":342,"props":688,"children":689},{"style":365},[690],{"type":70,"value":368},{"type":65,"tag":342,"props":692,"children":693},{"style":359},[694],{"type":70,"value":373},{"type":65,"tag":342,"props":696,"children":697},{"style":349},[698],{"type":70,"value":378},{"type":65,"tag":342,"props":700,"children":701},{"style":381},[702],{"type":70,"value":384},{"type":65,"tag":342,"props":704,"children":705},{"style":387},[706],{"type":70,"value":558},{"type":65,"tag":342,"props":708,"children":709},{"style":381},[710],{"type":70,"value":373},{"type":65,"tag":342,"props":712,"children":713},{"style":349},[714],{"type":70,"value":398},{"type":65,"tag":342,"props":716,"children":718},{"class":344,"line":717},12,[719,723,727,731,735],{"type":65,"tag":342,"props":720,"children":721},{"style":359},[722],{"type":70,"value":686},{"type":65,"tag":342,"props":724,"children":725},{"style":365},[726],{"type":70,"value":579},{"type":65,"tag":342,"props":728,"children":729},{"style":359},[730],{"type":70,"value":373},{"type":65,"tag":342,"props":732,"children":733},{"style":349},[734],{"type":70,"value":378},{"type":65,"tag":342,"props":736,"children":737},{"style":349},[738],{"type":70,"value":528},{"type":65,"tag":342,"props":740,"children":742},{"class":344,"line":741},13,[743,748,753,757,761,765,769,773,777,781,785,789,793,798,802,807,811,815,820,824,829,833,837,841,846,850,855],{"type":65,"tag":342,"props":744,"children":745},{"style":359},[746],{"type":70,"value":747},"          \"",{"type":65,"tag":342,"props":749,"children":750},{"style":365},[751],{"type":70,"value":752},"detail",{"type":65,"tag":342,"props":754,"children":755},{"style":359},[756],{"type":70,"value":373},{"type":65,"tag":342,"props":758,"children":759},{"style":349},[760],{"type":70,"value":378},{"type":65,"tag":342,"props":762,"children":763},{"style":349},[764],{"type":70,"value":618},{"type":65,"tag":342,"props":766,"children":767},{"style":359},[768],{"type":70,"value":384},{"type":65,"tag":342,"props":770,"children":771},{"style":365},[772],{"type":70,"value":368},{"type":65,"tag":342,"props":774,"children":775},{"style":359},[776],{"type":70,"value":373},{"type":65,"tag":342,"props":778,"children":779},{"style":349},[780],{"type":70,"value":378},{"type":65,"tag":342,"props":782,"children":783},{"style":381},[784],{"type":70,"value":384},{"type":65,"tag":342,"props":786,"children":787},{"style":387},[788],{"type":70,"value":643},{"type":65,"tag":342,"props":790,"children":791},{"style":381},[792],{"type":70,"value":373},{"type":65,"tag":342,"props":794,"children":795},{"style":349},[796],{"type":70,"value":797},",",{"type":65,"tag":342,"props":799,"children":800},{"style":359},[801],{"type":70,"value":384},{"type":65,"tag":342,"props":803,"children":804},{"style":365},[805],{"type":70,"value":806},"enum",{"type":65,"tag":342,"props":808,"children":809},{"style":359},[810],{"type":70,"value":373},{"type":65,"tag":342,"props":812,"children":813},{"style":349},[814],{"type":70,"value":378},{"type":65,"tag":342,"props":816,"children":817},{"style":349},[818],{"type":70,"value":819}," [",{"type":65,"tag":342,"props":821,"children":822},{"style":381},[823],{"type":70,"value":373},{"type":65,"tag":342,"props":825,"children":826},{"style":387},[827],{"type":70,"value":828},"summary",{"type":65,"tag":342,"props":830,"children":831},{"style":381},[832],{"type":70,"value":373},{"type":65,"tag":342,"props":834,"children":835},{"style":349},[836],{"type":70,"value":797},{"type":65,"tag":342,"props":838,"children":839},{"style":381},[840],{"type":70,"value":384},{"type":65,"tag":342,"props":842,"children":843},{"style":387},[844],{"type":70,"value":845},"full",{"type":65,"tag":342,"props":847,"children":848},{"style":381},[849],{"type":70,"value":373},{"type":65,"tag":342,"props":851,"children":852},{"style":349},[853],{"type":70,"value":854},"]",{"type":65,"tag":342,"props":856,"children":857},{"style":349},[858],{"type":70,"value":652},{"type":65,"tag":342,"props":860,"children":862},{"class":344,"line":861},14,[863,867,872,876,880,884,888,892,896,900,904,908,912,916,920,924,929,933,937],{"type":65,"tag":342,"props":864,"children":865},{"style":359},[866],{"type":70,"value":747},{"type":65,"tag":342,"props":868,"children":869},{"style":365},[870],{"type":70,"value":871},"note",{"type":65,"tag":342,"props":873,"children":874},{"style":359},[875],{"type":70,"value":373},{"type":65,"tag":342,"props":877,"children":878},{"style":349},[879],{"type":70,"value":378},{"type":65,"tag":342,"props":881,"children":882},{"style":349},[883],{"type":70,"value":618},{"type":65,"tag":342,"props":885,"children":886},{"style":359},[887],{"type":70,"value":384},{"type":65,"tag":342,"props":889,"children":890},{"style":365},[891],{"type":70,"value":368},{"type":65,"tag":342,"props":893,"children":894},{"style":359},[895],{"type":70,"value":373},{"type":65,"tag":342,"props":897,"children":898},{"style":349},[899],{"type":70,"value":378},{"type":65,"tag":342,"props":901,"children":902},{"style":349},[903],{"type":70,"value":819},{"type":65,"tag":342,"props":905,"children":906},{"style":381},[907],{"type":70,"value":373},{"type":65,"tag":342,"props":909,"children":910},{"style":387},[911],{"type":70,"value":643},{"type":65,"tag":342,"props":913,"children":914},{"style":381},[915],{"type":70,"value":373},{"type":65,"tag":342,"props":917,"children":918},{"style":349},[919],{"type":70,"value":797},{"type":65,"tag":342,"props":921,"children":922},{"style":381},[923],{"type":70,"value":384},{"type":65,"tag":342,"props":925,"children":926},{"style":387},[927],{"type":70,"value":928},"null",{"type":65,"tag":342,"props":930,"children":931},{"style":381},[932],{"type":70,"value":373},{"type":65,"tag":342,"props":934,"children":935},{"style":349},[936],{"type":70,"value":854},{"type":65,"tag":342,"props":938,"children":939},{"style":349},[940],{"type":70,"value":941}," }\n",{"type":65,"tag":342,"props":943,"children":945},{"class":344,"line":944},15,[946],{"type":65,"tag":342,"props":947,"children":948},{"style":349},[949],{"type":70,"value":950},"        },\n",{"type":65,"tag":342,"props":952,"children":954},{"class":344,"line":953},16,[955,959,964,968,972,976,980,984,988,992,996,1000,1004],{"type":65,"tag":342,"props":956,"children":957},{"style":359},[958],{"type":70,"value":686},{"type":65,"tag":342,"props":960,"children":961},{"style":365},[962],{"type":70,"value":963},"required",{"type":65,"tag":342,"props":965,"children":966},{"style":359},[967],{"type":70,"value":373},{"type":65,"tag":342,"props":969,"children":970},{"style":349},[971],{"type":70,"value":378},{"type":65,"tag":342,"props":973,"children":974},{"style":349},[975],{"type":70,"value":819},{"type":65,"tag":342,"props":977,"children":978},{"style":381},[979],{"type":70,"value":373},{"type":65,"tag":342,"props":981,"children":982},{"style":387},[983],{"type":70,"value":752},{"type":65,"tag":342,"props":985,"children":986},{"style":381},[987],{"type":70,"value":373},{"type":65,"tag":342,"props":989,"children":990},{"style":349},[991],{"type":70,"value":797},{"type":65,"tag":342,"props":993,"children":994},{"style":381},[995],{"type":70,"value":384},{"type":65,"tag":342,"props":997,"children":998},{"style":387},[999],{"type":70,"value":871},{"type":65,"tag":342,"props":1001,"children":1002},{"style":381},[1003],{"type":70,"value":373},{"type":65,"tag":342,"props":1005,"children":1006},{"style":349},[1007],{"type":70,"value":1008},"],\n",{"type":65,"tag":342,"props":1010,"children":1012},{"class":344,"line":1011},17,[1013,1017,1022,1026,1030],{"type":65,"tag":342,"props":1014,"children":1015},{"style":359},[1016],{"type":70,"value":686},{"type":65,"tag":342,"props":1018,"children":1019},{"style":365},[1020],{"type":70,"value":1021},"additionalProperties",{"type":65,"tag":342,"props":1023,"children":1024},{"style":359},[1025],{"type":70,"value":373},{"type":65,"tag":342,"props":1027,"children":1028},{"style":349},[1029],{"type":70,"value":378},{"type":65,"tag":342,"props":1031,"children":1032},{"style":497},[1033],{"type":70,"value":1034}," false\n",{"type":65,"tag":342,"props":1036,"children":1038},{"class":344,"line":1037},18,[1039],{"type":65,"tag":342,"props":1040,"children":1041},{"style":349},[1042],{"type":70,"value":1043},"      }\n",{"type":65,"tag":342,"props":1045,"children":1047},{"class":344,"line":1046},19,[1048],{"type":65,"tag":342,"props":1049,"children":1050},{"style":349},[1051],{"type":70,"value":1052},"    },\n",{"type":65,"tag":342,"props":1054,"children":1056},{"class":344,"line":1055},20,[1057,1061,1065,1069,1073,1077,1081,1085,1089,1093,1097,1101,1105],{"type":65,"tag":342,"props":1058,"children":1059},{"style":359},[1060],{"type":70,"value":537},{"type":65,"tag":342,"props":1062,"children":1063},{"style":365},[1064],{"type":70,"value":963},{"type":65,"tag":342,"props":1066,"children":1067},{"style":359},[1068],{"type":70,"value":373},{"type":65,"tag":342,"props":1070,"children":1071},{"style":349},[1072],{"type":70,"value":378},{"type":65,"tag":342,"props":1074,"children":1075},{"style":349},[1076],{"type":70,"value":819},{"type":65,"tag":342,"props":1078,"children":1079},{"style":381},[1080],{"type":70,"value":373},{"type":65,"tag":342,"props":1082,"children":1083},{"style":387},[1084],{"type":70,"value":605},{"type":65,"tag":342,"props":1086,"children":1087},{"style":381},[1088],{"type":70,"value":373},{"type":65,"tag":342,"props":1090,"children":1091},{"style":349},[1092],{"type":70,"value":797},{"type":65,"tag":342,"props":1094,"children":1095},{"style":381},[1096],{"type":70,"value":384},{"type":65,"tag":342,"props":1098,"children":1099},{"style":387},[1100],{"type":70,"value":665},{"type":65,"tag":342,"props":1102,"children":1103},{"style":381},[1104],{"type":70,"value":373},{"type":65,"tag":342,"props":1106,"children":1107},{"style":349},[1108],{"type":70,"value":1008},{"type":65,"tag":342,"props":1110,"children":1112},{"class":344,"line":1111},21,[1113,1117,1121,1125,1129],{"type":65,"tag":342,"props":1114,"children":1115},{"style":359},[1116],{"type":70,"value":537},{"type":65,"tag":342,"props":1118,"children":1119},{"style":365},[1120],{"type":70,"value":1021},{"type":65,"tag":342,"props":1122,"children":1123},{"style":359},[1124],{"type":70,"value":373},{"type":65,"tag":342,"props":1126,"children":1127},{"style":349},[1128],{"type":70,"value":378},{"type":65,"tag":342,"props":1130,"children":1131},{"style":497},[1132],{"type":70,"value":1034},{"type":65,"tag":342,"props":1134,"children":1136},{"class":344,"line":1135},22,[1137],{"type":65,"tag":342,"props":1138,"children":1139},{"style":349},[1140],{"type":70,"value":1141},"  }\n",{"type":65,"tag":342,"props":1143,"children":1145},{"class":344,"line":1144},23,[1146],{"type":65,"tag":342,"props":1147,"children":1148},{"style":349},[1149],{"type":70,"value":1150},"}\n",{"type":65,"tag":66,"props":1152,"children":1153},{},[1154,1156,1161],{"type":70,"value":1155},"OpenAI strict schema 要求各对象关闭额外属性，并把属性列入 required；可空字段用 ",{"type":65,"tag":167,"props":1157,"children":1159},{"className":1158},[],[1160],{"type":70,"value":928},{"type":70,"value":1162}," 表示。支持的是 JSON Schema 子集，非任意 schema 都可用。Claude 的声明形式和支持范围按其文档处理，不能只改字段名就保证兼容。",{"type":65,"tag":66,"props":1164,"children":1165},{},[1166,1168,1173],{"type":70,"value":1167},"Strict 降低参数形状错误，",{"type":65,"tag":73,"props":1169,"children":1170},{},[1171],{"type":70,"value":1172},"不保证 ticket_id 存在、归当前用户所有，或模型选对了工具",{"type":70,"value":1174},"。身份、租户和授权范围由会话上下文注入服务端；模型不能通过一个参数把自己变成管理员。",{"type":65,"tag":84,"props":1176,"children":1178},{"id":1177},"工具循环先完整再执行",[1179],{"type":70,"value":1180},"工具循环：先完整，再执行",{"type":65,"tag":66,"props":1182,"children":1183},{},[1184,1186,1192],{"type":70,"value":1185},"以下为框架中立伪代码，",{"type":65,"tag":167,"props":1187,"children":1189},{"className":1188},[],[1190],{"type":70,"value":1191},"provider_adapter",{"type":70,"value":1193}," 负责厂商差异：",{"type":65,"tag":331,"props":1195,"children":1199},{"className":1196,"code":1198,"language":70,"meta":336},[1197],"language-text","for round in bounded_rounds:\n    response = await provider_adapter.generate(state)\n    record_usage_and_status(response)\n    if response.refused or response.incomplete:\n        return explicit_failure(response)\n\n    calls = provider_adapter.complete_calls(response)\n    if calls is empty:\n        return validated_final_answer(response)\n\n    results = bounded_execute(calls, handler = call => {\n        tool = registry.lookup(call.name)        # 未知工具拒绝\n        args = adapter.parse_complete_args(call) # 字符串解析或已解析对象\n        validate_schema_and_business(args)\n        authorize(current_user, tool, args)\n        return execute_with_deadline_and_idempotency(tool, args)\n    })\n    state = adapter.append_response_and_results(state, response, results)\nreturn explicit_failure(\"tool_round_limit\")\n",[1200],{"type":65,"tag":167,"props":1201,"children":1202},{"__ignoreMap":336},[1203],{"type":70,"value":1198},{"type":65,"tag":66,"props":1205,"children":1206},{},[1207],{"type":70,"value":1208},"执行器把校验错误、超时和业务失败转成结构化结果，保留调用 ID；机密、堆栈和内部 SQL 不原样交给模型。流式参数要按调用 ID 聚合，等完整结束才解析，不能用“容错解析”把半截参数执行掉。",{"type":65,"tag":66,"props":1210,"children":1211},{},[1212,1214,1220,1222,1228],{"type":70,"value":1213},"厂商的截断、拒绝、暂停和完成状态分别处理；不能把 Claude 的 ",{"type":65,"tag":167,"props":1215,"children":1217},{"className":1216},[],[1218],{"type":70,"value":1219},"stop_reason",{"type":70,"value":1221}," 套到 Responses 上。",{"type":65,"tag":167,"props":1223,"children":1225},{"className":1224},[],[1226],{"type":70,"value":1227},"tool_choice",{"type":70,"value":1229}," 是否能强制某工具取决于模型与接口，不能笼统说“新模型都已移除”。",{"type":65,"tag":84,"props":1231,"children":1233},{"id":1232},"并行独立读取可以依赖写入不可以",[1234],{"type":70,"value":1235},"并行：独立读取可以，依赖写入不可以",{"type":65,"tag":66,"props":1237,"children":1238},{},[1239],{"type":70,"value":1240},"一个响应可能包含多次调用，但是否并行生成取决于模型与配置。程序不必无条件并发执行：两次独立检索可并发；“创建订单后付款”有依赖，应串行或拆成不同轮。",{"type":65,"tag":66,"props":1242,"children":1243},{},[1244,1246,1252],{"type":70,"value":1245},"并发要有上限、每调用截止时间和部分失败结果。写入工具用业务幂等键、唯一约束或事务防重复；模型请求重试和工具写入去重是不同问题，详见 ",{"type":65,"tag":297,"props":1247,"children":1249},{"href":1248},"\u002Farticles\u002Fllm-fallback-design",[1250],{"type":70,"value":1251},"兜底设计",{"type":70,"value":1253},"。",{"type":65,"tag":66,"props":1255,"children":1256},{},[1257,1259,1265],{"type":70,"value":1258},"对发布、删除、支付等操作，把“草稿生成”与“提交”拆开。模型给出的 ",{"type":65,"tag":167,"props":1260,"children":1262},{"className":1261},[],[1263],{"type":70,"value":1264},"suggested_status",{"type":70,"value":1266}," 只能作为建议；最终状态由授权、业务规则、执行结果或审核机制确认。",{"type":65,"tag":84,"props":1268,"children":1270},{"id":1269},"结构化输出对象合法不等于对象正确",[1271],{"type":70,"value":1272},"结构化输出：对象合法不等于对象正确",{"type":65,"tag":66,"props":1274,"children":1275},{},[1276,1278,1284,1286,1292,1294,1300,1302],{"type":70,"value":1277},"抽取文档字段、分类反馈、生成报告适合结构化输出。Responses 的 ",{"type":65,"tag":167,"props":1279,"children":1281},{"className":1280},[],[1282],{"type":70,"value":1283},"text.format",{"type":70,"value":1285},"、Chat Completions 的 ",{"type":65,"tag":167,"props":1287,"children":1289},{"className":1288},[],[1290],{"type":70,"value":1291},"response_format",{"type":70,"value":1293}," 和 Claude 的 ",{"type":65,"tag":167,"props":1295,"children":1297},{"className":1296},[],[1298],{"type":70,"value":1299},"output_config.format",{"type":70,"value":1301}," 是不同配置位置。",{"type":65,"tag":297,"props":1303,"children":1305},{"href":27,"rel":1304},[300],[1306],{"type":70,"value":1307},"OpenAI 结构化输出",{"type":65,"tag":66,"props":1309,"children":1310},{},[1311],{"type":70,"value":1312},"消费结果前先看完成状态与拒绝，再解析并做 schema、业务校验。合法 JSON 中的日期也可能错误，引用 ID 也可能不存在；格式能力解决结构稳定，正确性仍由任务评测负责。",{"type":65,"tag":84,"props":1314,"children":1316},{"id":1315},"工具体积与权限治理",[1317],{"type":70,"value":1315},{"type":65,"tag":66,"props":1319,"children":1320},{},[1321],{"type":70,"value":1322},"工具定义和结果占上下文，缓存只是改变重复处理成本。按任务加载工具、合并重叠工具、分页和按需读取都值得比较，工具数量没有统一的“最多十个”上限。",{"type":65,"tag":66,"props":1324,"children":1325},{},[1326,1328,1333],{"type":70,"value":1327},"大结果可返回摘要与受控引用，注明截断、总条数和后续 cursor；外部系统之间用有授权的 artifact ID，不能假设对方可读取本地路径。按角色少暴露工具有助于路由，",{"type":65,"tag":73,"props":1329,"children":1330},{},[1331],{"type":70,"value":1332},"执行侧仍必须授权",{"type":70,"value":1253},{"type":65,"tag":66,"props":1335,"children":1336},{},[1337],{"type":70,"value":1338},"工具结果包含网页、日志等不受信任内容。模型读到“执行删除”的文字，不应因此获得删除能力。工具注册表、授权与高风险提交规则才是边界。",{"type":65,"tag":84,"props":1340,"children":1342},{"id":1341},"openai-与-anthropic格式契约之外怎样改善工具使用",[1343],{"type":70,"value":1344},"OpenAI 与 Anthropic：格式契约之外怎样改善工具使用",{"type":65,"tag":66,"props":1346,"children":1347},{},[1348,1350,1356],{"type":70,"value":1349},"OpenAI 的 Function Calling 与 Structured Outputs 文档提供 API 层面的 schema 和回传契约；Anthropic 的 ",{"type":65,"tag":297,"props":1351,"children":1353},{"href":39,"rel":1352},[300],[1354],{"type":70,"value":1355},"Writing effective tools",{"type":70,"value":1357},"则从 Agent 使用工具的行为出发，讨论工具选择、命名、返回相关信息与 token 效率。两者可以结合：schema 限制格式，工具设计帮助模型正确选择和理解。",{"type":65,"tag":66,"props":1359,"children":1360},{},[1361],{"type":70,"value":1362},"工程推导：固定模型、任务集和业务权限，分别比较工具描述、重叠接口数量、结果字段与简洁\u002F详细模式。记录误选、参数错误、缺失 ID、重试次数和最终任务成功率；精简结果时保留后续动作所需的稳定 ID，不能只追求 token 最少。以相同预算比较，避免把工具优化与换模型的收益混在一起。",{"type":65,"tag":66,"props":1364,"children":1365},{},[1366,1368,1374],{"type":70,"value":1367},"执行循环与审批边界由",{"type":65,"tag":297,"props":1369,"children":1371},{"href":1370},"\u002Farticles\u002Fproduction-agent-design",[1372],{"type":70,"value":1373},"生产架构篇",{"type":70,"value":1375},"继续展开。",{"type":65,"tag":84,"props":1377,"children":1379},{"id":1378},"落地检查",[1380],{"type":70,"value":1378},{"type":65,"tag":1382,"props":1383,"children":1384},"ol",{},[1385,1391,1396,1401,1406,1411],{"type":65,"tag":1386,"props":1387,"children":1388},"li",{},[1389],{"type":70,"value":1390},"API 适配器独立处理字段与回传格式。",{"type":65,"tag":1386,"props":1392,"children":1393},{},[1394],{"type":70,"value":1395},"strict schema 校验完整，同时校验业务含义和身份权限。",{"type":65,"tag":1386,"props":1397,"children":1398},{},[1399],{"type":70,"value":1400},"流式调用参数完整后执行，按调用 ID 记录状态。",{"type":65,"tag":1386,"props":1402,"children":1403},{},[1404],{"type":70,"value":1405},"并行只用于独立操作，写入有幂等与审批语义。",{"type":65,"tag":1386,"props":1407,"children":1408},{},[1409],{"type":70,"value":1410},"限制轮数、并发、时间、费用和结果体积。",{"type":65,"tag":1386,"props":1412,"children":1413},{},[1414],{"type":70,"value":1415},"回归覆盖未知工具、截断、拒绝、重复调用和越权。",{"type":65,"tag":66,"props":1417,"children":1418},{},[1419,1421,1427],{"type":70,"value":1420},"长任务还需要 ",{"type":65,"tag":297,"props":1422,"children":1424},{"href":1423},"\u002Farticles\u002Fcontext-memory-management",[1425],{"type":70,"value":1426},"上下文与记忆管理",{"type":70,"value":1253},{"type":65,"tag":84,"props":1429,"children":1431},{"id":1430},"参考资料",[1432],{"type":70,"value":1430},[1434,1435,1436,1437,1438,1439,1440,1441,1442],{"id":86,"depth":355,"text":86},{"id":314,"depth":355,"text":317},{"id":1177,"depth":355,"text":1180},{"id":1232,"depth":355,"text":1235},{"id":1269,"depth":355,"text":1272},{"id":1315,"depth":355,"text":1315},{"id":1341,"depth":355,"text":1344},{"id":1378,"depth":355,"text":1378},{"id":1430,"depth":355,"text":1430},1792400815607]