- 一个本地查询工具
- 一个范围明确的 Agent 循环
- 一种严格的 JSON 输出结构
1. 准备 SDK
Python Agent SDK 包尚未发布到 PyPI。请参阅从源代码安装说明。
2. 定义本地工具
3. 创建 Agent
4. 通过网关客户端运行 Agent
5. 适用场景
- 由一个 Python 工作进程负责编排
- 工具接口位于本地且行为确定
- 你想先获得严格输出,再构建更大的编排层
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
使用 Python Agent SDK 构建范围明确的本地工具循环,并通过 Phaseo Gateway 返回严格 JSON。
from phaseo_agent import AgentTool, define_tool
lookup_policy = define_tool(
AgentTool(
id="lookup-policy",
description="Look up one internal policy by slug.",
parameters={
"type": "object",
"properties": {
"slug": {"type": "string"},
},
"required": ["slug"],
"additionalProperties": False,
},
execute=lambda input, ctx: {
"slug": input["slug"],
"summary": "Presets centralize routing, prompts, and caching defaults.",
},
)
)
from phaseo_agent import create_agent
agent = create_agent(
{
"id": "policy-extractor",
"model": "openai/gpt-5.4-nano",
"instructions": "Use tools when needed and return concise JSON.",
"tools": [lookup_policy],
"parse_output": lambda text: text,
}
)
from phaseo_agent import create_gateway_agent_client
result = agent.run(
input="Look up presets and return JSON with keys summary and recommendation.",
client=create_gateway_agent_client(),
)
print(result.output)