[Contrib] Agent-OS Integration: Kernel-Level Safety for RL Training#478
Open
imran-siddique wants to merge 22 commits intomicrosoft:mainfrom
Open
[Contrib] Agent-OS Integration: Kernel-Level Safety for RL Training#478imran-siddique wants to merge 22 commits intomicrosoft:mainfrom
imran-siddique wants to merge 22 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/
Contributor
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 <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was referenced Feb 5, 2026
Open
- 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.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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