agentleFS
zendev-shzendev-sh/goai/AGENTS.md

goai

AGENTS.md242 starsChanged 8 months agoMITView on GitHub

Instructions for AI contributors working on the GoAI codebase. GoAI is a Go SDK for AI applications - one API across 25+ LLM providers. Inspired by Vercel AI SDK, adapted to Go idioms.

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Vercel AI SDK is the reference: - check Vercel source before modifying provider behavior

    line 69
  2. Very specific:

    errors.As, not type assertion: - always errors.As(err, &apiErr), never err.(*APIError)

    line 72
  3. Very specific:

    Lock-free network calls: - never hold a mutex during I/O (see CachedTokenSource)

    line 74

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md - GoAI

Instructions for AI contributors working on the GoAI codebase.

Commands

go build ./...          # Build
go test ./...           # Test all packages
go test -cover ./...    # Test with coverage
golangci-lint run       # Lint
go test ./provider/openai/  # Test single package

Architecture

GoAI is a Go SDK for AI applications - one API across 25+ LLM providers. Inspired by Vercel AI SDK, adapted to Go idioms.

goai/
├── generate.go             # GenerateText, StreamText
├── object.go               # GenerateObject[T], StreamObject[T]
├── embed.go                # Embed, EmbedMany
├── image.go                # GenerateImage
├── video.go                # GenerateVideo
├── realtime.go             # OpenRealtimeSession (experimental realtime voice sessions)
├── options.go              # WithPrompt, WithTools, etc.
├── schema.go               # SchemaFrom[T] - JSON Schema from Go structs
├── errors.go               # APIError, ContextOverflowError
├── retry.go                # Exponential backoff (errors.As, not type assertion)
├── caching.go              # Prompt cache control (copies msgs, no mutation)
├── types.go                # Tool struct
├── messages.go             # Message builders
├── hooks.go                # Telemetry hooks
├── partial_json.go         # Partial JSON parser for streaming
├── provider/
│   ├── provider.go         # LanguageModel, EmbeddingModel, ImageModel, VideoModel, RealtimeModel interfaces
│   ├── realtime.go         # Realtime audio formats, params, events, capabilities
│   ├── types.go            # Message, Part, Usage, StreamChunk
│   ├── token.go            # TokenSource, CachedTokenSource (lock-free fetch)
│   ├── openai/             # OpenAI (Chat Completions + Responses API)
│   ├── anthropic/          # Anthropic (Messages API)
│   ├── google/             # Google Gemini (REST + Live realtime)
│   ├── bedrock/            # AWS Bedrock (Converse API + SigV4 + EventStream, RWMutex for fallback; InvokeModel API for embeddings)
│   ├── vertex/             # Vertex AI
│   ├── azure/              # Azure OpenAI
│   ├── cohere/             # Cohere (Chat v2 + Embed)
│   ├── minimax/            # MiniMax (Anthropic-compat, delegates to anthropic/)
│   ├── compat/             # Generic OpenAI-compatible
│   └── <24 more>/          # Mostly OpenAI-compat (some via compat/ or anthropic/ wrappers)
│ # tools.go files: 5 files with provider-defined tools: anthropic/ (14 tools), openai/ (4 tools), google/ (5 tools), xai/ (2 tools), groq/ (1 tool)
├── internal/
│   ├── openaicompat/       # Shared codec for 25 provider implementation files
│   ├── gemini/             # Schema sanitization (Vertex, Google)
│   ├── sse/                # SSE parser
│   ├── httpc/              # HTTP helpers + ParseDataURL
│   └── realtimews/         # Provider-neutral WebSocket transport for realtime adapters
├── mcp/                    # MCP (Model Context Protocol) client
├── observability/
│   ├── langfuse/           # Langfuse observability integration (separate go.mod)
│   └── otel/               # OpenTelemetry tracing and metrics (separate go.mod)
├── examples/               # 33 runnable examples (including 8 MCP examples)
└── bench/                  # Performance benchmarks (GoAI vs Vercel AI SDK)

Key Rules

  1. Keep dependencies minimal - core runtime: direct golang.org/x/oauth2 and github.com/coder/websocket (realtime transport, zero transitive deps), indirect cloud.google.com/go/compute/metadata for ADC; go.uber.org/goleak is test-only. Optional submodules (observability/langfuse, observability/otel) use separate go.mod.
  2. Vercel AI SDK is the reference - check Vercel source before modifying provider behavior
  3. 90% test coverage per package - mock HTTP servers, not internals
  4. Interface compliance checks - provider structs should include compile-time checks (type name may vary, e.g. *chatCompletionsModel)
  5. errors.As, not type assertion - always errors.As(err, &apiErr), never err.(*APIError)
  6. No input mutation - functions must copy slices/maps before modifying (see applyCaching)
  7. Lock-free network calls - never hold a mutex during I/O (see CachedTokenSource)
  8. Shared utilities in internal/ - parseDataURL lives in httpc, not duplicated per provider

Adding Providers

OpenAI-compatible providers use internal/openaicompat. Pattern:

var _ provider.LanguageModel = (*chatModel)(nil)

func Chat(modelID string, opts ...Option) provider.LanguageModel { ... }
func (m *chatModel) DoGenerate(ctx, params) (*provider.GenerateResult, error) { ... }
func (m *chatModel) DoStream(ctx, params) (*provider.StreamResult, error) { ... }

Provider options should be idiomatic and consistent where applicable. Common options are WithAPIKey, WithTokenSource, WithBaseURL, WithHTTPClient, WithHeaders; provider-specific exceptions are acceptable (for example azure.WithEndpoint, ollama without auth options).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.