Strands Agents + Ertas
使用 Strands Agents 建構代理——AWS 的開源 SDK,採用模型驅動規劃而非硬編碼工作流程,並與 Bedrock 與 Anthropic API 一同完整支援 Ertas 訓練本地模型。
Overview
Strands Agents 是 AWS 的開源代理 SDK,作為更廣泛推動的一部分釋出,目的是讓 AWS 客戶有第一方的 LangChain 與 CrewAI 替代品。其決定性的設計選擇是仰賴模型驅動規劃,而非手動編碼的工作流程圖——代理基於模型對任務的理解來推理下一步該做什麼,SDK 圍繞該推理迴圈處理工具執行、重試與可觀測性。到 2026 年 5 月,SDK 不到一年總下載量已超過 1400 萬,部分原因是它在 AWS 自家產品(Amazon Q、AWS Glue、Amazon Connect Contact Lens)內部使用。TypeScript SDK 於 2026 年 5 月 1 日達到 1.0 GA,為 Node.js 與瀏覽器環境帶來與 Python 執行期的對等性——這對行動 app 後端與 Vercel/Cloudflare 邊緣部署特別相關。
框架的輕量級設計是刻意的。LangGraph 要求預先的圖定義、CrewAI 要求明確的角色/目標設定,而 Strands 讓模型在執行期自行找出工作流程,由 SDK 圍繞該決策提供鷹架(工具呼叫、可觀測性、重試)。對於直接的代理任務,這帶來更少程式碼與更快開發;對於高度結構化的工作流程——當模型規劃不可靠時——團隊可在其上分層自訂編排。
Strands 模型無關。SDK 隨附 Amazon Bedrock、Anthropic、OpenAI 與 Ollama 的一級 provider,外加可適配任何 OpenAI 相容端點的通用 LiteLLM provider。對於想要 AWS 開發者人體工學與可觀測性故事,但計畫部署於自託管模型——出於成本或資料主權原因——的團隊,與 Ertas 訓練推論的整合只需幾行設定。
How Ertas Integrates
Ertas 訓練的模型透過 Strands Agents 的 OllamaModel provider 或其通用 LiteLLM provider 協同運作。在 Studio 微調並匯出為 GGUF 後,你透過 Ollama、vLLM 或 Ertas Cloud 提供模型服務,再以指向你端點的適當 provider 設定 Strands 的代理。模型驅動規劃、可觀測性與重試原語全都透明地運作。
模型驅動規劃方式與微調模型搭配特別強大。通用的 7B–14B 模型在領域特定任務上常做出不一致的規劃決策,這迫使團隊轉向更明確的編排。Ertas 訓練模型——其訓練資料包含來自目標領域的代表性規劃軌跡——產生更一致且更勝任的規劃,讓 Strands 的輕量設計在生產中能撐住,而非降格為臨時的權宜之計。
對於已在 AWS 生態系內想要控制推論成本的團隊,在 EC2(或本地端)上 Strands + Ertas 訓練模型產生一個契合 AWS 架構但保持每任務經濟模型固定的代理堆疊。可觀測性流入 Amazon CloudWatch 與 AWS X-Ray;追蹤資料回饋至 Studio 用於漸進式微調。
Getting Started
- 1
在 Ertas Studio 微調領域特定模型
在包含來自目標領域代表性規劃軌跡的資料上訓練。Strands 仰賴模型做出規劃決策,因此訓練資料品質直接改善代理可靠性。
- 2
部署到 OpenAI 相容端點
匯出為 GGUF 並透過 Ollama、vLLM 或 Ertas Cloud 提供服務。Strands 的 OllamaModel provider 直接連接;LiteLLM provider 連接任何相容替代品。
- 3
安裝 Strands Agents 並設定模型
安裝 strands-agents。建立一個以 OllamaModel(或 LiteLLM)provider 設定指向你推論端點的 Agent。
- 4
將工具定義為型別化 Python 函式
使用 Strands 的 @tool 裝飾器加入工具。Strands 的輕量設計意味著很少樣板程式碼——函式簽章與 docstring 通常足以讓模型正確使用工具。
- 5
以內建可觀測性執行
呼叫代理。追蹤流入 AWS X-Ray(或你的可觀測性後端)。透過檢查追蹤並回饋至 Studio 進行下一輪訓練,迭代代理的規劃行為。
from strands import Agent, tool
from strands.models.ollama import OllamaModel
# Point Strands at your Ertas-trained model served via Ollama
model = OllamaModel(
host="http://localhost:11434",
model_id="ertas-aws-ops-7b",
)
@tool
def list_running_instances(region: str) -> list[dict]:
"""Return a list of running EC2 instances in a region."""
return ec2.list_instances(region, state="running")
@tool
def stop_instance(instance_id: str) -> dict:
"""Stop an EC2 instance by ID."""
return ec2.stop(instance_id)
agent = Agent(
model=model,
tools=[list_running_instances, stop_instance],
system_prompt="You manage EC2 fleets — find idle instances and stop them when asked.",
)
# Strands lets the model plan the multi-step workflow itself
result = agent("Find any t3.micro instances in us-west-2 that have been idle for >24h and stop them.")
print(result.message)Benefits
- 模型驅動規劃——比 LangGraph 或 CrewAI 更少編排程式碼
- 輕量級 SDK——最小的概念負擔
- 一級 AWS 整合——Bedrock、CloudWatch、X-Ray 可觀測性
- 多 provider 模型支援:Bedrock、Anthropic、OpenAI、Ollama、通用 LiteLLM
- 在 AWS 自家產品(Amazon Q、Glue、Connect)中經生產測試
- 與 Ertas 微調搭配,使模型驅動規劃在領域任務上可靠
Related Resources
Fine-Tuning
Function Calling
Inference
Fine-Tuning for Tool Calling: How to Build Reliable AI Agents with Small Models
Building Reliable AI Agents with Fine-Tuned Local Models: Complete Guide
Stop Paying GPT-4 to Call Your APIs: Fine-Tune a Local Tool-Calling Model
LangGraph
Ollama
OpenAI Agents SDK
Pydantic AI
vLLM
Ertas for SaaS Product Teams
Ertas for AI Automation Agencies
Ertas for Internal Knowledge Bases
Ship AI that runs on your users' devices.
Early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.