agentmesh-lightning 2.3.0__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,206 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentmesh-lightning
3
+ Version: 2.3.0
4
+ Summary: Community Edition — Agent-Lightning RL integration for the Agent Governance Toolkit: governed training with policy enforcement
5
+ Author-email: Microsoft Corporation <agt@microsoft.com>
6
+ Maintainer-email: Agent Governance Toolkit Team <agt@microsoft.com>
7
+ License-Expression: 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,agent-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>=1.0.0; extra == "agent-os"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0; extra == "dev"
27
+ Requires-Dist: pytest-cov; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # Agent Lightning — RL Training Governance
31
+
32
+ > [!IMPORTANT]
33
+ > **Community Preview** — The `agentmesh-lightning` package on PyPI is a community preview release
34
+ > for testing and evaluation only. It is **not** an official Microsoft-signed release.
35
+ > Official signed packages will be available in a future release.
36
+
37
+ Train AI agents with RL while maintaining **0% policy violations**.
38
+
39
+ *Part of the [Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit)*
40
+
41
+ [![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)
42
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
43
+ [![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://python.org)
44
+ [![PyPI](https://img.shields.io/pypi/v/agent-lightning)](https://pypi.org/project/agent-lightning/)
45
+
46
+ ## 🎯 Overview
47
+
48
+ This package provides governed RL training integration:
49
+ - **Agent-Lightning** = Training/Optimization (the "brains")
50
+ - **Agent-OS** = Governance/Safety (the "guardrails")
51
+
52
+ **Result**: Agents learn to be smart AND safe from the start.
53
+
54
+ > **Note:** This package was extracted from `agent_os.integrations.agent_lightning`.
55
+ > The old import path still works via a backward-compatibility shim but new code
56
+ > should import from `agent_lightning_gov` directly.
57
+
58
+ ## 🚀 Quick Start
59
+
60
+ ```bash
61
+ pip install agent-lightning
62
+ # Optional: pip install agent-os-kernel # for kernel integration
63
+ ```
64
+
65
+ ```python
66
+ from agent_lightning_gov import GovernedRunner, PolicyReward
67
+ from agent_os import KernelSpace
68
+ from agent_os.policies import SQLPolicy, CostControlPolicy
69
+
70
+ # 1. Create governed kernel
71
+ kernel = KernelSpace(policy=[
72
+ SQLPolicy(deny=["DROP", "DELETE"]),
73
+ CostControlPolicy(max_cost_usd=100)
74
+ ])
75
+
76
+ # 2. Create governed runner
77
+ runner = GovernedRunner(kernel)
78
+
79
+ # 3. Create policy-aware reward function
80
+ def base_accuracy(rollout):
81
+ return rollout.task_output.accuracy if rollout.success else 0.0
82
+
83
+ reward_fn = PolicyReward(kernel, base_reward_fn=base_accuracy)
84
+
85
+ # 4. Train with Agent-Lightning
86
+ from agentlightning import Trainer
87
+ trainer = Trainer(
88
+ runner=runner,
89
+ reward_fn=reward_fn,
90
+ algorithm="GRPO"
91
+ )
92
+
93
+ trainer.train(num_epochs=100)
94
+ ```
95
+
96
+ ## 📊 Key Benefits
97
+
98
+ | Metric | Without Agent-OS | With Agent-OS |
99
+ |--------|------------------|---------------|
100
+ | Policy Violations | 12.3% | **0.0%** |
101
+ | Task Accuracy | 76.4% | **79.2%** |
102
+ | Training Stability | Variable | Consistent |
103
+
104
+ ## 🔧 Components
105
+
106
+ ### GovernedRunner
107
+
108
+ Agent-Lightning runner that enforces policies during execution:
109
+
110
+ ```python
111
+ from agent_lightning_gov import GovernedRunner
112
+
113
+ runner = GovernedRunner(
114
+ kernel,
115
+ fail_on_violation=False, # Continue but penalize
116
+ log_violations=True, # Log all violations
117
+ )
118
+
119
+ # Execute a task
120
+ rollout = await runner.step(task_input)
121
+ print(f"Violations: {len(rollout.violations)}")
122
+ print(f"Total penalty: {rollout.total_penalty}")
123
+ ```
124
+
125
+ ### PolicyReward
126
+
127
+ Converts policy violations to RL penalties:
128
+
129
+ ```python
130
+ from agent_lightning_gov import PolicyReward, RewardConfig
131
+
132
+ config = RewardConfig(
133
+ critical_penalty=-100.0, # Harsh penalty for critical violations
134
+ high_penalty=-50.0,
135
+ medium_penalty=-10.0,
136
+ low_penalty=-1.0,
137
+ clean_bonus=5.0, # Bonus for no violations
138
+ )
139
+
140
+ reward_fn = PolicyReward(kernel, config=config)
141
+
142
+ # Calculate reward
143
+ reward = reward_fn(rollout) # Base reward + policy penalties
144
+ ```
145
+
146
+ ### GovernedEnvironment
147
+
148
+ Gym-compatible training environment:
149
+
150
+ ```python
151
+ from agent_lightning_gov import GovernedEnvironment
152
+
153
+ env = GovernedEnvironment(
154
+ kernel,
155
+ config=EnvironmentConfig(
156
+ max_steps=100,
157
+ terminate_on_critical=True,
158
+ )
159
+ )
160
+
161
+ # Standard Gym interface
162
+ state, info = env.reset()
163
+ while not env.terminated:
164
+ action = agent.get_action(state)
165
+ state, reward, terminated, truncated, info = env.step(action)
166
+ ```
167
+
168
+ ### FlightRecorderEmitter
169
+
170
+ Export audit logs to LightningStore:
171
+
172
+ ```python
173
+ from agent_os import FlightRecorder
174
+ from agent_lightning_gov import FlightRecorderEmitter
175
+
176
+ recorder = FlightRecorder()
177
+ emitter = FlightRecorderEmitter(recorder)
178
+
179
+ # Export to LightningStore
180
+ emitter.emit_to_store(lightning_store)
181
+
182
+ # Or export to file for analysis
183
+ emitter.export_to_file("training_audit.json")
184
+
185
+ # Get violation summary
186
+ summary = emitter.get_violation_summary()
187
+ print(f"Violation rate: {summary['violation_rate']:.1%}")
188
+ ```
189
+
190
+ ## Ecosystem
191
+
192
+ Agent Lightning is one of 7 packages in the Agent Governance Toolkit:
193
+
194
+ | Package | Role |
195
+ |---------|------|
196
+ | **Agent OS** | Policy engine — deterministic action evaluation |
197
+ | **AgentMesh** | Trust infrastructure — identity, credentials, protocol bridges |
198
+ | **Agent Runtime** | Execution supervisor — rings, sessions, sagas |
199
+ | **Agent SRE** | Reliability — SLOs, circuit breakers, chaos testing |
200
+ | **Agent Compliance** | Regulatory compliance — GDPR, HIPAA, SOX frameworks |
201
+ | **Agent Marketplace** | Plugin lifecycle — discover, install, verify, sign |
202
+ | **Agent Lightning** | RL training governance — governed runners, policy rewards *(this package)* |
203
+
204
+ ## 📋 License
205
+
206
+ MIT — see [LICENSE](../../LICENSE).
@@ -0,0 +1,177 @@
1
+ # Agent Lightning — RL Training Governance
2
+
3
+ > [!IMPORTANT]
4
+ > **Community Preview** — The `agentmesh-lightning` package on PyPI is a community preview release
5
+ > for testing and evaluation only. It is **not** an official Microsoft-signed release.
6
+ > Official signed packages will be available in a future release.
7
+
8
+ Train AI agents with RL while maintaining **0% policy violations**.
9
+
10
+ *Part of the [Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit)*
11
+
12
+ [![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)
13
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
14
+ [![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://python.org)
15
+ [![PyPI](https://img.shields.io/pypi/v/agent-lightning)](https://pypi.org/project/agent-lightning/)
16
+
17
+ ## 🎯 Overview
18
+
19
+ This package provides governed RL training integration:
20
+ - **Agent-Lightning** = Training/Optimization (the "brains")
21
+ - **Agent-OS** = Governance/Safety (the "guardrails")
22
+
23
+ **Result**: Agents learn to be smart AND safe from the start.
24
+
25
+ > **Note:** This package was extracted from `agent_os.integrations.agent_lightning`.
26
+ > The old import path still works via a backward-compatibility shim but new code
27
+ > should import from `agent_lightning_gov` directly.
28
+
29
+ ## 🚀 Quick Start
30
+
31
+ ```bash
32
+ pip install agent-lightning
33
+ # Optional: pip install agent-os-kernel # for kernel integration
34
+ ```
35
+
36
+ ```python
37
+ from agent_lightning_gov import GovernedRunner, PolicyReward
38
+ from agent_os import KernelSpace
39
+ from agent_os.policies import SQLPolicy, CostControlPolicy
40
+
41
+ # 1. Create governed kernel
42
+ kernel = KernelSpace(policy=[
43
+ SQLPolicy(deny=["DROP", "DELETE"]),
44
+ CostControlPolicy(max_cost_usd=100)
45
+ ])
46
+
47
+ # 2. Create governed runner
48
+ runner = GovernedRunner(kernel)
49
+
50
+ # 3. Create policy-aware reward function
51
+ def base_accuracy(rollout):
52
+ return rollout.task_output.accuracy if rollout.success else 0.0
53
+
54
+ reward_fn = PolicyReward(kernel, base_reward_fn=base_accuracy)
55
+
56
+ # 4. Train with Agent-Lightning
57
+ from agentlightning import Trainer
58
+ trainer = Trainer(
59
+ runner=runner,
60
+ reward_fn=reward_fn,
61
+ algorithm="GRPO"
62
+ )
63
+
64
+ trainer.train(num_epochs=100)
65
+ ```
66
+
67
+ ## 📊 Key Benefits
68
+
69
+ | Metric | Without Agent-OS | With Agent-OS |
70
+ |--------|------------------|---------------|
71
+ | Policy Violations | 12.3% | **0.0%** |
72
+ | Task Accuracy | 76.4% | **79.2%** |
73
+ | Training Stability | Variable | Consistent |
74
+
75
+ ## 🔧 Components
76
+
77
+ ### GovernedRunner
78
+
79
+ Agent-Lightning runner that enforces policies during execution:
80
+
81
+ ```python
82
+ from agent_lightning_gov import GovernedRunner
83
+
84
+ runner = GovernedRunner(
85
+ kernel,
86
+ fail_on_violation=False, # Continue but penalize
87
+ log_violations=True, # Log all violations
88
+ )
89
+
90
+ # Execute a task
91
+ rollout = await runner.step(task_input)
92
+ print(f"Violations: {len(rollout.violations)}")
93
+ print(f"Total penalty: {rollout.total_penalty}")
94
+ ```
95
+
96
+ ### PolicyReward
97
+
98
+ Converts policy violations to RL penalties:
99
+
100
+ ```python
101
+ from agent_lightning_gov import PolicyReward, RewardConfig
102
+
103
+ config = RewardConfig(
104
+ critical_penalty=-100.0, # Harsh penalty for critical violations
105
+ high_penalty=-50.0,
106
+ medium_penalty=-10.0,
107
+ low_penalty=-1.0,
108
+ clean_bonus=5.0, # Bonus for no violations
109
+ )
110
+
111
+ reward_fn = PolicyReward(kernel, config=config)
112
+
113
+ # Calculate reward
114
+ reward = reward_fn(rollout) # Base reward + policy penalties
115
+ ```
116
+
117
+ ### GovernedEnvironment
118
+
119
+ Gym-compatible training environment:
120
+
121
+ ```python
122
+ from agent_lightning_gov import GovernedEnvironment
123
+
124
+ env = GovernedEnvironment(
125
+ kernel,
126
+ config=EnvironmentConfig(
127
+ max_steps=100,
128
+ terminate_on_critical=True,
129
+ )
130
+ )
131
+
132
+ # Standard Gym interface
133
+ state, info = env.reset()
134
+ while not env.terminated:
135
+ action = agent.get_action(state)
136
+ state, reward, terminated, truncated, info = env.step(action)
137
+ ```
138
+
139
+ ### FlightRecorderEmitter
140
+
141
+ Export audit logs to LightningStore:
142
+
143
+ ```python
144
+ from agent_os import FlightRecorder
145
+ from agent_lightning_gov import FlightRecorderEmitter
146
+
147
+ recorder = FlightRecorder()
148
+ emitter = FlightRecorderEmitter(recorder)
149
+
150
+ # Export to LightningStore
151
+ emitter.emit_to_store(lightning_store)
152
+
153
+ # Or export to file for analysis
154
+ emitter.export_to_file("training_audit.json")
155
+
156
+ # Get violation summary
157
+ summary = emitter.get_violation_summary()
158
+ print(f"Violation rate: {summary['violation_rate']:.1%}")
159
+ ```
160
+
161
+ ## Ecosystem
162
+
163
+ Agent Lightning is one of 7 packages in the Agent Governance Toolkit:
164
+
165
+ | Package | Role |
166
+ |---------|------|
167
+ | **Agent OS** | Policy engine — deterministic action evaluation |
168
+ | **AgentMesh** | Trust infrastructure — identity, credentials, protocol bridges |
169
+ | **Agent Runtime** | Execution supervisor — rings, sessions, sagas |
170
+ | **Agent SRE** | Reliability — SLOs, circuit breakers, chaos testing |
171
+ | **Agent Compliance** | Regulatory compliance — GDPR, HIPAA, SOX frameworks |
172
+ | **Agent Marketplace** | Plugin lifecycle — discover, install, verify, sign |
173
+ | **Agent Lightning** | RL training governance — governed runners, policy rewards *(this package)* |
174
+
175
+ ## 📋 License
176
+
177
+ MIT — see [LICENSE](../../LICENSE).
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agentmesh-lightning"
7
+ version = "2.3.0"
8
+ description = "Community Edition — Agent-Lightning RL integration for the Agent Governance Toolkit: governed training with policy enforcement"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ {name = "Microsoft Corporation", email = "agt@microsoft.com"},
14
+ ]
15
+ maintainers = [
16
+ {name = "Agent Governance Toolkit Team", email = "agt@microsoft.com"},
17
+ ]
18
+ keywords = [
19
+ "ai-agents", "governance", "reinforcement-learning",
20
+ "agent-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"]
36
+ dev = ["pytest>=7.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
+ ]