> ## 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.

# 出力と再試行

> 最終出力を検証し、モデル呼び出しを再試行して、完了したRuby実行を確認します。

後続のRubyコードで予測可能な結果形式が必要な場合は出力を検証します。モデルの再試行は一時的なリクエスト障害を対象とします。副作用を伴うツールの再試行は、明示的かつ冪等にしてください。

## 再試行を設定する

```ruby theme={null}
agent = PhaseoAgentSdk.create_agent(
  id: "research-agent",
  model: "openai/gpt-5.4-nano",
  model_retry: PhaseoAgentSdk::ModelRetryConfig.new(
    max_retries: 3,
    base_delay_ms: 500,
    max_delay_ms: 4_000
  )
)
```

結果には実行レコード、ステップ、メッセージ、正規化された使用量、停止理由、最終出力が含まれます。

```ruby theme={null}
result = agent.run(input: prompt, client: client)

puts result.output
puts result.run.status
puts result.usage[:total_tokens]
puts 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.