Model-agnostic Execution Runtime for LLM-based Agents
Provides a standardized execution loop, tool integration, and traceable/debuggable agent runtime that can work with any LLM or model backend.
- Model-Agnostic: Plug in OpenAI, Claude, local LLMs, or future models.
- Standard Agent Loop: Think → Act → Observe → Update.
- Tool Integration: Easy to define and call tools with structured input/output.
- Traceability & Replay: Full step-by-step trace for debugging and replay.
- Extensible: Add adapters, tools, and policies with minimal effort.
┌──────────────┐
│ Prompt │
└─────┬────────┘
│
▼
┌──────────────┐
│ Agent Core │
│ (State + Mem)│
└─────┬────────┘
│
┌─────┴─────────┐
▼ ▼
┌─────────────┐ ┌───────────────┐
│ LLM Adapter │ │ Tool Executor │
│ generate() │ │ call(tool) │
└─────┬───────┘ └─────┬─────────┘
│ │
▼ ▼
LLM Response Tool Output
│ │
└──────┬────────┘
▼
┌──────────────┐
│ TraceManager │
│ record(step) │
└─────┬────────┘
▼
Replay / Debug Interface
Components:
- Agent Core - Maintains agent state, memory, and execution loop.
- LLM Adapter - Abstract interface for any LLM backend.
- Tool Executor - Standardized tool invocation with input/output schema.
- Trace Manager - Records every step for replay/debug.
- Replay / Debug Interface - CLI or Web UI to replay agent actions for validation.
# clone repo
git clone https://github.com/lewiscutey/agent-runtime.git
cd agent-runtime
# install dependencies
npm install
# set up environment variables
cp .env.example .env
# Edit .env and add your API keys
# run demo
npm run demoimport { Agent, OpenAIAdapter, Tool } from './src'
// Define a simple LLM adapter
const llm = new OpenAIAdapter({
apiKey: process.env.OPENAI_API_KEY,
model: 'gpt-4'
})
// Define a sample tool
const calculatorTool = new Tool({
name: 'calculator',
description: 'Evaluates mathematical expressions',
schema: {
expression: 'string'
},
func: input => {
try {
return { result: eval(input.expression) }
} catch (error) {
return { error: error.message }
}
}
})
// Initialize agent
const agent = new Agent({
llm,
tools: [calculatorTool]
})
// Run agent loop
await agent.run({
prompt: 'Calculate 2 + 2 and then multiply the result by 5',
maxSteps: 5
})
// Replay / debug
agent.replay()| Component | Main Methods / Interfaces | Description |
|---|---|---|
| Agent | run(prompt, maxSteps) |
Executes the agent loop |
replay() |
Replay the full execution trace | |
addTool(tool) |
Add additional tool to agent | |
| LLMAdapter | generate(prompt, context) |
Returns model response |
| Tool | call(input) |
Executes tool function with input/output schema |
| TraceManager | record(step) |
Records agent execution step |
getTrace() |
Returns full trace for replay/debug |
agent-runtime/
├── src/
│ ├── core/
│ │ ├── Agent.ts # Main agent implementation
│ │ ├── Tool.ts # Tool interface and base class
│ │ └── TraceManager.ts # Execution trace recording
│ ├── adapters/
│ │ ├── LLMAdapter.ts # Base LLM adapter interface
│ │ ├── OpenAIAdapter.ts # OpenAI implementation
│ │ └── ClaudeAdapter.ts # Anthropic Claude implementation
│ ├── tools/
│ │ ├── calculator.ts # Example calculator tool
│ │ └── weather.ts # Example weather tool
│ └── index.ts # Main exports
├── examples/
│ ├── demo-agent.ts # Basic demo
│ └── advanced-agent.ts # Advanced usage
├── tests/
│ └── agent.test.ts
├── package.json
├── tsconfig.json
├── .env.example
└── README.md
- Add new LLM adapters in
src/adapters/ - Add tools in
src/tools/ - Add examples in
examples/
MIT