agent-learning 0.4.1__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.
Files changed (93) hide show
  1. agent_learning-0.4.1/LICENSE +21 -0
  2. agent_learning-0.4.1/PKG-INFO +82 -0
  3. agent_learning-0.4.1/PYPI.md +15 -0
  4. agent_learning-0.4.1/README.md +87 -0
  5. agent_learning-0.4.1/pyproject.toml +79 -0
  6. agent_learning-0.4.1/setup.cfg +4 -0
  7. agent_learning-0.4.1/src/agent_learning/__init__.py +160 -0
  8. agent_learning-0.4.1/src/agent_learning/_version.py +3 -0
  9. agent_learning-0.4.1/src/agent_learning/capture.py +271 -0
  10. agent_learning-0.4.1/src/agent_learning/classifiers/__init__.py +37 -0
  11. agent_learning-0.4.1/src/agent_learning/classifiers/base.py +185 -0
  12. agent_learning-0.4.1/src/agent_learning/classifiers/router.py +236 -0
  13. agent_learning-0.4.1/src/agent_learning/classifiers/scorers/__init__.py +34 -0
  14. agent_learning-0.4.1/src/agent_learning/classifiers/scorers/_base.py +162 -0
  15. agent_learning-0.4.1/src/agent_learning/classifiers/scorers/adherence.py +26 -0
  16. agent_learning-0.4.1/src/agent_learning/classifiers/scorers/completion.py +26 -0
  17. agent_learning-0.4.1/src/agent_learning/classifiers/scorers/intent.py +25 -0
  18. agent_learning-0.4.1/src/agent_learning/cli.py +386 -0
  19. agent_learning-0.4.1/src/agent_learning/config.py +524 -0
  20. agent_learning-0.4.1/src/agent_learning/learners/__init__.py +6 -0
  21. agent_learning-0.4.1/src/agent_learning/learners/base.py +38 -0
  22. agent_learning-0.4.1/src/agent_learning/learners/reinforce.py +153 -0
  23. agent_learning-0.4.1/src/agent_learning/metrics/__init__.py +22 -0
  24. agent_learning-0.4.1/src/agent_learning/metrics/base.py +233 -0
  25. agent_learning-0.4.1/src/agent_learning/metrics/intent_resolution.py +50 -0
  26. agent_learning-0.4.1/src/agent_learning/metrics/registry.py +42 -0
  27. agent_learning-0.4.1/src/agent_learning/metrics/task_adherence.py +42 -0
  28. agent_learning-0.4.1/src/agent_learning/metrics/task_completion.py +54 -0
  29. agent_learning-0.4.1/src/agent_learning/policy/__init__.py +7 -0
  30. agent_learning-0.4.1/src/agent_learning/policy/base.py +59 -0
  31. agent_learning-0.4.1/src/agent_learning/policy/contextual_softmax.py +243 -0
  32. agent_learning-0.4.1/src/agent_learning/policy/softmax_bandit.py +157 -0
  33. agent_learning-0.4.1/src/agent_learning/py.typed +1 -0
  34. agent_learning-0.4.1/src/agent_learning/rewards/__init__.py +6 -0
  35. agent_learning-0.4.1/src/agent_learning/rewards/shaping.py +121 -0
  36. agent_learning-0.4.1/src/agent_learning/rewards/writer.py +130 -0
  37. agent_learning-0.4.1/src/agent_learning/scorers/__init__.py +187 -0
  38. agent_learning-0.4.1/src/agent_learning/scorers/base.py +49 -0
  39. agent_learning-0.4.1/src/agent_learning/scorers/llm/__init__.py +19 -0
  40. agent_learning-0.4.1/src/agent_learning/scorers/llm/_base.py +126 -0
  41. agent_learning-0.4.1/src/agent_learning/scorers/llm/adherence.py +21 -0
  42. agent_learning-0.4.1/src/agent_learning/scorers/llm/completion.py +21 -0
  43. agent_learning-0.4.1/src/agent_learning/scorers/llm/intent.py +21 -0
  44. agent_learning-0.4.1/src/agent_learning/scorers/nlp/__init__.py +16 -0
  45. agent_learning-0.4.1/src/agent_learning/scorers/nlp/_base.py +99 -0
  46. agent_learning-0.4.1/src/agent_learning/scorers/nlp/adherence.py +17 -0
  47. agent_learning-0.4.1/src/agent_learning/scorers/nlp/completion.py +17 -0
  48. agent_learning-0.4.1/src/agent_learning/scorers/nlp/intent.py +17 -0
  49. agent_learning-0.4.1/src/agent_learning/scorers/nlp_text/__init__.py +26 -0
  50. agent_learning-0.4.1/src/agent_learning/scorers/nlp_text/_base.py +234 -0
  51. agent_learning-0.4.1/src/agent_learning/scorers/nlp_text/adherence.py +94 -0
  52. agent_learning-0.4.1/src/agent_learning/scorers/nlp_text/completion.py +91 -0
  53. agent_learning-0.4.1/src/agent_learning/scorers/nlp_text/intent.py +59 -0
  54. agent_learning-0.4.1/src/agent_learning/scorers/slm/__init__.py +25 -0
  55. agent_learning-0.4.1/src/agent_learning/scorers/slm/_base.py +292 -0
  56. agent_learning-0.4.1/src/agent_learning/scorers/slm/adherence.py +98 -0
  57. agent_learning-0.4.1/src/agent_learning/scorers/slm/completion.py +111 -0
  58. agent_learning-0.4.1/src/agent_learning/scorers/slm/intent.py +80 -0
  59. agent_learning-0.4.1/src/agent_learning/scorers/stdlib/__init__.py +38 -0
  60. agent_learning-0.4.1/src/agent_learning/scorers/stdlib/_text.py +87 -0
  61. agent_learning-0.4.1/src/agent_learning/scorers/stdlib/adherence.py +157 -0
  62. agent_learning-0.4.1/src/agent_learning/scorers/stdlib/completion.py +117 -0
  63. agent_learning-0.4.1/src/agent_learning/scorers/stdlib/intent.py +182 -0
  64. agent_learning-0.4.1/src/agent_learning/storage/__init__.py +14 -0
  65. agent_learning-0.4.1/src/agent_learning/storage/base.py +156 -0
  66. agent_learning-0.4.1/src/agent_learning/storage/cosmos.py +506 -0
  67. agent_learning-0.4.1/src/agent_learning/storage/local.py +353 -0
  68. agent_learning-0.4.1/src/agent_learning/storage/memory.py +209 -0
  69. agent_learning-0.4.1/src/agent_learning/training/__init__.py +5 -0
  70. agent_learning-0.4.1/src/agent_learning/training/runner.py +172 -0
  71. agent_learning-0.4.1/src/agent_learning/types.py +507 -0
  72. agent_learning-0.4.1/src/agent_learning.egg-info/PKG-INFO +82 -0
  73. agent_learning-0.4.1/src/agent_learning.egg-info/SOURCES.txt +91 -0
  74. agent_learning-0.4.1/src/agent_learning.egg-info/dependency_links.txt +1 -0
  75. agent_learning-0.4.1/src/agent_learning.egg-info/entry_points.txt +2 -0
  76. agent_learning-0.4.1/src/agent_learning.egg-info/requires.txt +29 -0
  77. agent_learning-0.4.1/src/agent_learning.egg-info/top_level.txt +1 -0
  78. agent_learning-0.4.1/tests/test_capture.py +57 -0
  79. agent_learning-0.4.1/tests/test_cli.py +230 -0
  80. agent_learning-0.4.1/tests/test_contextual_policy.py +120 -0
  81. agent_learning-0.4.1/tests/test_default_store.py +56 -0
  82. agent_learning-0.4.1/tests/test_end_to_end.py +164 -0
  83. agent_learning-0.4.1/tests/test_learner.py +91 -0
  84. agent_learning-0.4.1/tests/test_policy.py +50 -0
  85. agent_learning-0.4.1/tests/test_scorers.py +346 -0
  86. agent_learning-0.4.1/tests/test_scorers_llm.py +244 -0
  87. agent_learning-0.4.1/tests/test_scorers_nlp_text.py +269 -0
  88. agent_learning-0.4.1/tests/test_scorers_slm.py +348 -0
  89. agent_learning-0.4.1/tests/test_scorers_stdlib.py +468 -0
  90. agent_learning-0.4.1/tests/test_shaping.py +158 -0
  91. agent_learning-0.4.1/tests/test_storage_local.py +186 -0
  92. agent_learning-0.4.1/tests/test_storage_memory.py +102 -0
  93. agent_learning-0.4.1/tests/test_types.py +118 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Microsoft
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,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-learning
3
+ Version: 0.4.1
4
+ Summary: Native, in-process reinforcement learning SDK for AI agents — in-memory and local-file storage by default.
5
+ Author: Chris Tava
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Microsoft
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/microsoft/agent-learning
29
+ Project-URL: Repository, https://github.com/microsoft/agent-learning
30
+ Project-URL: Issues, https://github.com/microsoft/agent-learning/issues
31
+ Keywords: reinforcement-learning,ai-agents,azure,evaluation,rlhf
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.10
37
+ Classifier: Programming Language :: Python :: 3.11
38
+ Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
40
+ Requires-Python: >=3.10
41
+ Description-Content-Type: text/markdown
42
+ License-File: LICENSE
43
+ Requires-Dist: numpy>=1.24
44
+ Requires-Dist: azure-identity>=1.15
45
+ Requires-Dist: azure-ai-evaluation>=1.0.0
46
+ Requires-Dist: pydantic>=2.0
47
+ Provides-Extra: dev
48
+ Requires-Dist: pytest>=7.4; extra == "dev"
49
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
50
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
51
+ Requires-Dist: ruff>=0.1; extra == "dev"
52
+ Requires-Dist: mypy>=1.6; extra == "dev"
53
+ Provides-Extra: cosmos
54
+ Requires-Dist: azure-cosmos>=4.5; extra == "cosmos"
55
+ Provides-Extra: nlp
56
+ Requires-Dist: scikit-learn>=1.3; extra == "nlp"
57
+ Requires-Dist: scipy>=1.10; extra == "nlp"
58
+ Requires-Dist: joblib>=1.3; extra == "nlp"
59
+ Provides-Extra: examples
60
+ Requires-Dist: pyyaml>=6.0; extra == "examples"
61
+ Provides-Extra: slm
62
+ Requires-Dist: onnxruntime-genai>=0.5; extra == "slm"
63
+ Provides-Extra: llm
64
+ Requires-Dist: azure-ai-evaluation>=1.0.0; extra == "llm"
65
+ Requires-Dist: azure-identity>=1.15; extra == "llm"
66
+ Dynamic: license-file
67
+
68
+ # agent-learning
69
+
70
+ Native reinforcement learning SDK for AI agents. An in-process learner optimizes a small, interpretable policy over discrete agent choices (understand intent and complete task by choosing the right outcome).
71
+
72
+ ## How it works
73
+
74
+ The SDK improves agents without LLM weight fine-tuning. There are no GPU fine-tune jobs and no opaque update cycles — just three pieces that run in your existing Python process:
75
+
76
+ 1. The **policy** is a softmax distribution over `N` discrete actions (e.g., "take action A", "take action B", "take action C"). It lives in Python and updates in milliseconds.
77
+
78
+ 2. Each episode is **evaluated** by three AI Evaluation evaluators — `IntentResolutionEvaluator`, `TaskAdherenceEvaluator`, and `TaskCompletionEvaluator` — whose scores are combined into a single scalar reward.
79
+
80
+ 3. A **REINFORCE-with-baseline** learner updates the policy logits directly from logged episodes. Updates are tiny gradient steps that run on local compute and persist through a pluggable store — in-memory or local files by default, with Azure Cosmos DB optional.
81
+
82
+ Every episode, reward, run, and deployment is captured by the configured store — in-memory or local files by default, or Azure Cosmos DB — giving you a complete lineage and audit trail of how the policy evolved over time.
@@ -0,0 +1,15 @@
1
+ # agent-learning
2
+
3
+ Native reinforcement learning SDK for AI agents. An in-process learner optimizes a small, interpretable policy over discrete agent choices (understand intent and complete task by choosing the right outcome).
4
+
5
+ ## How it works
6
+
7
+ The SDK improves agents without LLM weight fine-tuning. There are no GPU fine-tune jobs and no opaque update cycles — just three pieces that run in your existing Python process:
8
+
9
+ 1. The **policy** is a softmax distribution over `N` discrete actions (e.g., "take action A", "take action B", "take action C"). It lives in Python and updates in milliseconds.
10
+
11
+ 2. Each episode is **evaluated** by three AI Evaluation evaluators — `IntentResolutionEvaluator`, `TaskAdherenceEvaluator`, and `TaskCompletionEvaluator` — whose scores are combined into a single scalar reward.
12
+
13
+ 3. A **REINFORCE-with-baseline** learner updates the policy logits directly from logged episodes. Updates are tiny gradient steps that run on local compute and persist through a pluggable store — in-memory or local files by default, with Azure Cosmos DB optional.
14
+
15
+ Every episode, reward, run, and deployment is captured by the configured store — in-memory or local files by default, or Azure Cosmos DB — giving you a complete lineage and audit trail of how the policy evolved over time.
@@ -0,0 +1,87 @@
1
+ # agent-learning
2
+
3
+ Native reinforcement learning SDK for AI agents. An in-process
4
+ learner optimizes a small, interpretable policy over discrete agent choices (e.g., "take action A", "take action B", "take action C") using AI Evaluation scores as the reward
5
+ signal.
6
+
7
+ <p align="center">
8
+ <img src="images/agent-learning-loop.svg" alt="Animated loop: Policy chooses an action, Score evaluates the episode, and Learner updates the policy" width="960" style="max-width:100%; height:auto;" />
9
+ </p>
10
+
11
+ ## How it works
12
+
13
+ The SDK improves agents without LLM weight fine-tuning. There are no GPU fine-tune jobs and no opaque update cycles — just three pieces that run in your existing Python process:
14
+
15
+ 1. The **policy** is a softmax distribution over `N` discrete
16
+ actions (e.g., "take action A", "take action B", "take action C"). It lives in Python and updates in milliseconds.
17
+
18
+ <img src="images/0f85e08d0c47cd01.png" alt="Policy selects one of N discrete actions" width="360" style="max-width:100%; height:auto;" />
19
+
20
+ 2. Each episode is **evaluated** by three AI Evaluation
21
+ evaluators — `IntentResolutionEvaluator`, `TaskAdherenceEvaluator`,
22
+ and `TaskCompletionEvaluator` — whose scores are combined into a single scalar reward.
23
+
24
+ <img src="images/246d112f995b785a.png" alt="Three evaluator scores feed a single scalar reward" width="360" style="max-width:100%; height:auto;" />
25
+
26
+ 3. A **Reinforce-with-baseline** learner updates the policy logits
27
+ directly from stored episodes. Updates are tiny gradient steps
28
+ that run on local compute and persist through a pluggable store — in-memory
29
+ or local files by default, with Azure Cosmos DB optional.
30
+
31
+ <img src="images/cc970c453583c982.png" alt="Policy quality improves with every batch of episodes" width="360" style="max-width:100%; height:auto;" />
32
+
33
+ Every episode, reward, run, and deployment is captured by the
34
+ configured store — in-memory or local files by default, or Azure Cosmos DB —
35
+ giving you a complete lineage and audit trail of how the policy
36
+ evolved over time.
37
+
38
+ ## Install
39
+
40
+ ### Windows CLI
41
+
42
+ For a Python-independent installation, download `agent-learn.exe` or the
43
+ standalone installer from the
44
+ [latest GitHub release](https://github.com/microsoft/agent-learning/releases/latest).
45
+ The installer can add its installation directory to your user `PATH`, so
46
+ `agent-learn` works from PowerShell or Command Prompt without Python or `pip`.
47
+
48
+ ```powershell
49
+ agent-learn.exe --help
50
+ ```
51
+
52
+ ### Python SDK
53
+
54
+ Released versions are published to PyPI:
55
+ <https://pypi.org/project/agent-learning/>.
56
+
57
+ ```powershell
58
+ py -m pip install agent-learning
59
+ agent-learn.exe --help
60
+ ```
61
+
62
+ `pip` installs `agent-learn.exe` into the active Python environment's
63
+ `Scripts` directory.
64
+
65
+ ## Usage
66
+
67
+ The `agent-learn` CLI provides the current task-learning-loop operations:
68
+
69
+ ```text
70
+ agent-learn list
71
+ agent-learn tasks-list <agent_id>
72
+ agent-learn task-episodes-count <agent_id> [--task-id <task_id>]
73
+ agent-learn task-episodes-list <agent_id> [--task-id <task_id>] [--limit <1-500>] [--include-incomplete]
74
+ agent-learn task-policy-init --agent-id <agent_id> --task-id <task_id> --actions ./actions.json
75
+ agent-learn task-episode-register --agent-id <agent_id> --task-id <task_id> --episode ./episode.json
76
+ agent-learn score --agent-id <agent_id> [--task-id <task_id>] [--limit <1-500>]
77
+ agent-learn train --agent-id <agent_id> [--task-id <task_id>] [--limit <1-500>] [--start-date <date>] [--end-date <date>] [--skip-scoring]
78
+ agent-learn task-policy --agent-id <agent_id> --task-id <task_id>
79
+ ```
80
+
81
+ The subprocess-level functional workflow uses an isolated local store. Run the
82
+ interactive capture scenario first, followed by the offline batch update:
83
+
84
+ ```powershell
85
+ python tests/functional_cli_interactive.py
86
+ python tests/functional_cli_batch.py
87
+ ```
@@ -0,0 +1,79 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-learning"
7
+ version = "0.4.1"
8
+ description = "Native, in-process reinforcement learning SDK for AI agents — in-memory and local-file storage by default."
9
+ readme = "PYPI.md"
10
+ requires-python = ">=3.10"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "Chris Tava" }]
13
+ keywords = ["reinforcement-learning", "ai-agents", "azure", "evaluation", "rlhf"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
23
+ ]
24
+
25
+ dependencies = [
26
+ "numpy>=1.24",
27
+ "azure-identity>=1.15",
28
+ "azure-ai-evaluation>=1.0.0",
29
+ "pydantic>=2.0",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "pytest>=7.4",
35
+ "pytest-asyncio>=0.21",
36
+ "pytest-cov>=4.1",
37
+ "ruff>=0.1",
38
+ "mypy>=1.6",
39
+ ]
40
+ cosmos = [
41
+ "azure-cosmos>=4.5",
42
+ ]
43
+ nlp = [
44
+ "scikit-learn>=1.3",
45
+ "scipy>=1.10",
46
+ "joblib>=1.3",
47
+ ]
48
+ examples = [
49
+ "pyyaml>=6.0",
50
+ ]
51
+ slm = [
52
+ "onnxruntime-genai>=0.5",
53
+ ]
54
+ llm = [
55
+ "azure-ai-evaluation>=1.0.0",
56
+ "azure-identity>=1.15",
57
+ ]
58
+
59
+ [project.scripts]
60
+ agent-learn = "agent_learning.cli:main"
61
+
62
+ [project.urls]
63
+ Homepage = "https://github.com/microsoft/agent-learning"
64
+ Repository = "https://github.com/microsoft/agent-learning"
65
+ Issues = "https://github.com/microsoft/agent-learning/issues"
66
+
67
+ [tool.setuptools.packages.find]
68
+ where = ["src"]
69
+
70
+ [tool.setuptools.package-data]
71
+ agent_learning = ["py.typed"]
72
+
73
+ [tool.ruff]
74
+ line-length = 110
75
+ target-version = "py310"
76
+
77
+ [tool.pytest.ini_options]
78
+ testpaths = ["tests"]
79
+ asyncio_mode = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,160 @@
1
+ """Native reinforcement learning SDK for AI agents.
2
+
3
+ Replaces the agent-lightning LLM fine-tuning loop with a fully
4
+ native, in-process learner. The SDK is organised into five layers:
5
+
6
+ - ``agent_learning.types`` - durable record types (``Episode``,
7
+ ``Reward``, ``PolicySnapshot``, ...).
8
+ - ``agent_learning.storage`` - pluggable persistence (Cosmos DB,
9
+ local file system, and in-memory).
10
+ - ``agent_learning.metrics`` - score-based metrics that wrap the
11
+ Azure AI Evaluation evaluators for Intent Resolution, Task
12
+ Adherence, and Task Completion.
13
+ - ``agent_learning.rewards`` - reward shaping + persistence.
14
+ - ``agent_learning.policy`` - discrete softmax bandit policy.
15
+ - ``agent_learning.learners`` - REINFORCE-with-baseline learner.
16
+ - ``agent_learning.training`` - end-to-end :class:`LearningRunner`.
17
+
18
+ Quick start::
19
+
20
+ from agent_learning import (
21
+ Action,
22
+ EpisodeCapture,
23
+ LearningRunner,
24
+ SoftmaxPolicy,
25
+ )
26
+
27
+ actions = [Action(id="prompt_A"), Action(id="prompt_B")]
28
+ policy = SoftmaxPolicy.from_actions(actions, agent_id="dq", task_id="sales-summary")
29
+
30
+ # Capture
31
+ capture = EpisodeCapture()
32
+ decision = policy.choose()
33
+ ctx = capture.start(
34
+ "Tell me my Q3 sales summary",
35
+ task_id="sales-summary",
36
+ intent_summary="Summarize Q3 sales",
37
+ action_type="chat",
38
+ action_name=decision.action.id,
39
+ expected_outcome="An accurate Q3 sales summary",
40
+ policy_id=policy.snapshot().id,
41
+ policy_version=policy.snapshot().version,
42
+ action_id=decision.action.id,
43
+ action_logprob=decision.logprob,
44
+ )
45
+ # ... agent runs, records tool calls, produces output ...
46
+ episode = capture.end(
47
+ ctx,
48
+ assistant_output="...",
49
+ execution_status="completed",
50
+ result_summary="Returned the sales summary",
51
+ )
52
+
53
+ # Train
54
+ runner = LearningRunner(policy=policy)
55
+ run = runner.run_offline_batch("dq", task_id="sales-summary", episode_limit=200)
56
+ """
57
+
58
+ from ._version import __version__
59
+ from .capture import CaptureContext, EpisodeCapture, get_capture
60
+ from .classifiers import (
61
+ AdherenceScorer,
62
+ Classifier,
63
+ ClassifierResult,
64
+ CompletionScorer,
65
+ IntentScorer,
66
+ RouterClassifier,
67
+ )
68
+ from .config import (
69
+ CaptureConfig,
70
+ CosmosConfig,
71
+ ScoreConfig,
72
+ LearnerConfig,
73
+ ShapingConfig,
74
+ )
75
+ from .learners import Learner, LearnerResult, ReinforceLearner
76
+ from .metrics import (
77
+ IntentResolutionMetric,
78
+ MetricEvaluator,
79
+ MetricRequest,
80
+ TaskAdherenceMetric,
81
+ TaskCompletionMetric,
82
+ default_metrics,
83
+ evaluate_all,
84
+ )
85
+ from .policy import ContextualSoftmaxPolicy, Policy, SoftmaxPolicy
86
+ from .rewards import RewardShaper, RewardWriter, shape_episode_reward
87
+ from .storage import (
88
+ CosmosStore,
89
+ InMemoryStore,
90
+ LearningStore,
91
+ LocalFileStore,
92
+ get_default_store,
93
+ )
94
+ from .training import LearningRunner
95
+ from .types import (
96
+ Action,
97
+ AgentSummary,
98
+ AgentTaskSummary,
99
+ Episode,
100
+ MetricName,
101
+ MetricResult,
102
+ PolicySnapshot,
103
+ Reward,
104
+ RewardSource,
105
+ ToolCall,
106
+ TrainingRun,
107
+ TrainingStatus,
108
+ )
109
+
110
+ __all__ = [
111
+ "Action",
112
+ "AdherenceScorer",
113
+ "AgentSummary",
114
+ "AgentTaskSummary",
115
+ "CaptureConfig",
116
+ "CaptureContext",
117
+ "Classifier",
118
+ "ClassifierResult",
119
+ "CompletionScorer",
120
+ "ContextualSoftmaxPolicy",
121
+ "CosmosConfig",
122
+ "CosmosStore",
123
+ "Episode",
124
+ "EpisodeCapture",
125
+ "InMemoryStore",
126
+ "IntentScorer",
127
+ "IntentResolutionMetric",
128
+ "ScoreConfig",
129
+ "Learner",
130
+ "LearnerConfig",
131
+ "LearnerResult",
132
+ "LearningRunner",
133
+ "LearningStore",
134
+ "LocalFileStore",
135
+ "MetricEvaluator",
136
+ "MetricName",
137
+ "MetricRequest",
138
+ "MetricResult",
139
+ "Policy",
140
+ "PolicySnapshot",
141
+ "ReinforceLearner",
142
+ "Reward",
143
+ "RewardShaper",
144
+ "RewardSource",
145
+ "RewardWriter",
146
+ "RouterClassifier",
147
+ "ShapingConfig",
148
+ "SoftmaxPolicy",
149
+ "TaskAdherenceMetric",
150
+ "TaskCompletionMetric",
151
+ "ToolCall",
152
+ "TrainingRun",
153
+ "TrainingStatus",
154
+ "__version__",
155
+ "default_metrics",
156
+ "evaluate_all",
157
+ "get_capture",
158
+ "get_default_store",
159
+ "shape_episode_reward",
160
+ ]
@@ -0,0 +1,3 @@
1
+ """Package version."""
2
+
3
+ __version__ = "0.4.1"