Skip to main content

Crate sombrax_agentic_core

Crate sombrax_agentic_core 

Source
Expand description

§SombraX Agentic Core (sombrax_agentic_core)

SombraX Agentic Core (SAC) is a Rust library for LLM agent orchestration with content-modifying hooks, MCP tool integration, cross-agent communication, and context optimization.

§Features

  • Content-Modifying Hooks: Intercept and modify messages before/after LLM calls
  • MCP Tool Integration: Connect to MCP servers for tool discovery and execution
  • Cross-Agent Communication: Registry for agent discovery and invocation
  • Context Optimization: Automatic context management for long conversations
  • OpenTelemetry: Built-in observability with tracing and metrics
  • LLM Providers: OpenAI, Anthropic, ZAI, Cerebras, OpenRouter (sombrax_agentic_core::providers)
  • Agent Tools: File, shell, web, and task tools (sombrax_agentic_core::tools)

§Quick Start

use sombrax_agentic_core::prelude::*;

#[derive(Clone)]
struct LoggingHook;

impl Hook for LoggingHook {
    async fn pre_completion(
        &self,
        message: Message,
        _history: &[Message],
        ctx: &mut HookContext,
    ) -> HookResult<Message> {
        println!("[{}] Processing message", ctx.request_id);
        Ok(message)
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = OpenAIClientBuilder::new(&std::env::var("OPENAI_API_KEY")?).build();
    let model = client.completion_model_adapter("gpt-4");

    let agent = AgentBuilder::new(model)
        .preamble("You are a helpful assistant.")
        .hook(LoggingHook)
        .build();

    let response = agent.prompt("Hello!").await?;
    println!("{}", response.content());
    Ok(())
}

Re-exports§

pub use agent::Agent;
pub use agent::AgentBuilder;
pub use agent::AgentWrapper;
pub use agent::ExecutionStats;
pub use agent::PromptResponse;
pub use context::HookContext;
pub use context::OptimizationConfig;
pub use context::SharedContext;
pub use error::CompletionError;
pub use error::HookError;
pub use error::HookStage;
pub use error::ToolError;
pub use extractor::build_extractor;
pub use extractor::ExtractorBuildError;
pub use extractor::ExtractorError;
pub use extractor::ExtractorWrapper;
pub use hook::builtin::ValidationHook;
pub use hook::builtin::WorkspaceBoundaryHook;
pub use hook::Hook;
pub use hook::HookChain;
pub use hook::ToolCallDecision;
pub use message::validate_tool_result_ids;
pub use message::Message;
pub use message::ValidationError;
pub use provider::CompletionModel;
pub use provider::CompletionRequest;
pub use provider::CompletionResponse;
pub use provider::Usage;
pub use providers::build_agent;
pub use providers::build_agent_with_options;
pub use providers::AgentBuildError;
pub use providers::AgentBuildOptions;
pub use providers::LlmConfigLike;
pub use providers::ProviderType;
pub use providers::ProviderTypeError;
pub use retry::ResponseValidation;
pub use retry::RetryConfig;
pub use retry::ValidationResult;
pub use tool::McpToolSource;
pub use tool::StdioMcpClient;
pub use tool::Tool;
pub use tool::ToolDefinition;
pub use tool::ToolDyn;

Modules§

agent
Agent module
context
Context types for hooks and agents
error
Error types for the Agent Hook Library
experience
Experience-based learning system for agent self-improvement. Experience-based learning system for agent self-improvement.
extractor
Extractor module for structured data extraction from LLM responses.
hook
Hook trait and chain execution
message
Message types for conversation content
prelude
Prelude module for convenient imports
prompt
System prompts as first-class on-disk assets with a name-based resolution ladder — analog of skill for persona prompts. System prompt assets — first-class, on-disk prompt files with a deterministic name-based resolution ladder.
provider
LLM Provider abstractions
providers
LLM Providers
retry
Retry configuration for agent execution with exponential backoff.
runs
Pluggable pipeline / bundle / job runtime.
skill
Skill system for discovering and loading user-defined agent skills.
telemetry
Telemetry module for observability
tool
Tool trait and definitions
tools
Agent Tools

Macros§

completion_span
Create a tracing span for a completion request
hook_execution_span
Create a tracing span for a hook execution
hook_span
Create a tracing span for a hook chain execution
tool_call_span
Create a tracing span for a tool call