Sdk Go 标志

Sdk Go

组织热门
GetStream
sdk-go

How the Go SDK in sdks/go is built, tested and released. Read before changing sdks/go, adding a resource method, or cutting a Go SDK version.

概览

发布者GetStream
代码仓库Agents
技能名称sdk-go
星标数
8.2K
复刻数
709
附带文件
仅含指令
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 GetStream 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Sdk Go AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/GetStream/Agents/tree/main/.claude/skills/sdk-go
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/GetStream/Agents.git /tmp/Agents
mkdir -p .claude/skills
cp -r /tmp/Agents/.claude/skills/sdk-go .claude/skills/sdk-go
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Sdk Go,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Sdk Go。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Sdk Go 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Go SDK conventions

The per-language half of sdk for sdks/go, module github.com/GetStream/Vision-Agents/sdks/go. Go goes first (AGENTS.md "SDK changes"), so a shared API change lands here before the other SDKs. Write the Go itself by the go and go-testing skills.

Layout

PackageWhat it is
agentsAn agent spelled out in code: agents.New, folder sync, tools, phone, dispatch workers (agents.NewDispatch). What most programs start from
clientAgents addressed by name (client.New(backend).Agent("docs")), their sessions, responses, items, forks, guests, usage callbacks
streamBackend (where the router is, who is billed), Pipeline (one session and its socket), RouterError, routers (stream.NewClient(backend).Router(name)), phone
toolsThe function registry and the JSON Schema read off an argument struct
edgeStream Video calls and the monitor link, through getstream-go
accelerationGenerated from the spec. Never edited by hand

stream.Backend is the one value every package shares. A client's Backend() carries its usage watcher, so an agent, worker or router built on it reports to that client's WithUsage and WithBalanceWarning; client.New with no options on such a backend shares the watcher rather than wrapping it twice.

Go version

Always keep the SDK to latest version of Golang

Dependencies

  • Always update dependencies to latest version
  • Changes to dependencies cannot break the public API

The generated client

go generate ./... in sdks/go runs oapi-codegen on ../../acceleration/api/openapi.yaml with api/oapi-codegen.yaml, which leaves out the Staff operations and the four socket operations: stream holds the three it uses by hand on stream/socket.go, and openSocketSession has no Go client yet. The output is committed; CI's go job regenerates it and fails on a diff.

Models public, operations not:

  • Generated types (acceleration.Session, AgentConfig, SttOptions, enums) are the SDK's models and may appear in signatures. Do not wrap one for its own sake.
  • Generated operations (*WithResponse) are never the API: README, examples and docs call a method of client, agents or stream. A new endpoint is finished when it has one.
  • stream.Backend.Client() and agents.Agent.Client() hand out the generated client for an operation with no method yet. Their doc comments say it carries no compatibility promise; keep that true and add no third accessor.
  • A parameter never takes *acceleration.ClientWithResponses. Take a stream.Backend.

Known gaps, generated only (docs on getstream.io call some of them raw today): simulations and their runs, voices, knowledge documents and URLs beyond ingest and add, scheduled tasks, campaigns, channels, connectors, a connection's credentials and tools, SIP trunks, 10DLC and opt-outs, phone transfer, digits and release, account, credits, spend limits, usage events, teams, prices, stats, policies, provider keys, runs, OCR and classify. Folder sync does not read resume_history: from agent.yaml yet, so one that names it is refused.

Errors, retries and idempotency

  • Every refusal is a *stream.RouterError, built by stream.NewRouterError from the answer. Transport failures are wrapped with %w, so errors.Is(err, context.Canceled) holds.
  • The SDK retries no HTTP request: it cannot know which of the caller's are safe to send twice. RouterError.RetryAfter says how long the router asked for.
  • Responses.Create sends a fresh request_id per text question, so the router answers a resend once. A tool call is keyed by its id (tools.Registry receipts), so a call the router sends again is joined or answered from its first result.
  • A text session's socket is the one thing reconnected: doubling waits from one second to 30, for five minutes (Pipeline.firstRetry, resumeFor), giving up on a 4xx other than 429.

Tests

bash
cd sdks/go
go test -race ./...
go vet ./... && go vet -tags e2e .

