Skip to main content

Crate astrid_runtime

Crate astrid_runtime 

Source
Expand description

Astrid Runtime - Agent orchestration and session management.

This crate provides:

  • Agent runtime with LLM, MCP, and security integration
  • Session management with persistence
  • Context management with auto-summarization

§Architecture

The runtime coordinates:

  • LLM provider for language model interactions
  • MCP client for tool execution
  • Capability store for authorization
  • Audit log for security logging

§Example

use astrid_runtime::{AgentRuntime, RuntimeConfig, SessionStore};
use astrid_llm::{ClaudeProvider, ProviderConfig};
use astrid_mcp::McpClient;
use astrid_audit::AuditLog;
use astrid_crypto::KeyPair;

// Create components
let llm = ClaudeProvider::new(ProviderConfig::new("api-key", "claude-sonnet-4-20250514"));
let mcp = McpClient::from_default_config()?;
let audit_key = KeyPair::generate();
let runtime_key = KeyPair::generate();
let audit = AuditLog::in_memory(audit_key);
let home = astrid_core::dirs::AstridHome::resolve()?;
let sessions = SessionStore::from_home(&home);

// Create runtime
let runtime = AgentRuntime::new(
    llm,
    mcp,
    audit,
    sessions,
    runtime_key,
    RuntimeConfig::default(),
);

// Create a session
let mut session = runtime.create_session(None);

// Run a turn (would need a Frontend implementation)
// runtime.run_turn_streaming(&mut session, "Hello!", &frontend).await?;

Re-exports§

pub use subagent::SubAgentHandle;
pub use subagent::SubAgentId;
pub use subagent::SubAgentPool;
pub use subagent::SubAgentPoolStats;
pub use subagent::SubAgentStatus;
pub use subagent_executor::SubAgentExecutor;
pub use astrid_workspace;
pub use astrid_tools;

Modules§

config_bridge
Bridge from astrid_config::Config to domain types.
prelude
Prelude module - commonly used types for convenient import.
subagent
Subagent pool management.
subagent_executor
Sub-agent executor — implements SubAgentSpawner using the runtime’s agentic loop.

Structs§

AgentRuntime
The main agent runtime.
AgentSession
An agent session.
ContextManager
Context manager for handling context overflow.
ContextStats
Context statistics.
GitState
Git repository state snapshot.
RuntimeConfig
Configuration for the agent runtime.
SerializableSession
Serializable session state (for persistence).
SessionMetadata
Session metadata.
SessionStore
Session store for persistence.
SessionSummary
Summary of a session for listing.
SparkConfig
Agent identity configuration.
SummarizationResult
Result of a summarization operation.
ToolContext
Shared context available to all built-in tools.
ToolRegistry
Registry of built-in tools for lookup and LLM definition export.
WorkspaceBoundary
Workspace boundary checker.
WorkspaceConfig
Workspace configuration.

Enums§

RuntimeError
Errors that can occur in the runtime.
WorkspaceMode
Operating mode for the workspace.

Functions§

build_system_prompt
Build the complete system prompt for an agent session.

Type Aliases§

RuntimeResult
Result type for runtime operations.