omni-experiments 1.0.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.
Files changed (120) hide show
  1. omni_experiments-1.0.0/.github/workflows/ci.yml +38 -0
  2. omni_experiments-1.0.0/.github/workflows/release.yml +70 -0
  3. omni_experiments-1.0.0/.gitignore +9 -0
  4. omni_experiments-1.0.0/.pre-commit-config.yaml +26 -0
  5. omni_experiments-1.0.0/AGENTS.md +11 -0
  6. omni_experiments-1.0.0/CODE_OF_CONDUCT.md +4 -0
  7. omni_experiments-1.0.0/CONTRIBUTING.md +59 -0
  8. omni_experiments-1.0.0/DEVELOPMENT.md +96 -0
  9. omni_experiments-1.0.0/GETTING-STARTED.md +198 -0
  10. omni_experiments-1.0.0/LICENSE +175 -0
  11. omni_experiments-1.0.0/NOTICE +2 -0
  12. omni_experiments-1.0.0/PKG-INFO +153 -0
  13. omni_experiments-1.0.0/README.md +128 -0
  14. omni_experiments-1.0.0/TESTING.md +79 -0
  15. omni_experiments-1.0.0/docs/agentcore-resources.md +67 -0
  16. omni_experiments-1.0.0/docs/agents.md +137 -0
  17. omni_experiments-1.0.0/docs/client-side-runs.md +165 -0
  18. omni_experiments-1.0.0/docs/commands.md +481 -0
  19. omni_experiments-1.0.0/docs/datasets.md +63 -0
  20. omni_experiments-1.0.0/docs/examples/README.md +26 -0
  21. omni_experiments-1.0.0/docs/examples/ab-comparison.md +41 -0
  22. omni_experiments-1.0.0/docs/examples/ci-gate.md +48 -0
  23. omni_experiments-1.0.0/docs/examples/execution-role.md +47 -0
  24. omni_experiments-1.0.0/docs/examples/hosted-run.md +61 -0
  25. omni_experiments-1.0.0/docs/examples/http-agent.md +66 -0
  26. omni_experiments-1.0.0/docs/examples/multi-turn.md +32 -0
  27. omni_experiments-1.0.0/docs/examples/python-api.md +68 -0
  28. omni_experiments-1.0.0/docs/examples/runtime-agent.md +41 -0
  29. omni_experiments-1.0.0/docs/examples/streaming-agent.md +41 -0
  30. omni_experiments-1.0.0/docs/hosted-runs.md +211 -0
  31. omni_experiments-1.0.0/docs/local-mode.md +235 -0
  32. omni_experiments-1.0.0/docs/managing-experiments.md +119 -0
  33. omni_experiments-1.0.0/docs/permissions.md +359 -0
  34. omni_experiments-1.0.0/docs/rules.md +230 -0
  35. omni_experiments-1.0.0/docs/trace-stats.md +134 -0
  36. omni_experiments-1.0.0/examples/agents/ag-ui-stream.json +20 -0
  37. omni_experiments-1.0.0/examples/agents/api-key.json +9 -0
  38. omni_experiments-1.0.0/examples/agents/bearer-token.json +7 -0
  39. omni_experiments-1.0.0/examples/agents/sigv4-agentcore.json +6 -0
  40. omni_experiments-1.0.0/examples/agents/sigv4-lambda-url.json +6 -0
  41. omni_experiments-1.0.0/examples/ci-gate.sh +69 -0
  42. omni_experiments-1.0.0/examples/datasets/cases.csv +3 -0
  43. omni_experiments-1.0.0/examples/datasets/cases.jsonl +4 -0
  44. omni_experiments-1.0.0/examples/python_api.py +65 -0
  45. omni_experiments-1.0.0/examples/rules/gates.json +12 -0
  46. omni_experiments-1.0.0/examples/rules/labels.json +7 -0
  47. omni_experiments-1.0.0/examples/rules/lower-is-better.json +8 -0
  48. omni_experiments-1.0.0/examples/rules/pr.json +7 -0
  49. omni_experiments-1.0.0/examples/rules/regressed-scores.json +11 -0
  50. omni_experiments-1.0.0/examples/rules/release.json +9 -0
  51. omni_experiments-1.0.0/install +152 -0
  52. omni_experiments-1.0.0/pyproject.toml +138 -0
  53. omni_experiments-1.0.0/src/omni_experiments/__init__.py +59 -0
  54. omni_experiments-1.0.0/src/omni_experiments/__main__.py +7 -0
  55. omni_experiments-1.0.0/src/omni_experiments/_terminal.py +120 -0
  56. omni_experiments-1.0.0/src/omni_experiments/_version.py +3 -0
  57. omni_experiments-1.0.0/src/omni_experiments/agentcore.py +1139 -0
  58. omni_experiments-1.0.0/src/omni_experiments/agentcore_resources.py +351 -0
  59. omni_experiments-1.0.0/src/omni_experiments/api.py +45 -0
  60. omni_experiments-1.0.0/src/omni_experiments/check.py +641 -0
  61. omni_experiments-1.0.0/src/omni_experiments/cli.py +1764 -0
  62. omni_experiments-1.0.0/src/omni_experiments/client.py +305 -0
  63. omni_experiments-1.0.0/src/omni_experiments/control_match.py +83 -0
  64. omni_experiments-1.0.0/src/omni_experiments/datasets.py +201 -0
  65. omni_experiments-1.0.0/src/omni_experiments/errors.py +88 -0
  66. omni_experiments-1.0.0/src/omni_experiments/hosted.py +497 -0
  67. omni_experiments-1.0.0/src/omni_experiments/http_invoker.py +895 -0
  68. omni_experiments-1.0.0/src/omni_experiments/local.py +915 -0
  69. omni_experiments-1.0.0/src/omni_experiments/local_run.py +334 -0
  70. omni_experiments-1.0.0/src/omni_experiments/lookup.py +83 -0
  71. omni_experiments-1.0.0/src/omni_experiments/manage.py +358 -0
  72. omni_experiments-1.0.0/src/omni_experiments/omni_spans.py +435 -0
  73. omni_experiments-1.0.0/src/omni_experiments/permissions.py +144 -0
  74. omni_experiments-1.0.0/src/omni_experiments/providers.py +60 -0
  75. omni_experiments-1.0.0/src/omni_experiments/py.typed +0 -0
  76. omni_experiments-1.0.0/src/omni_experiments/render.py +425 -0
  77. omni_experiments-1.0.0/src/omni_experiments/rules.py +467 -0
  78. omni_experiments-1.0.0/src/omni_experiments/runner.py +1365 -0
  79. omni_experiments-1.0.0/src/omni_experiments/targets.py +283 -0
  80. omni_experiments-1.0.0/src/omni_experiments/types.py +139 -0
  81. omni_experiments-1.0.0/src/omni_experiments/verdict.py +925 -0
  82. omni_experiments-1.0.0/src/omni_experiments/wire.py +130 -0
  83. omni_experiments-1.0.0/tests/__init__.py +2 -0
  84. omni_experiments-1.0.0/tests/_scoring.py +249 -0
  85. omni_experiments-1.0.0/tests/conftest.py +59 -0
  86. omni_experiments-1.0.0/tests/fake_api.py +1567 -0
  87. omni_experiments-1.0.0/tests/golden/verdict/README.md +35 -0
  88. omni_experiments-1.0.0/tests/golden/verdict/verdicts.json +6184 -0
  89. omni_experiments-1.0.0/tests/helpers.py +62 -0
  90. omni_experiments-1.0.0/tests/stubs.py +47 -0
  91. omni_experiments-1.0.0/tests/test_agentcore.py +1716 -0
  92. omni_experiments-1.0.0/tests/test_agentcore_resources.py +399 -0
  93. omni_experiments-1.0.0/tests/test_batching.py +444 -0
  94. omni_experiments-1.0.0/tests/test_check.py +1040 -0
  95. omni_experiments-1.0.0/tests/test_cli.py +852 -0
  96. omni_experiments-1.0.0/tests/test_cli_commands.py +2092 -0
  97. omni_experiments-1.0.0/tests/test_client.py +717 -0
  98. omni_experiments-1.0.0/tests/test_control_match.py +77 -0
  99. omni_experiments-1.0.0/tests/test_examples.py +75 -0
  100. omni_experiments-1.0.0/tests/test_fake_api.py +1502 -0
  101. omni_experiments-1.0.0/tests/test_hosted.py +1183 -0
  102. omni_experiments-1.0.0/tests/test_hosted_control.py +426 -0
  103. omni_experiments-1.0.0/tests/test_http_invoker.py +1428 -0
  104. omni_experiments-1.0.0/tests/test_license_headers.py +44 -0
  105. omni_experiments-1.0.0/tests/test_local.py +853 -0
  106. omni_experiments-1.0.0/tests/test_local_control.py +525 -0
  107. omni_experiments-1.0.0/tests/test_lookup.py +58 -0
  108. omni_experiments-1.0.0/tests/test_model_conformance.py +283 -0
  109. omni_experiments-1.0.0/tests/test_omni_spans.py +654 -0
  110. omni_experiments-1.0.0/tests/test_permissions.py +256 -0
  111. omni_experiments-1.0.0/tests/test_rules_and_datasets.py +697 -0
  112. omni_experiments-1.0.0/tests/test_runner.py +1798 -0
  113. omni_experiments-1.0.0/tests/test_targets.py +158 -0
  114. omni_experiments-1.0.0/tests/test_terminal.py +863 -0
  115. omni_experiments-1.0.0/tests/test_trace_stats.py +803 -0
  116. omni_experiments-1.0.0/tests/test_verdict_golden.py +261 -0
  117. omni_experiments-1.0.0/tests_integ/__init__.py +2 -0
  118. omni_experiments-1.0.0/tests_integ/conftest.py +105 -0
  119. omni_experiments-1.0.0/tests_integ/test_client_side_runs.py +81 -0
  120. omni_experiments-1.0.0/tests_integ/test_hosted_runs.py +42 -0
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
18
+ steps:
19
+ - uses: actions/checkout@v5
20
+ - uses: actions/setup-python@v6
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+ - name: Install
24
+ run: pip install -e . pytest pytest-xdist
25
+ - name: Unit tests
26
+ run: python -m pytest -n auto
27
+
28
+ lint:
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - uses: actions/checkout@v5
32
+ - uses: actions/setup-python@v6
33
+ with:
34
+ python-version: "3.12"
35
+ - name: Install hatch
36
+ run: pip install hatch
37
+ - name: Format and lint
38
+ run: hatch fmt --check
@@ -0,0 +1,70 @@
1
+ name: Release
2
+
3
+ # Publishes to PyPI when a GitHub release is published (tag vX.Y.Z, matching
4
+ # src/omni_experiments/_version.py). Run it by hand to publish to TestPyPI first.
5
+ # Uses PyPI trusted publishing: no API token is stored in the repository.
6
+
7
+ on:
8
+ release:
9
+ types: [published]
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ build:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v5
20
+ - uses: actions/setup-python@v6
21
+ with:
22
+ python-version: "3.12"
23
+ - name: Check the tag matches the version
24
+ if: github.event_name == 'release'
25
+ run: |
26
+ version="$(python -c 'import re,pathlib; print(re.search(r"__version__ = \"(.+?)\"", pathlib.Path("src/omni_experiments/_version.py").read_text()).group(1))')"
27
+ test "${GITHUB_REF_NAME}" = "v${version}" || { echo "tag ${GITHUB_REF_NAME} is not v${version}"; exit 1; }
28
+ - name: Build
29
+ run: |
30
+ pip install build twine
31
+ python -m build
32
+ twine check --strict dist/*
33
+ - uses: actions/upload-artifact@v4
34
+ with:
35
+ name: dist
36
+ path: dist/
37
+
38
+ testpypi:
39
+ if: github.event_name == 'workflow_dispatch'
40
+ needs: build
41
+ runs-on: ubuntu-latest
42
+ environment:
43
+ name: testpypi
44
+ url: https://test.pypi.org/p/omni-experiments
45
+ permissions:
46
+ id-token: write
47
+ steps:
48
+ - uses: actions/download-artifact@v4
49
+ with:
50
+ name: dist
51
+ path: dist/
52
+ - uses: pypa/gh-action-pypi-publish@release/v1
53
+ with:
54
+ repository-url: https://test.pypi.org/legacy/
55
+
56
+ pypi:
57
+ if: github.event_name == 'release'
58
+ needs: build
59
+ runs-on: ubuntu-latest
60
+ environment:
61
+ name: pypi
62
+ url: https://pypi.org/p/omni-experiments
63
+ permissions:
64
+ id-token: write
65
+ steps:
66
+ - uses: actions/download-artifact@v4
67
+ with:
68
+ name: dist
69
+ path: dist/
70
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,9 @@
1
+ *.egg-info/
2
+ __pycache__/
3
+ *.pyc
4
+ .mypy_cache/
5
+ .pytest_cache/
6
+ .coverage
7
+ .hatch_venv/
8
+ .env
9
+ dist/
@@ -0,0 +1,26 @@
1
+ # Optional local hooks: `pip install pre-commit && pre-commit install --hook-type pre-commit
2
+ # --hook-type pre-push`. CI runs the same checks, so these only catch problems sooner.
3
+ repos:
4
+ - repo: local
5
+ hooks:
6
+ # On commit: format and lint (fixes what it can).
7
+ - id: hatch-fmt
8
+ name: format and lint (hatch fmt)
9
+ entry: hatch fmt
10
+ language: system
11
+ types: [python]
12
+ pass_filenames: false
13
+ stages: [pre-commit]
14
+ # On push: types and the unit tests with the coverage floor.
15
+ - id: hatch-typing
16
+ name: type check (pyrefly)
17
+ entry: hatch run typing
18
+ language: system
19
+ pass_filenames: false
20
+ stages: [pre-push]
21
+ - id: hatch-test
22
+ name: unit tests with coverage
23
+ entry: hatch test --cover
24
+ language: system
25
+ pass_filenames: false
26
+ stages: [pre-push]
@@ -0,0 +1,11 @@
1
+ # Agents
2
+
3
+ Read these before changing the package:
4
+
5
+ - [DEVELOPMENT.md](DEVELOPMENT.md): build, layout, and the rules a change must keep
6
+ - [TESTING.md](TESTING.md): unit, conformance and live tests
7
+ - [README.md](README.md): what the package does, and links to the user docs in `docs/`
8
+
9
+ Test with `hatch test` (or `python -m pytest -n auto` from a virtualenv), format and lint with
10
+ `hatch fmt`, and type check with `hatch run typing`. Don't run `tests_integ/` unless asked: it
11
+ creates experiments and costs evaluator calls.
@@ -0,0 +1,4 @@
1
+ ## Code of Conduct
2
+ This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3
+ For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4
+ opensource-codeofconduct@amazon.com with any additional questions or comments.
@@ -0,0 +1,59 @@
1
+ # Contributing Guidelines
2
+
3
+ Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4
+ documentation, we greatly value feedback and contributions from our community.
5
+
6
+ Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7
+ information to effectively respond to your bug report or contribution.
8
+
9
+
10
+ ## Reporting Bugs/Feature Requests
11
+
12
+ We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13
+
14
+ When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15
+ reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16
+
17
+ * A reproducible test case or series of steps
18
+ * The version of our code being used
19
+ * Any modifications you've made relevant to the bug
20
+ * Anything unusual about your environment or deployment
21
+
22
+
23
+ ## Contributing via Pull Requests
24
+ Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25
+
26
+ 1. You are working against the latest source on the *main* branch.
27
+ 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28
+ 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29
+
30
+ To send us a pull request, please:
31
+
32
+ 1. Fork the repository.
33
+ 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34
+ 3. Ensure local tests pass.
35
+ 4. Commit to your fork using clear commit messages.
36
+ 5. Send us a pull request, answering any default questions in the pull request interface.
37
+ 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38
+
39
+ GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40
+ [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41
+
42
+
43
+ ## Finding contributions to work on
44
+ Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
45
+
46
+
47
+ ## Code of Conduct
48
+ This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49
+ For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50
+ opensource-codeofconduct@amazon.com with any additional questions or comments.
51
+
52
+
53
+ ## Security issue notifications
54
+ If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55
+
56
+
57
+ ## Licensing
58
+
59
+ See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
@@ -0,0 +1,96 @@
1
+ # Development
2
+
3
+ Hatch for environments and tasks, Ruff for formatting and linting, Pyrefly for type checking.
4
+
5
+ ## Setup and build
6
+
7
+ Work from a virtualenv:
8
+
9
+ ```bash
10
+ python3 -m venv .venv
11
+ .venv/bin/pip install -e '.[aws,agentcore,yaml]' pytest pytest-xdist pytest-cov
12
+ .venv/bin/python -m pytest -n auto
13
+ ```
14
+
15
+ Or let Hatch manage the environments (`pip install hatch`):
16
+
17
+ | Command | Does |
18
+ |---|---|
19
+ | `hatch test` | Runs the tests |
20
+ | `hatch test --cover --parallel` | Runs tests with coverage, in parallel |
21
+ | `hatch fmt` | Formats and lints (Ruff) |
22
+ | `hatch run typing` | Type checks (Pyrefly, strict) |
23
+
24
+ CI runs the tests on Python 3.10 to 3.13 and `hatch fmt --check` on every pull request.
25
+
26
+ The build backend is plain hatchling, so `pip install` works from git or a local checkout (see
27
+ GETTING-STARTED.md).
28
+
29
+ Testing, including the live suite, is in [TESTING.md](TESTING.md).
30
+
31
+ ### Optional: pre-commit hooks
32
+
33
+ ```bash
34
+ pip install pre-commit
35
+ pre-commit install --hook-type pre-commit --hook-type pre-push
36
+ ```
37
+
38
+ On commit they format and lint. On push they type check and run the tests with the coverage floor.
39
+
40
+ ## Layout
41
+
42
+ | Path | What's there |
43
+ |---|---|
44
+ | `src/omni_experiments/cli.py` | The `experiments` command |
45
+ | `runner.py` | Client-side runs (`run_experiment`) |
46
+ | `hosted.py` | Hosted runs (`start`, `wait`) |
47
+ | `local.py`, `local_run.py`, `omni_spans.py` | Local mode (`--local`): the API on the files in `.omni`, code evaluators, JUnit, and the agent's spans from `.omni` for AgentCore evaluators |
48
+ | `verdict.py` | Case status, summary and verdict, by the service's verdict rules; used by local mode only |
49
+ | `check.py` | `experiments check` |
50
+ | `manage.py`, `lookup.py` | `get`, `list`, `stop`, `delete`, and resolving names to ids |
51
+ | `agentcore.py` | AgentCore datasets, runner and `Evaluate` |
52
+ | `http_invoker.py` | HTTP agents and their spec |
53
+ | `client.py`, `wire.py` | The real API over botocore |
54
+ | `rules.py`, `datasets.py` | Rule files (both forms, translated to case criteria and gates) and local datasets |
55
+ | `targets.py` | The experiment's target definition and each run's target, derived from `--agent-endpoint` |
56
+ | `render.py` | Text output for `get`, `list`, `start`, `wait` |
57
+ | `permissions.py` | The `hint:` lines printed for permission errors |
58
+ | `tests/golden/verdict/` | The verdict golden cases, which the service must also agree with; see its README |
59
+ | `tests/` | Unit tests. `fake_api.py` and `_scoring.py` are an in-memory fake of the API, with the service's verdict logic; test code only, not shipped |
60
+ | `tests_integ/` | Live tests against the Experiments API. Opt-in; see [TESTING.md](TESTING.md) |
61
+ | `examples/` | Rule files, HTTP agent specs, datasets, `ci-gate.sh` and `python_api.py`. `tests/test_examples.py` loads them all |
62
+ | `docs/` | User docs. `docs/examples/` has one worked example per kind of run |
63
+
64
+ botocore, boto3, the AgentCore SDK and PyYAML are regular dependencies, imported only when a
65
+ command needs them.
66
+
67
+ ## Rules to keep
68
+
69
+ - **The service decides pass or fail.** The SDK reports scores and exits with the verdict it is
70
+ given.
71
+ - **The SDK never reports results for a hosted run.** The service refuses
72
+ `PutExperimentRunResults` and `CompleteExperimentRun` on them.
73
+ - **The fake matches the real API.** A change to the API goes into `tests/fake_api.py` too. The
74
+ conformance test (`tests/test_model_conformance.py`) checks the SDK and the fake against the
75
+ botocore's own CloudWatch Omni model (`cloudwatchomni`), and runs with the unit tests. To check
76
+ another model, set `OMNI_EXPERIMENTS_MODEL_DIR` to a directory laid out for botocore
77
+ (`<dir>/cloudwatchomni/<version>/service-2.json`), read before botocore's own data:
78
+
79
+ ```bash
80
+ OMNI_EXPERIMENTS_MODEL_DIR=<dir> hatch test tests/test_model_conformance.py
81
+ ```
82
+
83
+ - **`docs/permissions.md` is referenced by name** in CLI hints (`permissions.py`). If you move it
84
+ or rename "Permissions for hosted runs" or "With an execution role", update both. A test checks
85
+ that the doc's sample `hint:` line is what the CLI prints.
86
+ - **Comments stand on their own:** don't point to documents a reader can't open. Put longer
87
+ decisions in `docs/`.
88
+ - **Examples stay runnable.** A new rule, spec or dataset feature gets a file in `examples/` and a
89
+ mention in `docs/`.
90
+ - **Credentials never appear in output.** A spec names a credential source (`ENV:`, `SIGV4:`) and
91
+ never contains the secret.
92
+
93
+ ## Dependencies
94
+
95
+ Add third-party packages to `dependencies` in `pyproject.toml`, and to
96
+ `[tool.hatch.envs.hatch-test]` if the tests need them. Keep the list short.
@@ -0,0 +1,198 @@
1
+ # Getting started
2
+
3
+ This guide takes you from setup to a scored run of your agent in about 15 minutes. For the full
4
+ reference, see [README.md](README.md).
5
+
6
+ ## Which command
7
+
8
+ | | `experiments run` | `experiments start` (hosted) |
9
+ |---|---|---|
10
+ | Who calls the agent | The SDK, from your machine or CI host | The service |
11
+ | Agent | AgentCore Runtime or any HTTPS endpoint | AgentCore Runtime only |
12
+ | What gets scored | The dataset's cases | Every session already in the agent's logs |
13
+
14
+ Start with `run`. It scores only your dataset, so you know what a run will cost.
15
+
16
+ ## Setup
17
+
18
+ 1. **Instrument your agent.** It must send OpenTelemetry/ADOT or OpenInference spans to CloudWatch,
19
+ with `session.id` set. [2. Check your setup](#2-check-your-setup) checks this for you.
20
+ 2. **Install the CLI.** Clone the repo and run its installer, as you would `aws/install` for the
21
+ AWS CLI.
22
+
23
+ ```bash
24
+ git clone https://github.com/aws-observability/cloudwatch-omni-experiments-sdk-python.git
25
+ cloudwatch-omni-experiments-sdk-python/install
26
+ experiments --version
27
+ ```
28
+
29
+ The installer puts `experiments` in `~/.local/bin` (and tells you if that isn't on your PATH)
30
+ and gives it its own Python environment in `~/.local/share/omni-experiments`, so nothing goes
31
+ into your system Python and there is no pip or venv step. It needs a Python 3.10 or newer on
32
+ the machine and finds one on PATH or in a mise, uv, pyenv or Homebrew install. Without one,
33
+ get it first: `mise use -g python@3.12`, `brew install python@3.12` on a Mac (which ships
34
+ 3.9), or `uv python install 3.12`.
35
+
36
+ - **Update:**
37
+ `git -C cloudwatch-omni-experiments-sdk-python pull && cloudwatch-omni-experiments-sdk-python/install`.
38
+ The old install keeps working until the new one is ready.
39
+ - **Uninstall:** `cloudwatch-omni-experiments-sdk-python/install --uninstall`.
40
+ - **Elsewhere:** `--bin-dir DIR` and `--install-dir DIR` (for example
41
+ `sudo cloudwatch-omni-experiments-sdk-python/install --bin-dir /usr/local/bin --install-dir /opt/omni-experiments`
42
+ for every user on a CI host), `--python PATH` to pick the interpreter.
43
+ - **The Python package** (`import omni_experiments`, for the Python API): install it into
44
+ your own environment instead, with
45
+ `pip install "omni-experiments @ git+https://github.com/aws-observability/cloudwatch-omni-experiments-sdk-python.git"`.
46
+
47
+ 3. **Set your credentials.** They come from the usual AWS chain, so a profile is enough:
48
+
49
+ ```bash
50
+ export AWS_PROFILE=<profile for your account>
51
+ ```
52
+
53
+ The API model comes with botocore, which pip installs with the package. You don't need `--endpoint-url` or `--api-model-dir`.
54
+
55
+ 4. **Create an execution role.** Creating an experiment needs an IAM role in your account that the
56
+ service assumes for the experiment. Create it once, with the trust and permissions policies in
57
+ [Permissions](docs/permissions.md#with-an-execution-role), and pass it as
58
+ `--execution-role-arn` to the run that creates the experiment.
59
+
60
+ ## 1. Write a rule
61
+
62
+ Save this as `rule.json`, or use [examples/rules/pr.json](examples/rules/pr.json). See
63
+ [docs/rules.md](docs/rules.md) for every field.
64
+
65
+ ```json
66
+ {
67
+ "name": "pr",
68
+ "minPassRate": 0.9,
69
+ "evaluators": [{"evaluatorId": "Builtin.Helpfulness", "minScore": 0.7}]
70
+ }
71
+ ```
72
+
73
+ ## 2. Check your setup
74
+
75
+ Don't know your runtime ARN or dataset id? `experiments agentcore-runtimes list` and
76
+ `experiments agentcore-datasets list` show them, and `get` on one prints the exact
77
+ `--agent-endpoint`, `--service-name` and `--dataset` to pass. `experiments agentcore-evaluators
78
+ list` shows the evaluators a rule can name. See [AgentCore resources](docs/agentcore-resources.md).
79
+
80
+ `experiments check` is read-only. It checks your credentials, the API, the agent and the dataset,
81
+ and finds the `service.name` your agent's spans carry:
82
+
83
+ ```bash
84
+ experiments check \
85
+ --agent-endpoint arn:aws:bedrock-agentcore:us-east-1:<account>:runtime/<runtimeId> \
86
+ --dataset agentcore:<datasetId>@<version>
87
+ ```
88
+
89
+ ```text
90
+ ok credentials arn:aws:sts::<account>:assumed-role/<role>/<you>
91
+ ok Experiments API https://cloudwatch-omni.us-east-1.api.aws answered
92
+ ok agent <runtimeId> is READY
93
+ ok dataset <name>, version 1
94
+ ok scoring Builtin.Helpfulness bedrock-agentcore:GetEvaluator and Evaluate are allowed
95
+ note spans --service-name not given; spans in aws/spans in the last 7 days that match the runtime: <runtime>.DEFAULT (45 sessions)
96
+ ready
97
+
98
+ next, with your rule file:
99
+
100
+ experiments run \
101
+ --dataset agentcore:<datasetId>@1 \
102
+ --agent-endpoint arn:aws:bedrock-agentcore:us-east-1:<account>:runtime/<runtimeId> \
103
+ --service-name <runtime>.DEFAULT --environment <environment> \
104
+ --rule <rule.json> \
105
+ --execution-role-arn <role-arn>
106
+ ```
107
+
108
+ When everything is in place, `check` prints the `run` command for step 3 with your values filled
109
+ in; replace `<environment>`, `<rule.json>` and `<role-arn>` with yours. The `spans` line names the agent's `service.name`, which is often the runtime's name plus
110
+ `.DEFAULT`, not the runtime's name itself. If a line says `FAIL`, its `->` line says what to do.
111
+
112
+ ## 3. First run
113
+
114
+ ```bash
115
+ experiments run \
116
+ --dataset agentcore:<datasetId>@<version> \
117
+ --agent-endpoint arn:aws:bedrock-agentcore:us-east-1:<account>:runtime/<runtimeId> \
118
+ --service-name <service.name> --environment prod \
119
+ --rule rule.json \
120
+ --execution-role-arn arn:aws:iam::<account>:role/experiments-role
121
+ ```
122
+
123
+ Paste the command `check` printed, with your rule file and role. A run takes about 4 minutes, mostly a
124
+ 3-minute wait for the agent's spans to reach CloudWatch. It shows where it is while it waits:
125
+
126
+ ```text
127
+ [agentcore] calling the agent: 4/4 turns answered
128
+ [agentcore] 4/4 turns answered; waiting for the agent's spans to reach CloudWatch (2:27 left)
129
+ [agentcore] collecting the spans and scoring them with AgentCore Evaluate
130
+ FAILED: pass rate 67% (required 90%)
131
+ experiment exp-... run sdk-...
132
+ cases to look at:
133
+ - two-turn-recipe: FAILED
134
+ ```
135
+
136
+ It exits `0` if passed, `1` if failed, `2` if it didn't finish, and `3` on a setup error. To look
137
+ closer:
138
+
139
+ ```bash
140
+ experiments get <experiment> <runId> # verdict, case counts, per-evaluator scores
141
+ experiments list # your experiments
142
+ experiments update <experiment> --name N # rename (or change the description or configuration)
143
+ experiments delete-run <experimentId> <runId> # delete an ended run and its results
144
+ ```
145
+
146
+ For an agent behind HTTPS, see [HTTP agent](docs/examples/http-agent.md). To compare two versions
147
+ of your agent, see [A/B comparison](docs/examples/ab-comparison.md).
148
+
149
+ ## 4. Hosted runs
150
+
151
+ ```bash
152
+ experiments start --experiment my-agent-release \
153
+ --agent-endpoint <runtime ARN> --dataset agentcore:<datasetId>@<version> \
154
+ --service-name <service.name> --environment prod \
155
+ --trace-log-group aws/spans \
156
+ --trace-log-group /aws/bedrock-agentcore/runtimes/<runtimeId>-DEFAULT \
157
+ --execution-role-arn arn:aws:iam::<account>:role/experiments-role \
158
+ --rule rule.json --wait
159
+ ```
160
+
161
+ Every `start` names its dataset and a published version of it
162
+ (`--dataset agentcore:<datasetId>@<version>`; without a version it is exit 3), so later runs of the
163
+ same experiment can test another dataset or version. A hosted
164
+ run scores every session in the trace log groups, not just your dataset. The `spans` line
165
+ of `experiments check --service-name <service.name>` shows how many that is. See
166
+ [Hosted runs](docs/hosted-runs.md) before your first one.
167
+
168
+ ## Troubleshooting
169
+
170
+ | You see | Cause | Fix |
171
+ |---|---|---|
172
+ | `install: needs Python 3.10 or newer` | Only an older Python on the machine | `mise use -g python@3.12`, `brew install python@3.12` (Mac) or `uv python install 3.12`, then run `install` again |
173
+ | `experiments: command not found` after installing | `~/.local/bin` isn't on your PATH | Add `export PATH="$HOME/.local/bin:$PATH"` to `~/.zshrc` or `~/.bashrc` |
174
+ | `credentials` fails in `check` | Expired or missing credentials | Refresh them, or pass `--profile` |
175
+ | Every case `SPANS_MISSING` | The agent isn't instrumented, or its spans lack `session.id` | `experiments check` shows what spans exist |
176
+ | `spans` fails in `check` with "use one of" | Wrong `--service-name` | Use the name it suggests |
177
+ | `NOT_SCORED (SCORING_THROTTLED)` | AgentCore throttled the scoring | Run again, or lower `--concurrency` |
178
+ | Cases `TIMED_OUT` | A turn took longer than the limit (300 s for Runtime, 60 s for HTTP) | Raise `--turn-timeout-seconds` |
179
+ | `AccessDeniedException` | A missing permission | The `hint:` line names it; see [docs/permissions.md](docs/permissions.md) |
180
+ | Exit 3 on an existing experiment | The agent differs from the experiment's (another dataset is fine) | Use a new `--experiment` name |
181
+ | `creating it needs an execution role` | The run creates the experiment, and `--execution-role-arn` is missing | Pass the role from setup step 4 |
182
+ | `TARGET_RUNTIME_NOT_FOUND` | The runtime ARN isn't a runtime in your account and Region | Check the ARN, the account and `--region` |
183
+
184
+ ## Setting it up with a coding agent
185
+
186
+ This guide works as instructions for a coding agent (Claude Code, Kiro, Amazon Q Developer). Tell it:
187
+
188
+ - Install as in setup step 2.
189
+ - Stop and ask you for anything interactive: AWS credentials and installing a newer Python.
190
+ - Run `experiments check` before any run, and fix every `FAIL` line first.
191
+ - Start with `experiments run`. Ask before a hosted run (`experiments start`): it scores every
192
+ session in the agent's logs, not just the dataset.
193
+
194
+ ## Next
195
+
196
+ - [Examples](docs/examples/README.md): one worked example per kind of run.
197
+ - [Client-side runs](docs/client-side-runs.md): what a run does, step by step, and how scores
198
+ become a verdict.