1 Service-Lifecycle
Virgil edited this page 2026-02-19 18:36:58 +00:00

Service Lifecycle

Core Integration

go-agentic implements the Core framework service pattern:

type Service struct {
    *framework.ServiceRuntime[Config]
}

Startup

The service registers with Core's DI container and is instantiated during application startup. It:

  1. Loads configuration from YAML/environment
  2. Initialises allowance tracking
  3. Sets up the AI provider HTTP client
  4. Registers available completion models

Configuration

type Config struct {
    Provider    string   // AI provider (anthropic, openai, etc.)
    Model       string   // Default model
    APIKey      string   // Provider API key
    MaxTokens   int      // Default max tokens
    Temperature float64  // Default temperature
}

Configuration sources (in priority order):

  1. Environment variables
  2. YAML config file
  3. Built-in defaults

Client Operations

client.go provides the HTTP client for AI provider APIs:

  • Configurable base URL and authentication
  • Request/response serialisation
  • Timeout and error handling
  • Context cancellation support

Completion Flow

User request
    ↓
Context builder (context.go) — assembles project context
    ↓
Allowance check (allowance.go) — verify quota
    ↓
Completion request (completion.go) — call AI provider
    ↓
Response handling — parse and return