> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 输出与重试

> 验证最终输出、重试模型请求，并检查已完成的 Go 运行。

通过输出验证，确保 Agent 返回值符合应用预期的契约。模型重试针对失败的模型请求；工具重试必须在工具实现中明确处理，并且仅在安全时使用。

## 配置模型重试

```go theme={null}
agent := phaseoagent.CreateAgent(phaseoagent.AgentDefinition{
  ID: "research-agent",
  Model: "openai/gpt-5.4-nano",
  ModelRetry: phaseoagent.ModelRetryConfig{
    MaxRetries: 3,
    BaseDelay:  500 * time.Millisecond,
    MaxDelay:   4 * time.Second,
  },
})
```

运行记录会保留每个步骤的模型尝试次数。重试不会丢弃已完成的工具结果。

## 验证最终结果

如果后续代码需要结构化结果，请在 `AgentDefinition` 上设置 `OutputSchema`。系统会在将结果标记为完成之前验证，因此无效输出会在 Agent 边界处失败，而不是稍后在应用中才失败。

## 查看结果

```go theme={null}
result, err := agent.Run(ctx, phaseoagent.RunOptions{Input: prompt, Client: client})
if err != nil { return err }

fmt.Println(result.Output)
fmt.Println(result.Run.Status)
fmt.Println(result.Usage.TotalTokens)
fmt.Println(result.Usage.Cost)
```

使用[停止条件](./agent-sdk-stop-conditions.mdx)设置预算和硬性限制，并参考[错误与故障排查](./agent-sdk-observability.mdx)处理故障。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.