SombraX Agentic Core (sombrax_agentic_core)
sombrax_agentic_core (SAC) is a Rust library for building tool-using LLM agents with hookable execution, resilient completion loops, and strong context management.
It is designed for coding/automation workflows where context quality and local model stability matter as much as raw model capability. It was initially inspired by the RIG library and evolved toward stronger agent orchestration, context control, and local-model workflows.
What Problems It Solves
| Problem | How sombrax_agentic_core addresses it |
|---|---|
| Agent logic becomes hard to control | AgentBuilder + hook chain let you intercept and modify messages, tool calls, and responses. |
| Tool loops fail on malformed/truncated model output | Built-in retry/backoff, validation retries, and rollback behavior around tool-call failures. |
| Long sessions bloat context windows | Pluggable context optimizers (Recency, Priority, Truncation) + configurable token budgets. |
| File-edit workflows keep stale snapshots | File-history context classification tracks read/write/edit and computes keep/drop/move decisions. |
| Local models need provider-specific handling | First-class local providers: ollama, lmstudio, mlx/mlxlm, with anti-loop controls and template handling. |
| Tool execution needs guardrails | Workspace-bounded file tools and shell safety filters for dangerous command patterns. |
Core Capabilities
- Content-modifying hooks (
pre_completion,post_completion,pre_tool_call,post_tool_call,filter_tools) - Built-in tools for file/shell/web/task workflows
- MCP tool integration (
McpToolSource) - Cross-agent registry and shared context
- Provider-agnostic factory (
build_agent) and provider-specific builders - OpenTelemetry-friendly metrics/tracing integration
Context Management (Main Focus)
1) Token-Budget Optimization
Use any optimizer implementing ContextOptimizer:
RecencyOptimizerPriorityOptimizerTruncationOptimizer
use ;
use ;
use AgentBuilder;
let client = new.build;
let model = client.completion_model_adapter;
let agent = new
.context_optimizer
.optimization_config
.build;
2) File-History Context Classification
For coding agents, FileContextHook tracks file operations and computes context decisions to avoid stale file history dominating prompts.
use FileContextHook;
let file_hook = new;
// Attach file_hook to your AgentBuilder via .hook(file_hook.clone())
// Later, inspect optimization signals:
let optimization = file_hook.compute_optimization;
let files_needing_read = file_hook.files_needing_read;
// optimization.keep / optimization.drop / optimization.move_to_end
This is especially useful when an agent reads/edits the same file repeatedly in one session.
3) Request and Shared State
HookContext: per-request mutable context across hooksSharedContext: session-scoped shared state for multi-agent flows
Local Models (Main Focus)
sombrax_agentic_core supports local inference without forcing cloud APIs.
Ollama (OpenAI-compatible endpoint)
use ;
use AgentBuilder;
let client = new
.base_url
.build;
let model = client.completion_model_adapter;
let agent = new
.preamble
.build;
LM Studio (anti-repetition controls)
use ;
use AgentBuilder;
let client = new
.base_url
.with_anti_loop_config
.with_anti_repetition_stops
.build;
let model = client.completion_model_adapter;
let agent = new.build;
MLX-LM (Apple Silicon, chat-template aware)
use ;
use AgentBuilder;
let model_id = "mlx-community/Qwen2.5-Coder-7B-Instruct-4bit";
let client = new
.base_url
.auto_chat_template
.with_anti_loop_config
.with_chatml_stop_sequences
.with_anti_repetition_stops
.build;
let model = client.completion_model_adapter;
let agent = new.build;
Provider-Agnostic Agent Construction
Use LlmConfigLike + build_agent when you want one config path for both local and cloud models.
use ;
# async
Supported provider IDs include: openrouter, openai, anthropic, minimax, cerebras, zai, ollama, mlx, lmstudio.
Tools and Safety
sombrax_agentic_core::tools includes:
- File tools:
ReadTool,WriteTool,EditTool,GlobTool,GrepTool - Shell tool:
BashTool(dangerous pattern rejection) - Web tool:
FetchTool - Agent tools:
TaskTool,TodoReadTool,TodoWriteTool
Tools run inside a ToolContext with workspace boundary checks.
MCP Integration
use McpToolSource;
# async
You can attach MCP tools to an agent via AgentBuilder::mcp_tools(source).await.
Installation
[]
= "0.1"
= { = "1", = ["full"] }
Optional features: openai, anthropic, and runs (a pluggable pipeline/job
runtime); full enables all three. Default build pulls in none of them.
Examples
Runnable, provider-agnostic examples live in examples/ (they
default to a local Ollama, no API key required):
See examples/README.md for the full list and the
SAC_* environment variables that point them at any supported provider.
Development
Project Layout
src/agent- agent runtime, loop execution, retries, wrappersrc/context- hook/shared context + optimizers + file-history classificationsrc/hook- hook trait, hook chain, built-in hookssrc/providers- provider clients/adapters/builders (cloud + local)src/toolsandsrc/tool- built-in tools and tool abstractions/MCP support
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.