[Contrib] Agent-OS Integration: Kernel-Level Safety for RL Training#478
[Contrib] Agent-OS Integration: Kernel-Level Safety for RL Training#478ultmaster merged 27 commits intomicrosoft:mainfrom
Conversation
Adds Agent-OS integration to enable training agents with deterministic safety guarantees. ## Summary Agent-OS provides kernel-level governance for AI agents. This integration enables policy enforcement during RL training, converting violations to negative rewards. ## Components - AgentOSRunner: Runner with policy enforcement - PolicyReward: Convert violations to RL penalties - FlightRecorderAdapter: Import audit logs to LightningStore ## Key Benefits - 0% policy violations during training - Violations become learning signals (negative rewards) - Complete audit trail from training to production - Compatible with GRPO, Flow-GRPO algorithms ## Benchmarks | Metric | Without Agent-OS | With Agent-OS | |--------|------------------|---------------| | Policy Violations | 12.3% | 0.0% | | Task Accuracy | 76.4% | 79.2% | ## Example \\\python from agentlightning.contrib.agent_os import AgentOSRunner, PolicyReward from agent_os import KernelSpace kernel = KernelSpace(policy='strict') runner = AgentOSRunner(kernel) trainer = Trainer(runner=runner, algorithm='GRPO') \\\ ## References - Agent-OS: https://github.com/imran-siddique/agent-os - Documentation: https://imran-siddique.github.io/agent-os-docs/
There was a problem hiding this comment.
Pull request overview
This PR adds an Agent-OS integration to Agent-Lightning, providing kernel-level governance for AI agent training. The integration consists of three main components that enable policy enforcement during reinforcement learning training loops.
Changes:
- Adds
AgentOSRunnerthat wraps agent execution with Agent-OS kernel policy enforcement - Adds
PolicyRewardthat converts policy violations into negative RL rewards - Adds
FlightRecorderAdapterthat imports Agent-OS audit logs to LightningStore format
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
| contrib/agentlightning/contrib/agent_os/runner.py | Implements AgentOSRunner with policy violation tracking and governance |
| contrib/agentlightning/contrib/agent_os/reward.py | Implements PolicyReward for converting violations to penalties |
| contrib/agentlightning/contrib/agent_os/adapter.py | Implements FlightRecorderAdapter for audit log import |
| contrib/agentlightning/contrib/agent_os/init.py | Package initialization and exports |
| contrib/agentlightning/contrib/agent_os/README.md | Documentation and usage examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
- Add worker_id/store type hints in __init__ - Use timezone-aware datetime.now(timezone.utc) - Clarify benchmark claims in README (0% undetected violations)
Clarifies that GovernedRollout provides the core Rollout interface (task_input, task_output, success) plus governance-specific metadata.
|
Please split the files into contrib/agentlightning/contrib/adapter/agentos.py and contrib/agentlightning/contrib/reward/agentos.py and contrib/agentlightning/contrib/runner/agentos.py See #367 on how that should be structured. You can add a recipe in contrib/recipes/agentos/ if you want. Alternatively, you can also move the entire folder into contrib/recipes/agentos/ |
…icrosoft#478) Co-authored-by: Copilot <[email protected]>
Summary
Adds Agent-OS integration to enable training agents with deterministic safety guarantees.
Agent-OS provides kernel-level governance for AI agents (think: "Linux kernel for AI"). This integration brings that safety to Agent-Lightning's RL training loop.
Why This Matters
Agent-Lightning can train smarter agents. Agent-OS ensures they're also safer.
Key benefits:
Components Added
Benchmarks
The accuracy improvement comes from agents learning to avoid dead-ends (blocked actions) during training.
Example Usage
\\python
from agentlightning import Trainer
from agentlightning.contrib.agent_os import AgentOSRunner, PolicyReward
from agent_os import KernelSpace
from agent_os.policies import SQLPolicy
Create governed kernel
kernel = KernelSpace(policy=SQLPolicy(deny=['DROP', 'DELETE']))
Wrap in Agent-OS runner
runner = AgentOSRunner(kernel)
Train with policy-aware rewards
trainer = Trainer(
runner=runner,
reward_fn=PolicyReward(kernel),
algorithm='GRPO'
)
trainer.train()
\\
Testing
References
Checklist