# 第七章：模型集成与输出治理

## 章引言

模型集成是智能体系统与 LLM 的边界。设计不当的集成会导致：

* 幻觉（输出不真实信息）
* 性能问题（过度推理、Token浪费）
* 安全隐患（输出不可控）
* 兼容性问题（难以支持多个模型）

本章研究如何设计一个健壮、灵活、高效的模型集成层，包括多模型切换、输出解析、质量门控、幻觉检测等机制。

## 核心设计问题

1. **模型抽象**：如何设计统一接口支持多个模型（Claude、GPT、DeepSeek 等）？
2. **输出解析**：如何从原始 API 响应中安全地提取和验证结构化输出？
3. **质量保证**：在工具调用执行前如何验证输出的合法性？
4. **幻觉检测**：如何识别和防止智能体调用不存在的工具或生成错误的参数？

## 参考系统的方法

**OpenClaw**：支持 Claude/GPT/DeepSeek/Gemini/Ollama，带模型回退链路

**Claude Code**：绑定 Claude，专注于输出质量和推理预算管理

## 本章结构

* 7.1：模型抽象层
* 7.2：结构化输出解析
* 7.3：输出质量门控
* 7.4：幻觉检测与修复
* 7.5：推理预算管理
* 7.6：MiniHarness 输出治理
* 本章小结

模型集成层是智能体可靠性的最后防线。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/harness_engineering_guide/di-er-bu-fen-harness-he-xin-zi-xi-tong/07_model_integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
