What Are the Three Execution Layers in Apache Maka?
Apache Maka implements three distinct execution layers—the Runtime Event Log, the SessionManager with AgentRun lifecycle components, and the Agent Graph Control Plane—all coordinated by a single Runtime Host that serves as the sole execution authority.
Apache Maka is an open-source agent runtime that channels all work through a hierarchical execution model documented in ARCHITECTURE.md. Understanding the three execution layers in Apache Maka is essential for developers building deterministic agent applications, as each layer handles a specific aspect of session state, turn execution, and multi-agent orchestration.
The Three Execution Layers in Apache Maka
The execution model centralizes authority in the Runtime Host, which acts on behalf of desktops, TUIs, CLIs, bots, and evaluation clients. Within this host, three logical layers process work in a deterministic pipeline.
Runtime Event Log
The Runtime Event Log is an immutable ledger that records every discrete fact during a session. According to the Apache Maka source code, this layer persists model messages, tool invocations, tool results, and termination facts, creating a single source of truth for what has occurred during execution.
In packages/runtime/src/eventLog.ts, the log implementation provides append-only storage that guarantees reproducibility. Developers can query this log to reconstruct session state or audit agent decisions retroactively.
SessionManager and AgentRun
The SessionManager and AgentRun components own the execution lifecycle of individual sessions. The SessionManager creates and tracks session metadata, while an AgentRun encapsulates a single turn of an agent’s operation.
As implemented in packages/runtime-host/src/RuntimeHost.ts, this layer handles model adapter selection, tool execution dispatch, context window management, and recovery from failures. The RuntimeHost.createSession() method initializes the SessionManager, and session.runAgent() executes a complete turn through the AgentRun abstraction.
Agent Graph Control Plane
The Agent Graph Control Plane operates as a scheduling layer that orchestrates dependent work across multiple agents. This layer spawns child sessions and routes all activations back through the same Runtime Host, ensuring consistent execution semantics for complex multi-agent workflows.
Defined in packages/graph/src/AgentGraph.ts, the control plane enables sophisticated coordination patterns. The AgentGraph.spawnChild() method creates subordinate sessions that inherit the parent’s execution context while maintaining isolation through the Runtime Host’s authority.
How to Interact with Each Execution Layer
The following examples demonstrate how to programmatically access each of the three execution layers using Apache Maka’s public APIs.
Accessing the Runtime Event Log
Use the getEventLog function from the runtime package to retrieve the immutable session history:
import { getEventLog } from '@maka/runtime';
// Retrieve the log for the current session
const log = await getEventLog({ sessionId: 'abc123' });
console.log('Event Log:', log);
Managing Sessions and Agent Runs
Create sessions through the Runtime Host and execute agent turns via the SessionManager and AgentRun:
import { RuntimeHost } from '@maka/runtime-host';
async function runAgentTurn(prompt) {
// RuntimeHost creates a SessionManager internally
const session = await RuntimeHost.createSession({ user: 'alice' });
// AgentRun executes a single turn
const result = await session.runAgent({ input: prompt });
console.log('Agent output:', result);
}
runAgentTurn('Explain the three execution layers.');
Orchestrating with the Agent Graph
Schedule dependent work through the Agent Graph Control Plane:
import { AgentGraph } from '@maka/graph';
async function scheduleChildWork() {
const graph = new AgentGraph();
// The graph spawns a child session that will run in the same Runtime Host
const childSession = await graph.spawnChild({ parentSessionId: 'abc123' });
const childResult = await childSession.runAgent({ input: 'Summarize the architecture.' });
console.log('Child result:', childResult);
}
scheduleChildWork();
Key Source Files
The implementation of Apache Maka’s three execution layers resides in specific packages within the repository:
ARCHITECTURE.md– Provides the canonical specification of the execution model and layer interactions.packages/runtime/src/eventLog.ts– Implements the Runtime Event Log API for storing and retrieving execution facts.packages/runtime-host/src/RuntimeHost.ts– Contains the entry point for session creation and the SessionManager/AgentRun lifecycle implementation.packages/graph/src/AgentGraph.ts– Defines the Agent Graph Control Plane that schedules child sessions and routes activations.
Summary
- Runtime Event Log – An immutable ledger in
packages/runtime/src/eventLog.tsthat records all session facts, enabling full reproducibility and auditability. - SessionManager and AgentRun – Lifecycle components in
packages/runtime-host/src/RuntimeHost.tsthat manage session state and execute individual agent turns with recovery capabilities. - Agent Graph Control Plane – An orchestration layer in
packages/graph/src/AgentGraph.tsthat schedules multi-agent workflows while routing all work through the Runtime Host.
Frequently Asked Questions
How does the Runtime Event Log ensure deterministic execution?
The Runtime Event Log maintains an append-only record of every model message, tool invocation, and result. Because the log is immutable and serves as the single source of truth, any session can be reconstructed to the exact same state by replaying the event sequence, guaranteeing deterministic behavior across different environments.
What is the difference between SessionManager and AgentRun?
The SessionManager handles session-level concerns such as creation, tracking, and metadata management across multiple turns. The AgentRun encapsulates a single turn of execution, managing the specific lifecycle of model inference, tool calls, and context management within that turn. Both operate within the Runtime Host as implemented in packages/runtime-host/src/RuntimeHost.ts.
How does the Agent Graph Control Plane coordinate multiple agents?
The Agent Graph Control Plane spawns child sessions via AgentGraph.spawnChild() and routes all activations back through the Runtime Host. This design ensures that every agent—whether parent or child—follows the same execution path through the three layers, enabling consistent state management and fault isolation across distributed agent workflows.
Where is the Runtime Host implemented in the Apache Maka source code?
The Runtime Host entry point and session management logic are implemented in packages/runtime-host/src/RuntimeHost.ts. This file contains the RuntimeHost.createSession() method and coordinates interactions between the SessionManager, AgentRun, and the Runtime Event Log components.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →