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
Initialize the ArbiterOSAlpha instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
Literal['langgraph', 'native', 'vanilla']
|
The execution backend to use. - "langgraph": Use an agent based on the LangGraph framework. - "native": Use the framework-less ('from scratch') agent implementation. - "vanilla": (Deprecated) Alias for "native". |
'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
add_evaluator(evaluator)
¶
Register a node evaluator for quality assessment.
Evaluators assess node execution quality after completion. Unlike policy checkers, they do not block execution but provide feedback and scores for monitoring, RL training, or self-improvement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator
|
NodeEvaluator
|
A NodeEvaluator instance to assess execution quality. |
required |
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
_evaluate_node()
¶
Execute all evaluators on the most recent node.
Evaluators assess the quality of the node execution that just completed.
The node's HistoryItem (including output_state) has already been added
to history and can be accessed via history.entries[-1][-1].
Only evaluators whose target_instructions match the current node's instruction type will be executed. If target_instructions is None, the evaluator runs on all nodes.
Returns:
| Type | Description |
|---|---|
dict[str, EvaluationResult]
|
A dictionary mapping evaluator names to their evaluation results. |
Note
Evaluator failures are logged but do not raise exceptions or interrupt execution. This ensures evaluation does not break the workflow.
Source code in arbiteros_alpha/core.py
instruction(instruction_type, input_schema=None, output_schema=None)
¶
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 |
input_schema
|
type[BaseModel] | None
|
Optional Pydantic model to validate the input state. If provided, the input state will be validated against this schema before execution. |
None
|
output_schema
|
type[BaseModel] | None
|
Optional Pydantic model to validate the output state. If provided, the result will be validated against this schema after execution. |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[Callable], Callable]
|
A decorator function that wraps the target node function. |
Example
Source code in arbiteros_alpha/core.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
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(), evaluation_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 |
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). |
evaluation_results |
dict[str, EvaluationResult]
|
Results of node evaluators (name -> EvaluationResult). |