一键导入
provider-patterns
Configure per-provider behavior, understand streaming quirks, and use the 5-hook adapter system for optimal performance across LLM providers.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Configure per-provider behavior, understand streaming quirks, and use the 5-hook adapter system for optimal performance across LLM providers.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | provider-patterns |
| description | Configure per-provider behavior, understand streaming quirks, and use the 5-hook adapter system for optimal performance across LLM providers. |
| compatibility | Reactive Agents TypeScript projects using @reactive-agents/* |
| metadata | {"author":"reactive-agents","version":"2.0","tier":"capability"} |
Produce a builder with the correct provider + model + any provider-specific configuration; know which providers need special handling for streaming and tool calls.
// Anthropic — highest quality, native FC, prompt caching
const agent = await ReactiveAgents.create()
.withProvider("anthropic")
.withModel("claude-sonnet-4-6")
.withReasoning({ defaultStrategy: "adaptive" })
.withTools()
.build();
// Local Ollama model
const agent = await ReactiveAgents.create()
.withProvider("ollama")
.withModel("qwen2.5:7b")
.withReasoning({ defaultStrategy: "reactive", maxIterations: 6 })
.withTools({ allowedTools: ["web-search"] })
.build();
| Provider | Best for | Key notes |
|---|---|---|
"anthropic" | Production, highest quality | Native FC, prompt caching, streaming |
"openai" | GPT-4o, broad compatibility | Native FC, streaming |
"gemini" | Multimodal, long context | Native FC; functionResponse.name quirk |
"ollama" | Local, privacy-first | Tool calls arrive on chunk.done |
"litellm" | Proxy routing, cost optimization | OpenAI-compatible; use for Groq, OpenRouter, etc. |
"test" | Unit tests, CI | Returns deterministic mock responses |
.withProvider("anthropic")
.withModel({ model: "claude-opus-4-6", thinking: true })
// Enables extended thinking — model reasons before responding
// Higher quality on complex reasoning tasks; adds latency and cost
// Groq, OpenRouter, Bedrock, Vertex — all through LiteLLM
.withProvider("litellm")
.withModel("groq/llama-3.1-70b-versatile")
// Model name format: "provider/model-name" as per LiteLLM docs
.withProvider("ollama")
.withModel("llama3:8b")
.withCircuitBreaker({
failureThreshold: 3, // open after 3 consecutive failures
cooldownMs: 30_000, // wait 30s before half-open probe
halfOpenRequests: 1,
})
.withRateLimiting({ requestsPerMinute: 10 })
.withModel({ model: "gpt-4o", temperature: 0.2 }) // more deterministic
.withModel({ model: "claude-sonnet-4-6", temperature: 0.9 }) // more creative
These hooks run automatically and adapt prompts/behavior for each provider's strengths:
| Hook | What it does |
|---|---|
continuationHint | Tells the model to continue after tool results while required tools are pending |
errorRecovery | Recovery prompt appended to the observation on tool errors |
synthesisPrompt | Final answer synthesis guidance on the research→produce transition |
qualityCheck | Post-step quality assessment (fires once before the final answer) |
parseToolCalls | Normalizes malformed native tool calls (e.g. qwen3 stringified arguments) in every provider complete()/stream() response |
Adapter selection is automatic via selectAdapter(capabilities, tier). Each provider (Anthropic, OpenAI, Gemini, Ollama) has an adapter with specialized implementations.
| Method | Key params | Notes |
|---|---|---|
.withProvider(p) | "anthropic"|"openai"|"gemini"|"ollama"|"litellm"|"test" | Required |
.withModel(m) | string | { model, thinking?, temperature? } | thinking: true = extended reasoning |
.withCircuitBreaker(cfg?) | { failureThreshold?, cooldownMs?, halfOpenRequests? } | Auto-retry with backoff |
.withRateLimiting(cfg) | { requestsPerMinute?, tokensPerMinute?, maxConcurrent? } |
"groq" and "openrouter" are not valid provider names — use "litellm" with the appropriate model prefixfunctionResponse.name must use msg.toolName, not hard-coded "tool" — framework handles this but custom tool parsers must follow the same patternchunk.done, not during the stream — don't parse mid-stream chunks for tool callsstreamEvent, not helper events (inputJson fires before contentBlock in streaming FC)thinking: true requires a model that supports extended thinking — verify model capability before enabling"provider/model" format — check LiteLLM docs for exact namesAgentic harness diagnostic + improvement loop. Probes the framework with real model runs, uses the rax-diagnose CLI to root-cause failures from structured trace data, ships ONE coordinated architectural fix, verifies via before/after diff, commits with empirical evidence. Use at the start of any harness improvement session — replaces ad-hoc grep + log-spelunking with a deterministic feedback loop.
Use when the architecture may have drifted from documentation, packages have grown complex, dead code or disabled systems are suspected, or before planning a major refactor — scoped to the reactive-agents-ts 22-package monorepo.
Reactive Agents framework architecture — layer stack, dependency graph, build order, and package structure. Use when planning work, understanding package relationships, or determining build dependencies.
Use when analyzing the Reactive Agents codebase for architectural improvements, abstraction opportunities, composability gaps, or Effect-TS engineering quality — before proposing refactors, during design reviews, or when codebase complexity is growing.
LLMService API contract — the correct signatures for complete(), stream(), embed(), and response types. Use when calling LLMService from any layer, writing reasoning strategies, or building LLM-dependent features.
LLM provider streaming patterns and per-provider quirks. Use when adding a new provider, implementing adapter hooks, or debugging streaming tool call behavior in packages/llm-provider.