Changelog: OS Model Migration

On Sun, 04 Oct 2026, by @lucasdicioccio, 405 words, 3 code snippets, 0 links, 0images.

Generated from documentation/CHANGELOG-OS-MIGRATION.md, the repository is the canonical source and may be ahead of this page.

Changelog: OS Model Migration

Date: March 2026
Commits: 0eb5263 to cb52af7

Summary

This release introduces a major architectural refactoring of the agents-exe core, migrating from a Runtime-per-agent model to a centralized Entity-Component-System (ECS) based OS model.

Major Changes

New Architecture: ECS-Based OS Model

The framework now uses an Entity-Component-System (ECS) pattern at its core:

  • Entities: Lightweight UUID-based identifiers (AgentId, ToolboxId, ConversationId, etc.)
  • Components: Pure, serializable data attached to entities (AgentConfig, AgentState, ToolboxConfig)
  • Systems: Functions that operate on entities with specific component combinations

New Modules (27 OS Modules Added)

ModulePurpose
System.Agents.OSMain OS module, exports all OS functionality
System.Agents.OS.CoreCore ECS types and World operations
System.Agents.OS.Core.TypesComponent typeclass and entity ID types
System.Agents.OS.Core.WorldWorld storage with STM-based component stores
System.Agents.OS.AgentsOS-native agent creation and management
System.Agents.OS.AgentTreeOS-native agent tree initialization
System.Agents.OS.ConcurrentConcurrent access patterns
System.Agents.OS.Concurrent.TypesAccess pattern types (Exclusive, Read-Write, Pool)
System.Agents.OS.Concurrent.LocksSTM-based locking primitives
System.Agents.OS.ResourcesResource lifecycle management
System.Agents.OS.Resources.TypesResource scope definitions
System.Agents.OS.Resources.SqliteSQLite resource management
System.Agents.OS.Resources.LuaLua interpreter resources
System.Agents.OS.Resources.HttpHTTP connection pool resources
System.Agents.OS.ConversationConversation and turn management
System.Agents.OS.Conversation.TypesTurn, Message, Conversation components
System.Agents.OS.Conversation.LineageCall chain tracking
System.Agents.OS.CompatCompatibility layer exports
System.Agents.OS.Compat.RuntimeRuntime-to-OS bridge
System.Agents.OS.InterfacesInterface layer
System.Agents.OS.Interfaces.TUITUI adaptation for OS
System.Agents.OS.Interfaces.OneShotOneShot adaptation for OS

Migration Phases

The migration follows a phased approach:

PhaseOldOnly (REMOVED) ──> PhaseDual ──> PhaseNewOnly
    (Legacy only)          (Both)        (OS only)

March 2026 Update: PhaseOldOnly has been removed. The system now operates in:

  • PhaseDual (default): Both Runtime and OS available
  • PhaseNewOnly: OS only, Runtime deprecated

Key New Capabilities

  1. Shared Toolboxes: Multiple agents can share the same SQLite database, HTTP connection pool, or other resources
  2. Better Resource Management: Explicit lifecycle scopes (Program, Agent, Toolbox, Conversation, Turn, ToolCall)
  3. Concurrent Access: STM-based synchronization with multiple patterns:
    • ExclusiveAccess: Single accessor (TMVar) - for Lua interpreters
    • ReadWriteAccess: Multiple readers/single writer (RWLock) - for SQLite
    • PoolAccess: Bounded pool (TBQueue) - for HTTP connections
    • StatelessAccess: No synchronization needed
  4. Durable Persistence: Pluggable backends (SQLite, PostgreSQL, file-based)
  5. Complete Lineage Tracking: Full call chains for debugging and accounting
  6. Foundation for Web API: Centralized state enables HTTP server interface

Component Type IDs

IDComponent
1AgentConfig
2AgentState
3ToolboxConfig
4ToolboxState
5ToolboxBinding
30ConversationConfig
31ConversationState
32AgentConversation
33TurnConfig
34TurnState
35ToolCallConfig
36ToolCallState
38Message

New CLI Modules

  • System.Agents.CLI.Export - Export tools and agents
  • System.Agents.CLI.Import - Import tools and agents

New Documentation

DocumentPurpose
documentation/architecture.mdUpdated with OS model architecture
documentation/OS-API.mdComplete API reference for OS model
documentation/MIGRATION-OS.mdMigration guide from Runtime to OS
documentation/MIGRATION-GUIDE.mdGeneral migration guidance
documentation/advanced-configuration.mdAdvanced configuration options

New Tests

Test ModulePurpose
test/OS/IntegrationTests.hsEnd-to-end OS scenarios
test/OS/CompatibilityTests.hsRuntime/OS compatibility tests
test/OS/CoreTests.hsECS core functionality
test/OS/ConcurrentTests.hsConcurrent access patterns
test/OS/ResourcesTests.hsResource management
test/OS/ConversationTests.hsConversation/lineage
test/OS/CompatTests.hsCompatibility layer
test/OS/InterfaceTests.hsInterface layer

New Benchmarks

BenchmarkPurpose
bench/OSBenchmarks.hsOS model performance benchmarks

API Changes

Old (Still Supported via Compatibility Layer)

-- Legacy Runtime approach
runtime <- newRuntime props agent tracer
result <- runWithRuntime runtime $ do
    tools <- listTools
    callTool "my-tool" args

New (OS Model)

-- OS model approach
import System.Agents.OS

-- Initialize world
world <- atomically $ do
    w <- newWorld
    w' <- registerComponentStore w (Proxy @AgentConfig)
    registerComponentStore w' (Proxy @AgentState)

-- Create agent
let config = AgentConfig
    { agentName = "my-agent"
    , agentModel = ModelConfig "openai" "url" "gpt-4" "key"
    , agentSystemPrompt = "You are helpful"
    , agentToolboxBindings = []
    }
agentId <- createAgent world config

Migration Path

  1. Current (PhaseDual): Use System.Agents.OS.Compat.Runtime for gradual migration
  2. Future (PhaseNewOnly): Direct OS model usage

See documentation/MIGRATION-OS.md for detailed migration instructions.

Build Changes

New Dependencies

  • deepseq - For benchmark strictness
  • criterion - Benchmarking framework
  • async - Concurrent test execution
  • mtl - Monad transformers

Cabal Updates

  • Added 27 new OS modules to library
  • Added new test modules
  • Added benchmark section

Benefits

  1. Shared Resources: Multiple agents sharing toolboxes
  2. Resource Pooling: HTTP connections pooled across agents
  3. Better Lifecycle: Explicit cleanup with scopes
  4. Web API Ready: Centralized state for HTTP interface
  5. Durable Persistence: Multiple backend options
  6. Lineage Tracking: Complete call chains

Tradeoffs

  1. ECS Complexity: Adds indirection but enables flexible composition
  2. STM Overhead: Slight performance cost for composability
  3. Dual Mode: Maintenance burden during transition
  4. Storage Overhead: More memory than direct fields

Backward Compatibility

  • Full compatibility layer provided
  • Old Runtime interface still works
  • Gradual migration supported
  • Breaking changes documented in migration guide
  • #348 - Core Entity and Component Types
  • #349 - Resource Management
  • #350 - Concurrent Access
  • #351 - Conversation and Lineage Tracking
  • #352 - OS Monad
  • #353 - Runtime Compatibility
  • #354 - TUI and OneShot Adaptation
  • #355 - Persistence Layer
  • #356 - Documentation and Integration (this release)

Contributors

  • Lucas DiCioccio

For questions about the migration, see documentation/MIGRATION-OS.md or file an issue with the “migration” label.