Core API Reference¶
This page contains the auto-generated API documentation for the core ArbiterOS module.
The main components are implemented in arbiteros_alpha.core and re-exported from the package root for convenience.
ArbiterOSAlpha¶
ArbiterOSAlpha(backend='langgraph')
¶
Main ArbiterOS coordinator for policy-driven LangGraph execution.
ArbiterOSAlpha provides a lightweight governance layer on top of LangGraph, enabling policy-based validation and dynamic routing without modifying the underlying graph structure.
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
The execution backend in use. |
|
history |
History
|
List of execution history entries with timestamps and I/O. |
policy_checkers |
list[PolicyChecker]
|
List of PolicyChecker instances for validation. |
policy_routers |
list[PolicyRouter]
|
List of PolicyRouter instances for dynamic routing. |
Example
os = ArbiterOSAlpha(backend="langgraph") os.add_policy_checker(HistoryPolicyChecker("require_verification",["generate", "execute"])) os.add_policy_router(ConfidencePolicyRouter("confidence", 0.5, "retry")) @os.instruction("generate") ... def generate(state): return {"result": "output"}
Initialize the ArbiterOSAlpha instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
Literal['langgraph', 'vanilla']
|
The execution backend to use. - "langgraph": Use an agent based on the LangGraph framework. - "vanilla": Use the framework-less ('from scratch') agent implementation. |
'langgraph'
|
Source code in arbiteros_alpha/core.py
add_policy_checker(checker)
¶
Register a policy checker for validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checker
|
PolicyChecker
|
A PolicyChecker instance to validate execution constraints. |
required |
Source code in arbiteros_alpha/core.py
add_policy_router(router)
¶
Register a policy router for dynamic flow control.
Policy routers are only supported when using the "langgraph" backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
router
|
PolicyRouter
|
A PolicyRouter instance to dynamically route execution. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the backend is not "langgraph". |
Source code in arbiteros_alpha/core.py
_check_before()
¶
Execute all policy checkers before instruction execution.
Returns:
| Type | Description |
|---|---|
dict[str, bool]
|
A dictionary mapping checker names to their validation results. |
bool
|
A final boolean indicating if all checkers passed. |
Source code in arbiteros_alpha/core.py
_route_after()
¶
Determine if execution should be routed to a different node.
Consults all registered policy routers in order. Returns the first non-None routing decision.
Returns:
| Type | Description |
|---|---|
dict[str, str | None]
|
A dictionary mapping checker names to their route destination. |
str | None
|
A final str indicating the final route destination. |
Source code in arbiteros_alpha/core.py
instruction(instruction_type)
¶
Decorator to wrap LangGraph node functions with policy governance.
This decorator adds policy validation, execution history tracking, and dynamic routing to LangGraph node functions. It's the core integration point between ArbiterOS and LangGraph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction_type
|
InstructionType
|
An instruction type from one of the Core enums (CognitiveCore, MemoryCore, ExecutionCore, NormativeCore, MetacognitiveCore, AdaptiveCore, SocialCore, or AffectiveCore). |
required |
Returns:
| Type | Description |
|---|---|
Callable[[Callable], Callable]
|
A decorator function that wraps the target node function. |
Example
from arbiteros_alpha.instructions import CognitiveCore @os.instruction(CognitiveCore.GENERATE) ... def generate(state: State) -> State: ... return {"field": "value"}
Function now includes policy checks and history tracking¶
Source code in arbiteros_alpha/core.py
History¶
History()
¶
Initialize an empty execution history.
Source code in arbiteros_alpha/history.py
enter_next_superstep(nodes)
¶
add_entry(entry)
¶
Source code in arbiteros_alpha/history.py
pprint()
¶
Source code in arbiteros_alpha/history.py
HistoryItem¶
HistoryItem(timestamp, instruction, input_state, output_state=dict(), check_policy_results=dict(), route_policy_results=dict())
dataclass
¶
The minimal OS metadata for tracking instruction execution.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
datetime
|
When the instruction was executed. |
instruction |
InstructionType
|
The instruction type that was executed. |
input_state |
dict[str, Any]
|
The state passed to the instruction. |
output_state |
dict[str, Any]
|
The state returned by the instruction. |
check_policy_results |
dict[str, bool]
|
Results of policy checkers (name -> passed/failed). |
route_policy_results |
dict[str, str | None]
|
Results of policy routers (name -> target or None). |