agentmesh_lightning 3.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.1
2
+ Name: agentmesh_lightning
3
+ Version: 3.0.2
4
+ Summary: Public Preview — Agent-Lightning RL integration for the Agent Governance Toolkit: governed training with policy enforcement
5
+ Author-email: Microsoft Corporation <agentgovtoolkit@microsoft.com>
6
+ Maintainer-email: Agent Governance Toolkit Team <agentgovtoolkit@microsoft.com>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/microsoft/agent-governance-toolkit
9
+ Project-URL: Repository, https://github.com/microsoft/agent-governance-toolkit
10
+ Project-URL: Bug Tracker, https://github.com/microsoft/agent-governance-toolkit/issues
11
+ Keywords: ai-agents,governance,reinforcement-learning,agentmesh-lightning,agent-os,enterprise-ai
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Provides-Extra: agent-os
24
+ Requires-Dist: agent-os-kernel<2.0,>=1.0.0; extra == "agent-os"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest<8.0,>=7.0; extra == "dev"
27
+ Requires-Dist: pytest-cov; extra == "dev"
28
+
29
+ # Agent Lightning — RL Training Governance
30
+
31
+ > [!IMPORTANT]
32
+ > **Public Preview** — The `agentmesh-lightning` package on PyPI is a Microsoft-signed
33
+ > public preview release. APIs may change before GA.
34
+
35
+ Train AI agents with RL while maintaining **0% policy violations**.
36
+
37
+ *Part of the [Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit)*
38
+
39
+ [![CI](https://github.com/microsoft/agent-governance-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/microsoft/agent-governance-toolkit/actions/workflows/ci.yml)
40
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
41
+ [![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://python.org)
42
+ [![PyPI](https://img.shields.io/pypi/v/agentmesh-lightning)](https://pypi.org/project/agentmesh-lightning/)
43
+
44
+ ## 🎯 Overview
45
+
46
+ This package provides governed RL training integration:
47
+ - **Agent-Lightning** = Training/Optimization (the "brains")
48
+ - **Agent-OS** = Governance/Safety (the "guardrails")
49
+
50
+ **Result**: Agents learn to be smart AND safe from the start.
51
+
52
+ > **Note:** This package was extracted from `agent_os.integrations.agent_lightning`.
53
+ > The old import path still works via a backward-compatibility shim but new code
54
+ > should import from `agent_lightning_gov` directly.
55
+
56
+ ## 🚀 Quick Start
57
+
58
+ ```bash
59
+ pip install agentmesh-lightning
60
+ # Optional: pip install agent-os-kernel # for kernel integration
61
+ ```
62
+
63
+ ```python
64
+ from agent_lightning_gov import GovernedRunner, PolicyReward
65
+ from agent_os import KernelSpace
66
+ from agent_os.policies import SQLPolicy, CostControlPolicy
67
+
68
+ # 1. Create governed kernel
69
+ kernel = KernelSpace(policy=[
70
+ SQLPolicy(deny=["DROP", "DELETE"]),
71
+ CostControlPolicy(max_cost_usd=100)
72
+ ])
73
+
74
+ # 2. Create governed runner
75
+ runner = GovernedRunner(kernel)
76
+
77
+ # 3. Create policy-aware reward function
78
+ def base_accuracy(rollout):
79
+ return rollout.task_output.accuracy if rollout.success else 0.0
80
+
81
+ reward_fn = PolicyReward(kernel, base_reward_fn=base_accuracy)
82
+
83
+ # 4. Train with Agent-Lightning
84
+ from agentlightning import Trainer
85
+ trainer = Trainer(
86
+ runner=runner,
87
+ reward_fn=reward_fn,
88
+ algorithm="GRPO"
89
+ )
90
+
91
+ trainer.train(num_epochs=100)
92
+ ```
93
+
94
+ ## 📊 Key Benefits
95
+
96
+ | Metric | Without Agent-OS | With Agent-OS |
97
+ |--------|------------------|---------------|
98
+ | Policy Violations | 12.3% | **0.0%** |
99
+ | Task Accuracy | 76.4% | **79.2%** |
100
+ | Training Stability | Variable | Consistent |
101
+
102
+ ## 🔧 Components
103
+
104
+ ### GovernedRunner
105
+
106
+ Agent-Lightning runner that enforces policies during execution:
107
+
108
+ ```python
109
+ from agent_lightning_gov import GovernedRunner
110
+
111
+ runner = GovernedRunner(
112
+ kernel,
113
+ fail_on_violation=False, # Continue but penalize
114
+ log_violations=True, # Log all violations
115
+ )
116
+
117
+ # Execute a task
118
+ rollout = await runner.step(task_input)
119
+ print(f"Violations: {len(rollout.violations)}")
120
+ print(f"Total penalty: {rollout.total_penalty}")
121
+ ```
122
+
123
+ ### PolicyReward
124
+
125
+ Converts policy violations to RL penalties:
126
+
127
+ ```python
128
+ from agent_lightning_gov import PolicyReward, RewardConfig
129
+
130
+ config = RewardConfig(
131
+ critical_penalty=-100.0, # Harsh penalty for critical violations
132
+ high_penalty=-50.0,
133
+ medium_penalty=-10.0,
134
+ low_penalty=-1.0,
135
+ clean_bonus=5.0, # Bonus for no violations
136
+ )
137
+
138
+ reward_fn = PolicyReward(kernel, config=config)
139
+
140
+ # Calculate reward
141
+ reward = reward_fn(rollout) # Base reward + policy penalties
142
+ ```
143
+
144
+ ### GovernedEnvironment
145
+
146
+ Gym-compatible training environment:
147
+
148
+ ```python
149
+ from agent_lightning_gov import GovernedEnvironment
150
+
151
+ env = GovernedEnvironment(
152
+ kernel,
153
+ config=EnvironmentConfig(
154
+ max_steps=100,
155
+ terminate_on_critical=True,
156
+ )
157
+ )
158
+
159
+ # Standard Gym interface
160
+ state, info = env.reset()
161
+ while not env.terminated:
162
+ action = agent.get_action(state)
163
+ state, reward, terminated, truncated, info = env.step(action)
164
+ ```
165
+
166
+ ### FlightRecorderEmitter
167
+
168
+ Export audit logs to LightningStore:
169
+
170
+ ```python
171
+ from agent_os import FlightRecorder
172
+ from agent_lightning_gov import FlightRecorderEmitter
173
+
174
+ recorder = FlightRecorder()
175
+ emitter = FlightRecorderEmitter(recorder)
176
+
177
+ # Export to LightningStore
178
+ emitter.emit_to_store(lightning_store)
179
+
180
+ # Or export to file for analysis
181
+ emitter.export_to_file("training_audit.json")
182
+
183
+ # Get violation summary
184
+ summary = emitter.get_violation_summary()
185
+ print(f"Violation rate: {summary['violation_rate']:.1%}")
186
+ ```
187
+
188
+ ## Ecosystem
189
+
190
+ Agent Lightning is one of 7 packages in the Agent Governance Toolkit:
191
+
192
+ | Package | Role |
193
+ |---------|------|
194
+ | **Agent OS** | Policy engine — deterministic action evaluation |
195
+ | **AgentMesh** | Trust infrastructure — identity, credentials, protocol bridges |
196
+ | **Agent Runtime** | Execution supervisor — rings, sessions, sagas |
197
+ | **Agent SRE** | Reliability — SLOs, circuit breakers, chaos testing |
198
+ | **Agent Compliance** | Regulatory compliance — GDPR, HIPAA, SOX frameworks |
199
+ | **Agent Marketplace** | Plugin lifecycle — discover, install, verify, sign |
200
+ | **Agent Lightning** | RL training governance — governed runners, policy rewards *(this package)* |
201
+
202
+ ## 📋 License
203
+
204
+ MIT — see [LICENSE](../../LICENSE).
@@ -0,0 +1,176 @@
1
+ # Agent Lightning — RL Training Governance
2
+
3
+ > [!IMPORTANT]
4
+ > **Public Preview** — The `agentmesh-lightning` package on PyPI is a Microsoft-signed
5
+ > public preview release. APIs may change before GA.
6
+
7
+ Train AI agents with RL while maintaining **0% policy violations**.
8
+
9
+ *Part of the [Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit)*
10
+
11
+ [![CI](https://github.com/microsoft/agent-governance-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/microsoft/agent-governance-toolkit/actions/workflows/ci.yml)
12
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
13
+ [![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://python.org)
14
+ [![PyPI](https://img.shields.io/pypi/v/agentmesh-lightning)](https://pypi.org/project/agentmesh-lightning/)
15
+
16
+ ## 🎯 Overview
17
+
18
+ This package provides governed RL training integration:
19
+ - **Agent-Lightning** = Training/Optimization (the "brains")
20
+ - **Agent-OS** = Governance/Safety (the "guardrails")
21
+
22
+ **Result**: Agents learn to be smart AND safe from the start.
23
+
24
+ > **Note:** This package was extracted from `agent_os.integrations.agent_lightning`.
25
+ > The old import path still works via a backward-compatibility shim but new code
26
+ > should import from `agent_lightning_gov` directly.
27
+
28
+ ## 🚀 Quick Start
29
+
30
+ ```bash
31
+ pip install agentmesh-lightning
32
+ # Optional: pip install agent-os-kernel # for kernel integration
33
+ ```
34
+
35
+ ```python
36
+ from agent_lightning_gov import GovernedRunner, PolicyReward
37
+ from agent_os import KernelSpace
38
+ from agent_os.policies import SQLPolicy, CostControlPolicy
39
+
40
+ # 1. Create governed kernel
41
+ kernel = KernelSpace(policy=[
42
+ SQLPolicy(deny=["DROP", "DELETE"]),
43
+ CostControlPolicy(max_cost_usd=100)
44
+ ])
45
+
46
+ # 2. Create governed runner
47
+ runner = GovernedRunner(kernel)
48
+
49
+ # 3. Create policy-aware reward function
50
+ def base_accuracy(rollout):
51
+ return rollout.task_output.accuracy if rollout.success else 0.0
52
+
53
+ reward_fn = PolicyReward(kernel, base_reward_fn=base_accuracy)
54
+
55
+ # 4. Train with Agent-Lightning
56
+ from agentlightning import Trainer
57
+ trainer = Trainer(
58
+ runner=runner,
59
+ reward_fn=reward_fn,
60
+ algorithm="GRPO"
61
+ )
62
+
63
+ trainer.train(num_epochs=100)
64
+ ```
65
+
66
+ ## 📊 Key Benefits
67
+
68
+ | Metric | Without Agent-OS | With Agent-OS |
69
+ |--------|------------------|---------------|
70
+ | Policy Violations | 12.3% | **0.0%** |
71
+ | Task Accuracy | 76.4% | **79.2%** |
72
+ | Training Stability | Variable | Consistent |
73
+
74
+ ## 🔧 Components
75
+
76
+ ### GovernedRunner
77
+
78
+ Agent-Lightning runner that enforces policies during execution:
79
+
80
+ ```python
81
+ from agent_lightning_gov import GovernedRunner
82
+
83
+ runner = GovernedRunner(
84
+ kernel,
85
+ fail_on_violation=False, # Continue but penalize
86
+ log_violations=True, # Log all violations
87
+ )
88
+
89
+ # Execute a task
90
+ rollout = await runner.step(task_input)
91
+ print(f"Violations: {len(rollout.violations)}")
92
+ print(f"Total penalty: {rollout.total_penalty}")
93
+ ```
94
+
95
+ ### PolicyReward
96
+
97
+ Converts policy violations to RL penalties:
98
+
99
+ ```python
100
+ from agent_lightning_gov import PolicyReward, RewardConfig
101
+
102
+ config = RewardConfig(
103
+ critical_penalty=-100.0, # Harsh penalty for critical violations
104
+ high_penalty=-50.0,
105
+ medium_penalty=-10.0,
106
+ low_penalty=-1.0,
107
+ clean_bonus=5.0, # Bonus for no violations
108
+ )
109
+
110
+ reward_fn = PolicyReward(kernel, config=config)
111
+
112
+ # Calculate reward
113
+ reward = reward_fn(rollout) # Base reward + policy penalties
114
+ ```
115
+
116
+ ### GovernedEnvironment
117
+
118
+ Gym-compatible training environment:
119
+
120
+ ```python
121
+ from agent_lightning_gov import GovernedEnvironment
122
+
123
+ env = GovernedEnvironment(
124
+ kernel,
125
+ config=EnvironmentConfig(
126
+ max_steps=100,
127
+ terminate_on_critical=True,
128
+ )
129
+ )
130
+
131
+ # Standard Gym interface
132
+ state, info = env.reset()
133
+ while not env.terminated:
134
+ action = agent.get_action(state)
135
+ state, reward, terminated, truncated, info = env.step(action)
136
+ ```
137
+
138
+ ### FlightRecorderEmitter
139
+
140
+ Export audit logs to LightningStore:
141
+
142
+ ```python
143
+ from agent_os import FlightRecorder
144
+ from agent_lightning_gov import FlightRecorderEmitter
145
+
146
+ recorder = FlightRecorder()
147
+ emitter = FlightRecorderEmitter(recorder)
148
+
149
+ # Export to LightningStore
150
+ emitter.emit_to_store(lightning_store)
151
+
152
+ # Or export to file for analysis
153
+ emitter.export_to_file("training_audit.json")
154
+
155
+ # Get violation summary
156
+ summary = emitter.get_violation_summary()
157
+ print(f"Violation rate: {summary['violation_rate']:.1%}")
158
+ ```
159
+
160
+ ## Ecosystem
161
+
162
+ Agent Lightning is one of 7 packages in the Agent Governance Toolkit:
163
+
164
+ | Package | Role |
165
+ |---------|------|
166
+ | **Agent OS** | Policy engine — deterministic action evaluation |
167
+ | **AgentMesh** | Trust infrastructure — identity, credentials, protocol bridges |
168
+ | **Agent Runtime** | Execution supervisor — rings, sessions, sagas |
169
+ | **Agent SRE** | Reliability — SLOs, circuit breakers, chaos testing |
170
+ | **Agent Compliance** | Regulatory compliance — GDPR, HIPAA, SOX frameworks |
171
+ | **Agent Marketplace** | Plugin lifecycle — discover, install, verify, sign |
172
+ | **Agent Lightning** | RL training governance — governed runners, policy rewards *(this package)* |
173
+
174
+ ## 📋 License
175
+
176
+ MIT — see [LICENSE](../../LICENSE).
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0,<69.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agentmesh_lightning"
7
+ version = "3.0.2"
8
+ description = "Public Preview — Agent-Lightning RL integration for the Agent Governance Toolkit: governed training with policy enforcement"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ {name = "Microsoft Corporation", email = "agentgovtoolkit@microsoft.com"},
14
+ ]
15
+ maintainers = [
16
+ {name = "Agent Governance Toolkit Team", email = "agentgovtoolkit@microsoft.com"},
17
+ ]
18
+ keywords = [
19
+ "ai-agents", "governance", "reinforcement-learning",
20
+ "agentmesh-lightning", "agent-os", "enterprise-ai"
21
+ ]
22
+ classifiers = [
23
+ "Development Status :: 4 - Beta",
24
+ "Intended Audience :: Developers",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.9",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
31
+ ]
32
+ dependencies = []
33
+
34
+ [project.optional-dependencies]
35
+ agent-os = ["agent-os-kernel>=1.0.0,<2.0"]
36
+ dev = ["pytest>=7.0,<8.0", "pytest-cov"]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/microsoft/agent-governance-toolkit"
40
+ Repository = "https://github.com/microsoft/agent-governance-toolkit"
41
+ "Bug Tracker" = "https://github.com/microsoft/agent-governance-toolkit/issues"
42
+
43
+ [tool.setuptools.packages.find]
44
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,36 @@
1
+ # Copyright (c) Microsoft Corporation.
2
+ # Licensed under the MIT License.
3
+ """
4
+ Agent-Lightning Governance Integration
5
+ =======================================
6
+
7
+ Provides kernel-level safety during Agent-Lightning RL training.
8
+
9
+ Key components:
10
+ - GovernedRunner: Agent-Lightning runner with policy enforcement
11
+ - PolicyReward: Convert policy violations to RL penalties
12
+ - FlightRecorderEmitter: Export audit logs to LightningStore
13
+ - GovernedEnvironment: Training environment with governance constraints
14
+
15
+ Example:
16
+ >>> from agent_lightning_gov import GovernedRunner, PolicyReward
17
+ >>> from agent_os import KernelSpace
18
+ >>> from agent_os.policies import SQLPolicy
19
+ >>>
20
+ >>> kernel = KernelSpace(policy=SQLPolicy())
21
+ >>> runner = GovernedRunner(kernel)
22
+ >>> reward_fn = PolicyReward(kernel, base_reward_fn=accuracy)
23
+ """
24
+
25
+ from .emitter import FlightRecorderEmitter
26
+ from .environment import GovernedEnvironment
27
+ from .reward import PolicyReward, policy_penalty
28
+ from .runner import GovernedRunner
29
+
30
+ __all__ = [
31
+ "GovernedRunner",
32
+ "PolicyReward",
33
+ "policy_penalty",
34
+ "FlightRecorderEmitter",
35
+ "GovernedEnvironment",
36
+ ]