No mocks: each package has its own stand-in router, an httptest.Server with a real gorilla upgrader (router in client/client_test.go and stream/accelerated_test.go, restartable and reopened in stream/resume_test.go, pool in stream/dispatch_test.go, worked in agents/dispatch_test.go, backend in agents/agent_test.go, moneyRouter in client/usage_test.go, vendors in stream/phone_test.go). Reuse the package's own before writing another. readme_test.go holds the README's quickstart to examples/quickstart.

e2e_test.go (tag e2e) drives a real router and real models, so it costs money and never runs in CI. Without STREAM_ACCELERATION_URL it skips; with E2E_REQUIRED=1 every skip fails instead. Its package comment names the release smoke set; run it against a router that searches, holds knowledge and bills:

bash
E2E_REQUIRED=1 go test -tags e2e -count=1 -v -run "$SMOKE" .

README

The README renders on pkg.go.dev too, where only links inside the module resolve: a link outside sdks/go is an absolute https://github.com/GetStream/Vision-Agents/tree/main/.... Every identifier in a code block exists; the quickstart is the example file verbatim.

Releasing

sdks/go is developed and released on main, the default branch, so go get ...@latest, @main and pkg.go.dev see it. A version is a tag sdks/go/vX.Y.Z on a main commit; nothing is copied. While 0.x, a minor may break a signature; a patch only fixes.

  1. Land the change on main by a pull request, with Version in stream/backend.go set to X.Y.Z: it is the User-Agent every request sends (stream-agents-go/X.Y.Z) and its X-Stream-Client (stream-agents-go-vX.Y.Z), and nothing else sets it. release-sdk-go.yml fails a tag whose Version differs. If the change breaks a signature or field, add one line under # Unreleased → Breaking Changes in the root CHANGELOG.md. The Go SDK steps of the CI (SDKs) workflow (.github/workflows/ci-sdks.yml) check sdks/go alone on Go 1.25, as a consumer gets it.

  2. Check out the commit to tag (git switch --detach <the main commit>), run the smoke set from sdks/go with E2E_REQUIRED=1, as above, and keep its output, so the result is the tagged commit's.

  3. Tag the commit that holds the change by its SHA, not whatever main is by then. Never create a GitHub Release for it: release.yml publishes the Python packages on a release. Check its Version first, as below: the proxy takes a pushed tag before the workflow runs, so a tag the workflow refuses stays public (v0.5.0 did).

    bash
    set -euo pipefail   # a failed check below stops before the tag
    git fetch origin
    SHA=<the main commit>
    git merge-base --is-ancestor "$SHA" origin/main   # exits 0, else the script stops
    git show "$SHA:sdks/go/stream/backend.go" | grep -q 'Version = "X.Y.Z"'   # the workflow's own check
    git tag sdks/go/vX.Y.Z "$SHA"
    git push origin sdks/go/vX.Y.Z
  4. release-sdk-go.yml runs on the tag: it checks the tag is on main, checks the tagged copy and builds the quickstart in an empty module through proxy.golang.org. By hand, with GOPRIVATE cleared:

    bash
    GOPRIVATE= GONOSUMDB= GOFLAGS=-mod=mod GOPROXY=https://proxy.golang.org \
      go list -m -versions github.com/GetStream/Vision-Agents/sdks/go

A version found broken is never moved or deleted: the proxy and the checksum database keep it. Add retract vX.Y.Z // why to sdks/go/go.mod on main, and release the next patch the same way; @latest then skips the retracted one.

Reject in review

  • A *WithResponse call in the README, an example or a docs page where a method exists.
  • A parameter of a generated client type, or a new accessor for the generated client.
  • A retry of an HTTP request without an owner, a bound and a named threat (AGENTS.md).
  • A stdlib or language feature newer than the go directive.

常见问题

Sdk Go AI 技能有什么作用?

How the Go SDK in sdks/go is built, tested and released. Read before changing sdks/go, adding a resource method, or cutting a Go SDK version.

为什么在 TypingMind 中使用 Sdk Go?

因为您只需安装一次,就能搭配任何模型使用。Sdk Go 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Sdk Go?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/GetStream/Agents/tree/main/.claude/skills/sdk-go。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Sdk Go?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Sdk Go 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Sdk Go 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Sdk Go AI 技能免费吗?

是的。GetStream 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