> ## 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 Agent SDK 运行工具循环、人工审核、重试和可恢复的 Agent。

## 准备运行环境

Agent SDK gem 尚未发布到 RubyGems。请按照[从源代码安装的说明](./agent-sdk-installation.mdx)进行操作。

## 快速入门

```ruby theme={null}
require "phaseo_agent_sdk"

agent = PhaseoAgentSdk.create_agent(
  id: "quickstart-agent",
  model: "openai/gpt-5.4-nano",
  instructions: "Answer concisely and helpfully."
)

result = agent.run(
  input: "Give me one fun fact about cURL.",
  client: PhaseoAgentSdk.create_gateway_agent_client
)

puts result.output
```

## 包含内容

* `PhaseoAgentSdk.create_agent(...)`
* `PhaseoAgentSdk.define_tool(...)`
* `PhaseoAgentSdk.create_gateway_agent_client(...)`
* 基于 Phaseo `responses` API 的有限工具循环

## 高级运行时

Ruby 支持验证和审批回调、HITL 与手动工具、进度、可恢复错误、可重放枚举器、停止辅助方法、动态轮次、持久化的下一轮参数、规范化用量/成本，以及鸭子类型状态访问器。

## 流式传输与取消

`Agent#stream(...)` 和 `Agent#continue_stream(...)` 会在工作线程中读取网关的 Responses SSE 流。可使用 `text_stream`、`reasoning_stream`、`item_stream` 或 `full_stream`；调用 `cancel` 可停止工作线程并关闭 HTTP 流。已完成步骤会保留请求 ID、供应商元数据、结束原因、警告、用量和成本。

## 相关内容

* [Agent SDK 概览](../agent-sdk/overview.mdx)
* [TypeScript Agent SDK](../typescript/agent-sdk.mdx)


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