> ## 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パターンを活用できます。

## 承認付きデプロイ

```go theme={null}
deploy := phaseoagent.Tool{
  ID: "deploy",
  Description: "Deploy the selected release",
  RequireApproval: true,
  Execute: func(input any, runtime phaseoagent.RuntimeContext) (any, error) {
    return deploymentService.Deploy(runtime.Context, input)
  },
}
```

エージェントを実行し、状態が`waiting_for_human`になったら返されたレコードを保存します。保留中のツール呼び出しIDに紐づく判断を指定して再開します。

## ターミナルにストリーミングする

```go theme={null}
stream := agent.Stream(ctx, phaseoagent.RunOptions{Input: prompt, Client: client})
for delta := range stream.Text() { fmt.Print(delta) }
result, err := stream.Result()
```

## 自律的な調査に上限を設ける

`StepCountIs`、`MaxTokensUsed`、`MaxCost`、`MaxDuration`を組み合わせると、有用な作業が続いても長時間実行されるエージェントがプロダクトの予算を超えません。

契約の詳細は、[ツール](./agent-sdk-tools.mdx)、[状態と承認](./agent-sdk-state-and-approval.mdx)、[停止条件](./agent-sdk-stop-conditions.mdx)を参照してください。


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