Documentation
¶
Overview ¶
Copyright 2026 Teradata
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package builder provides convenience functions for quickly setting up agents. This is the "batteries included" API that makes it easy to get started.
Index ¶
- Constants
- func NewDevelopmentAgent(backend fabric.ExecutionBackend, llmProvider agent.LLMProvider, ...) (*agent.Agent, error)
- func NewFullyInstrumentedAgent(backend fabric.ExecutionBackend, llmProvider agent.LLMProvider, ...) *agent.Agent
- func NewInstrumentedAgent(backend fabric.ExecutionBackend, llmProvider agent.LLMProvider, ...) *agent.Agent
- func NewProductionAgent(backend fabric.ExecutionBackend, llmProvider agent.LLMProvider, ...) (*agent.Agent, error)
- func NewQuickAgent(backend fabric.ExecutionBackend, llm agent.LLMProvider) *agent.Agent
- type AgentBuilder
- func (b *AgentBuilder) Build() (*agent.Agent, error)
- func (b *AgentBuilder) WithAnthropicLLM(apiKey string) *AgentBuilder
- func (b *AgentBuilder) WithAutoTracer() *AgentBuilder
- func (b *AgentBuilder) WithAzureOpenAIEntraAuth(endpoint, deploymentID, entraToken string) *AgentBuilder
- func (b *AgentBuilder) WithAzureOpenAILLM(endpoint, deploymentID, apiKey string) *AgentBuilder
- func (b *AgentBuilder) WithBackend(backend fabric.ExecutionBackend) *AgentBuilder
- func (b *AgentBuilder) WithBedrockLLM(region string) *AgentBuilder
- func (b *AgentBuilder) WithCircuitBreakers() *AgentBuilder
- func (b *AgentBuilder) WithEmbeddedTracer(storageType, sqlitePath string) *AgentBuilder
- func (b *AgentBuilder) WithGeminiLLM(apiKey string) *AgentBuilder
- func (b *AgentBuilder) WithGeminiLLMCustomModel(apiKey, model string) *AgentBuilder
- func (b *AgentBuilder) WithGuardrails() *AgentBuilder
- func (b *AgentBuilder) WithHawk(endpoint string) *AgentBuilder
- func (b *AgentBuilder) WithHawkAPIKey(apiKey string) *AgentBuilder
- func (b *AgentBuilder) WithHuggingFaceLLM(token string) *AgentBuilder
- func (b *AgentBuilder) WithHuggingFaceLLMCustomModel(token, model string) *AgentBuilder
- func (b *AgentBuilder) WithMistralLLM(apiKey string) *AgentBuilder
- func (b *AgentBuilder) WithMistralLLMCustomModel(apiKey, model string) *AgentBuilder
- func (b *AgentBuilder) WithOllamaLLM(model string) *AgentBuilder
- func (b *AgentBuilder) WithOpenAILLM(apiKey string) *AgentBuilder
- func (b *AgentBuilder) WithOpenAILLMCustomModel(apiKey, model string) *AgentBuilder
- func (b *AgentBuilder) WithPrompts(dir string) *AgentBuilder
- func (b *AgentBuilder) WithPromptsFile(dir string) *AgentBuilder
- func (b *AgentBuilder) WithPromptsRegistry(registry prompts.PromptRegistry) *AgentBuilder
- func (b *AgentBuilder) WithTools(tools ...interface{}) *AgentBuilder
- func (b *AgentBuilder) WithTracer(tracer observability.Tracer) *AgentBuilder
Constants ¶
const DefaultOllamaEndpoint = "http://localhost:11434"
DefaultOllamaEndpoint is the default Ollama server endpoint. Can be overridden via LOOM_LLM_OLLAMA_ENDPOINT or OLLAMA_BASE_URL environment variables.
const DefaultOllamaModel = "llama3.1:8b"
DefaultOllamaModel is the default Ollama model (Llama 3.1 8B for good balance of speed/quality). Can be overridden via LOOM_LLM_OLLAMA_MODEL environment variable.
const DefaultOpenAIModel = "gpt-4.1"
DefaultOpenAIModel is the default OpenAI model (GPT-4.1 as of 2025). Can be overridden via LOOM_LLM_OPENAI_MODEL environment variable.
Variables ¶
This section is empty.
Functions ¶
func NewDevelopmentAgent ¶
func NewDevelopmentAgent( backend fabric.ExecutionBackend, llmProvider agent.LLMProvider, storageType string, sqlitePath string, ) (*agent.Agent, error)
NewDevelopmentAgent creates an agent with embedded tracing for development. This uses in-process storage (memory or SQLite) and doesn't require a separate Hawk service. It provides 10,000x faster performance than service mode.
storageType must be "memory" (fast, non-persistent) or "sqlite" (persistent). sqlitePath is required when storageType is "sqlite", can be empty string for memory.
Example:
// Memory storage (development) agent, err := loom.NewDevelopmentAgent(backend, llmProvider, "memory", "") // SQLite storage (persistent) agent, err := loom.NewDevelopmentAgent(backend, llmProvider, "sqlite", "/tmp/traces.db")
func NewFullyInstrumentedAgent ¶
func NewFullyInstrumentedAgent( backend fabric.ExecutionBackend, llmProvider agent.LLMProvider, tracer observability.Tracer, ) *agent.Agent
NewFullyInstrumentedAgent is like NewInstrumentedAgent but also includes guardrails and circuit breakers for production resilience.
func NewInstrumentedAgent ¶
func NewInstrumentedAgent( backend fabric.ExecutionBackend, llmProvider agent.LLMProvider, tracer observability.Tracer, opts ...agent.Option, ) *agent.Agent
NewInstrumentedAgent creates an agent with comprehensive end-to-end observability. This automatically wraps the LLM provider with instrumentation, capturing detailed traces and metrics for: - Full conversation flows (turns, costs, tokens) - Every LLM call (latency, token usage, tool calls)
Note: Tool execution tracing happens automatically if tools are instrumented. For complete observability stack, also instrument your tools before registering them.
This is the recommended way to create production agents with full visibility.
Example:
tracer := observability.NewNoOpTracer() // or NewHawkTracer() llmProvider := anthropic.NewClient(config) backend := myBackend agent := loom.NewInstrumentedAgent(backend, llmProvider, tracer) agent.RegisterTool(myTool) // Tools can be instrumented separately
func NewProductionAgent ¶
func NewProductionAgent( backend fabric.ExecutionBackend, llmProvider agent.LLMProvider, hawkEndpoint string, ) (*agent.Agent, error)
NewProductionAgent creates an agent with all production features enabled. This uses Hawk service mode (requires running Hawk service). For embedded mode without a separate service, use NewDevelopmentAgent() instead.
func NewQuickAgent ¶
func NewQuickAgent(backend fabric.ExecutionBackend, llm agent.LLMProvider) *agent.Agent
NewQuickAgent creates an agent with sensible defaults. This is the fastest way to get started with loom.
Types ¶
type AgentBuilder ¶
type AgentBuilder struct {
// contains filtered or unexported fields
}
AgentBuilder provides a fluent API for building agents.
func NewAgentBuilder ¶
func NewAgentBuilder() *AgentBuilder
NewAgentBuilder creates a new agent builder.
func (*AgentBuilder) Build ¶
func (b *AgentBuilder) Build() (*agent.Agent, error)
Build creates the agent.
func (*AgentBuilder) WithAnthropicLLM ¶
func (b *AgentBuilder) WithAnthropicLLM(apiKey string) *AgentBuilder
WithAnthropicLLM configures Anthropic Claude as the LLM provider.
func (*AgentBuilder) WithAutoTracer ¶
func (b *AgentBuilder) WithAutoTracer() *AgentBuilder
WithAutoTracer enables automatic tracer selection based on environment variables. See observability.NewAutoSelectTracerFromEnv() for supported environment variables.
Environment Variables:
- LOOM_TRACER_MODE: "auto", "service", "embedded", or "none" (default: "auto")
- LOOM_TRACER_PREFER_EMBEDDED: "true" or "false" (default: "true")
- HAWK_URL: Service endpoint (for service mode)
- HAWK_API_KEY: Service authentication (for service mode)
- LOOM_EMBEDDED_STORAGE: "memory" or "sqlite" (default: "memory")
- LOOM_EMBEDDED_SQLITE_PATH: Path to SQLite database (required if storage=sqlite)
func (*AgentBuilder) WithAzureOpenAIEntraAuth ¶
func (b *AgentBuilder) WithAzureOpenAIEntraAuth(endpoint, deploymentID, entraToken string) *AgentBuilder
WithAzureOpenAIEntraAuth configures Azure OpenAI with Microsoft Entra ID authentication.
func (*AgentBuilder) WithAzureOpenAILLM ¶
func (b *AgentBuilder) WithAzureOpenAILLM(endpoint, deploymentID, apiKey string) *AgentBuilder
WithAzureOpenAILLM configures Azure OpenAI as the LLM provider using API key authentication.
func (*AgentBuilder) WithBackend ¶
func (b *AgentBuilder) WithBackend(backend fabric.ExecutionBackend) *AgentBuilder
WithBackend sets the execution backend.
func (*AgentBuilder) WithBedrockLLM ¶
func (b *AgentBuilder) WithBedrockLLM(region string) *AgentBuilder
WithBedrockLLM configures AWS Bedrock as the LLM provider.
func (*AgentBuilder) WithCircuitBreakers ¶
func (b *AgentBuilder) WithCircuitBreakers() *AgentBuilder
WithCircuitBreakers enables circuit breakers for failure isolation.
func (*AgentBuilder) WithEmbeddedTracer ¶
func (b *AgentBuilder) WithEmbeddedTracer(storageType, sqlitePath string) *AgentBuilder
WithEmbeddedTracer enables embedded Hawk tracer with in-process storage. This provides 10,000x faster performance than service mode and works without a separate Hawk service.
storageType must be "memory" (fast, non-persistent) or "sqlite" (persistent). sqlitePath is required when storageType is "sqlite".
Example:
// Memory storage (development)
builder.WithEmbeddedTracer("memory", "")
// SQLite storage (persistent)
builder.WithEmbeddedTracer("sqlite", "/tmp/loom-traces.db")
func (*AgentBuilder) WithGeminiLLM ¶
func (b *AgentBuilder) WithGeminiLLM(apiKey string) *AgentBuilder
WithGeminiLLM configures Google Gemini as the LLM provider.
func (*AgentBuilder) WithGeminiLLMCustomModel ¶
func (b *AgentBuilder) WithGeminiLLMCustomModel(apiKey, model string) *AgentBuilder
WithGeminiLLMCustomModel configures Google Gemini with a custom model.
func (*AgentBuilder) WithGuardrails ¶
func (b *AgentBuilder) WithGuardrails() *AgentBuilder
WithGuardrails enables guardrails for validation.
func (*AgentBuilder) WithHawk ¶
func (b *AgentBuilder) WithHawk(endpoint string) *AgentBuilder
WithHawk enables Hawk service observability (backward compatible). For embedded mode, use WithEmbeddedTracer() instead. For automatic selection, use WithAutoTracer() instead.
func (*AgentBuilder) WithHawkAPIKey ¶
func (b *AgentBuilder) WithHawkAPIKey(apiKey string) *AgentBuilder
WithHawkAPIKey adds an API key for Hawk service authentication. Only relevant when using WithHawk() for service mode.
func (*AgentBuilder) WithHuggingFaceLLM ¶
func (b *AgentBuilder) WithHuggingFaceLLM(token string) *AgentBuilder
WithHuggingFaceLLM configures HuggingFace as the LLM provider.
func (*AgentBuilder) WithHuggingFaceLLMCustomModel ¶
func (b *AgentBuilder) WithHuggingFaceLLMCustomModel(token, model string) *AgentBuilder
WithHuggingFaceLLMCustomModel configures HuggingFace with a custom model.
func (*AgentBuilder) WithMistralLLM ¶
func (b *AgentBuilder) WithMistralLLM(apiKey string) *AgentBuilder
WithMistralLLM configures Mistral AI as the LLM provider.
func (*AgentBuilder) WithMistralLLMCustomModel ¶
func (b *AgentBuilder) WithMistralLLMCustomModel(apiKey, model string) *AgentBuilder
WithMistralLLMCustomModel configures Mistral AI with a custom model.
func (*AgentBuilder) WithOllamaLLM ¶
func (b *AgentBuilder) WithOllamaLLM(model string) *AgentBuilder
WithOllamaLLM configures Ollama as the LLM provider.
func (*AgentBuilder) WithOpenAILLM ¶
func (b *AgentBuilder) WithOpenAILLM(apiKey string) *AgentBuilder
WithOpenAILLM configures OpenAI as the LLM provider.
func (*AgentBuilder) WithOpenAILLMCustomModel ¶
func (b *AgentBuilder) WithOpenAILLMCustomModel(apiKey, model string) *AgentBuilder
WithOpenAILLMCustomModel configures OpenAI with a custom model.
func (*AgentBuilder) WithPrompts ¶
func (b *AgentBuilder) WithPrompts(dir string) *AgentBuilder
WithPrompts sets the prompts directory. Deprecated: Use WithPromptsFile() for clarity. Will be removed in v2.0.0.
func (*AgentBuilder) WithPromptsFile ¶
func (b *AgentBuilder) WithPromptsFile(dir string) *AgentBuilder
WithPromptsFile uses FileRegistry for prompts (file-based loading).
func (*AgentBuilder) WithPromptsRegistry ¶
func (b *AgentBuilder) WithPromptsRegistry(registry prompts.PromptRegistry) *AgentBuilder
WithPromptsRegistry directly injects a PromptRegistry (custom implementation).
func (*AgentBuilder) WithTools ¶
func (b *AgentBuilder) WithTools(tools ...interface{}) *AgentBuilder
WithTools adds tools to the agent.
func (*AgentBuilder) WithTracer ¶
func (b *AgentBuilder) WithTracer(tracer observability.Tracer) *AgentBuilder
WithTracer sets a tracer directly (highest priority). This bypasses auto-selection and uses the provided tracer as-is.