Skip to content

Add kernel runtime loop - #21

Merged
JaimeStill merged 1 commit into
mainfrom
14-kernel-runtime-loop
Feb 15, 2026
Merged

Add kernel runtime loop#21
JaimeStill merged 1 commit into
mainfrom
14-kernel-runtime-loop

Conversation

@JaimeStill

@JaimeStill JaimeStill commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the kernel runtime loop — the observe/think/act/repeat agentic cycle composing agent, tools, session, and memory. Config-driven initialization via New(*Config, ...Option) following the cold start pattern. Run() executes the loop until the agent produces a final response or iterations are exhausted.

Closes #14

Changes

kernel package (new)

  • Kernel struct with New() and Run() implementing the agentic loop
  • Config, DefaultConfig, Merge, LoadConfig for config-driven initialization
  • ToolExecutor interface abstracting the global tools registry for testability
  • Functional options (WithAgent, WithSession, WithToolExecutor, WithMemoryStore)
  • ErrMaxIterations sentinel error

Agent interface evolution

  • Conversation methods (Chat, ChatStream, Vision, VisionStream, Tools) accept []protocol.Message instead of prompt string
  • Enables multi-turn conversations where the kernel passes full session history

ToolCall consolidation

  • response.ToolCall eliminated in favor of protocol.ToolCall as single canonical type
  • Custom UnmarshalJSON transparently handles nested LLM API format (function.name) and flat kernel format (name)

Subsystem configs

  • session.Config with DefaultConfig, Merge, New (extension point for future backends)
  • memory.Config with DefaultConfig, Merge, NewStore (nil store when path empty)

Convenience

  • protocol.InitMessages(role, content) replaces verbose []protocol.Message{protocol.NewMessage(role, content)} across all call sites

Tests

  • 14 kernel tests (93.8% coverage): direct response, tool calls, errors, max iterations, context cancellation, memory injection
  • 6 ToolCall UnmarshalJSON tests (nested, flat, invalid, empty, array)
  • Config and subsystem config tests

Implement the observe/think/act/repeat agentic cycle composing agent,
tools, session, and memory subsystems. Config-driven cold start with
functional options for test overrides.

Supporting changes:
- Evolve Agent interface: conversation methods accept []protocol.Message
- Consolidate response.ToolCall into protocol.ToolCall with custom UnmarshalJSON
- Add protocol.InitMessages convenience wrapper
- Add subsystem configs for session and memory
@JaimeStill
JaimeStill merged commit 4607a1f into main Feb 15, 2026
2 checks passed
@JaimeStill
JaimeStill deleted the 14-kernel-runtime-loop branch February 15, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kernel runtime loop

1 participant