intent-classify 0.2.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.
- intent_classify-0.2.0/CHANGELOG.md +64 -0
- intent_classify-0.2.0/CONTRIBUTING.md +112 -0
- intent_classify-0.2.0/LICENSE +202 -0
- intent_classify-0.2.0/MANIFEST.in +11 -0
- intent_classify-0.2.0/NOTICE +4 -0
- intent_classify-0.2.0/PKG-INFO +205 -0
- intent_classify-0.2.0/README.md +158 -0
- intent_classify-0.2.0/evals/datasets/README.md +59 -0
- intent_classify-0.2.0/evals/datasets/shopease_guardrails.jsonl +27 -0
- intent_classify-0.2.0/evals/datasets/shopease_intents.jsonl +70 -0
- intent_classify-0.2.0/evals/datasets/shopease_multilingual.jsonl +18 -0
- intent_classify-0.2.0/evals/datasets/shopease_multiturn.jsonl +32 -0
- intent_classify-0.2.0/evals/datasets/shopease_planning.jsonl +27 -0
- intent_classify-0.2.0/evals/datasets/shopease_synthetic.jsonl +240 -0
- intent_classify-0.2.0/evals/gates.yaml +23 -0
- intent_classify-0.2.0/projects/shopease.yaml +317 -0
- intent_classify-0.2.0/pyproject.toml +66 -0
- intent_classify-0.2.0/setup.cfg +4 -0
- intent_classify-0.2.0/src/intent_classify/__init__.py +70 -0
- intent_classify-0.2.0/src/intent_classify/__main__.py +3 -0
- intent_classify-0.2.0/src/intent_classify/_env.py +30 -0
- intent_classify-0.2.0/src/intent_classify/_version.py +3 -0
- intent_classify-0.2.0/src/intent_classify/backends/__init__.py +53 -0
- intent_classify-0.2.0/src/intent_classify/backends/anthropic_backend.py +100 -0
- intent_classify-0.2.0/src/intent_classify/backends/base.py +50 -0
- intent_classify-0.2.0/src/intent_classify/backends/embeddings.py +78 -0
- intent_classify-0.2.0/src/intent_classify/backends/openai_backend.py +66 -0
- intent_classify-0.2.0/src/intent_classify/builtin/guardrails.yaml +151 -0
- intent_classify-0.2.0/src/intent_classify/builtin/universal.yaml +75 -0
- intent_classify-0.2.0/src/intent_classify/cli.py +281 -0
- intent_classify-0.2.0/src/intent_classify/evals/__init__.py +23 -0
- intent_classify-0.2.0/src/intent_classify/evals/data/core_guardrails.jsonl +37 -0
- intent_classify-0.2.0/src/intent_classify/evals/data/core_universal.jsonl +38 -0
- intent_classify-0.2.0/src/intent_classify/evals/dataset.py +113 -0
- intent_classify-0.2.0/src/intent_classify/evals/gate.py +34 -0
- intent_classify-0.2.0/src/intent_classify/evals/generate.py +237 -0
- intent_classify-0.2.0/src/intent_classify/evals/leakage.py +22 -0
- intent_classify-0.2.0/src/intent_classify/evals/metrics.py +274 -0
- intent_classify-0.2.0/src/intent_classify/evals/public.py +123 -0
- intent_classify-0.2.0/src/intent_classify/evals/report.py +179 -0
- intent_classify-0.2.0/src/intent_classify/evals/runner.py +69 -0
- intent_classify-0.2.0/src/intent_classify/evals/systems.py +112 -0
- intent_classify-0.2.0/src/intent_classify/normalize.py +30 -0
- intent_classify-0.2.0/src/intent_classify/pipeline.py +247 -0
- intent_classify-0.2.0/src/intent_classify/planner.py +251 -0
- intent_classify-0.2.0/src/intent_classify/py.typed +0 -0
- intent_classify-0.2.0/src/intent_classify/stages/__init__.py +0 -0
- intent_classify-0.2.0/src/intent_classify/stages/embedding.py +55 -0
- intent_classify-0.2.0/src/intent_classify/stages/llm.py +207 -0
- intent_classify-0.2.0/src/intent_classify/stages/rules.py +113 -0
- intent_classify-0.2.0/src/intent_classify/taxonomy.py +336 -0
- intent_classify-0.2.0/src/intent_classify/types.py +145 -0
- intent_classify-0.2.0/src/intent_classify.egg-info/PKG-INFO +205 -0
- intent_classify-0.2.0/src/intent_classify.egg-info/SOURCES.txt +62 -0
- intent_classify-0.2.0/src/intent_classify.egg-info/dependency_links.txt +1 -0
- intent_classify-0.2.0/src/intent_classify.egg-info/entry_points.txt +3 -0
- intent_classify-0.2.0/src/intent_classify.egg-info/requires.txt +23 -0
- intent_classify-0.2.0/src/intent_classify.egg-info/top_level.txt +1 -0
- intent_classify-0.2.0/tests/conftest.py +52 -0
- intent_classify-0.2.0/tests/test_data_tools.py +94 -0
- intent_classify-0.2.0/tests/test_evals.py +64 -0
- intent_classify-0.2.0/tests/test_pipeline.py +128 -0
- intent_classify-0.2.0/tests/test_planner.py +246 -0
- intent_classify-0.2.0/tests/test_taxonomy_and_rules.py +90 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `intent-classify`. Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
|
+
|
|
5
|
+
## Versioning policy
|
|
6
|
+
|
|
7
|
+
There are two public contracts: the **result object** (`ClassificationResult` and everything it
|
|
8
|
+
contains) and the **project YAML schema**. Versions follow [SemVer](https://semver.org/):
|
|
9
|
+
|
|
10
|
+
| Change | Bump |
|
|
11
|
+
|---|---|
|
|
12
|
+
| A field is renamed or removed in the result, or a YAML file that used to load stops loading | **major** |
|
|
13
|
+
| New result fields, new YAML keys, new CLI commands or metrics | **minor** |
|
|
14
|
+
| Bug fixes and prompt wording that doesn't change behaviour | **patch** |
|
|
15
|
+
| **Shared guardrails or universal intents change** (labels, patterns, actions, examples) | at least **minor**, plus a bump of `CORE_VERSION` in `taxonomy.py` and a core-suite eval in the release notes |
|
|
16
|
+
|
|
17
|
+
The shared guardrails count as behaviour, not data: changing them can alter what every user's
|
|
18
|
+
assistant blocks. `ClassificationResult.taxonomy_version` records the `CORE_VERSION` that produced a result.
|
|
19
|
+
|
|
20
|
+
Before 1.0.0, minor versions may still contain breaking changes. Each one is called out under **Breaking**.
|
|
21
|
+
|
|
22
|
+
## [0.2.0] - 2026-12-03
|
|
23
|
+
|
|
24
|
+
First public release.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- **Slots and query planning.** A project can declare `slots`, `tools`, `retrievers` and per-intent
|
|
28
|
+
`plan` templates in its YAML. Results then carry validated `slots` and a `plan`
|
|
29
|
+
(tool / retrieve / reply / ask_user steps with `depends_on`, `for_each` sub-query fan-out,
|
|
30
|
+
`when`/`unless`, confirmation for side-effecting tools). Plans are deterministic. Nothing is planned
|
|
31
|
+
when guardrails block or escalate. Identifier slots must appear in the conversation, so values the
|
|
32
|
+
LLM invents are dropped. New public types: `Plan`, `PlanStep`, `SlotValue`, `Planner`, `SlotDef`,
|
|
33
|
+
`ToolDef`, `RetrieverDef`, `PlanStepDef`.
|
|
34
|
+
- **Planning evals:** `expected_slots` / `expected_plan` in datasets, and the metrics slot F1, context
|
|
35
|
+
slot accuracy, plan match, clarify accuracy and unsafe-plan rate (with a CI gate).
|
|
36
|
+
- **Core eval suites ship with the package** (`intent_classify/evals/data/`). `intent-classify eval`
|
|
37
|
+
always includes them (`--no-core` skips them), adapted to your taxonomy: an intent you don't
|
|
38
|
+
have isn't scored, and a guardrail you disabled is skipped.
|
|
39
|
+
- `ic` CLI alias. `intent_classify.__version__`. `py.typed` marker.
|
|
40
|
+
- GitHub Actions: `ci.yml` (tests on Python 3.10–3.13 + Windows, offline eval smoke, build and clean-install check) on
|
|
41
|
+
every PR; `live-eval.yml` (real model + regression gate), started manually.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
- **Breaking:** `ClassifierConfig.plan` defaults to on when a project declares plans. The embedding fast path is
|
|
45
|
+
skipped for intents whose required slots only the LLM can extract.
|
|
46
|
+
- **Breaking:** `intent-classify eval --datasets` is optional. Local files named `core_guardrails.jsonl` /
|
|
47
|
+
`core_universal.jsonl` are ignored in favour of the packaged suites.
|
|
48
|
+
- Domain-dependent cases (off-topic and scary-but-benign shopping messages) moved out of the core suite into the
|
|
49
|
+
example project's `shopease_guardrails.jsonl`. Every project should write its own.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
- The package failed to import on Python 3.10 and 3.11 (`SyntaxError` from a backslash inside an f-string
|
|
53
|
+
expression, which only Python 3.12+ accepts), despite declaring `requires-python >= 3.10`. Found by the new CI matrix.
|
|
54
|
+
- An attack the assistant had already declined no longer causes the user's next, harmless reply to be blocked
|
|
55
|
+
(e.g. "yes go ahead" accepting the safe alternative). The LLM prompt has a narrowly scoped exception: such a reply
|
|
56
|
+
is not flagged for the earlier attempt unless it repeats, continues or builds on it. A/B on `gpt-5.4-mini`: benign
|
|
57
|
+
replies not blocked 74/80 → 60/60; multi-turn attacks caught 24/24 → 24/24; jailbreak labelling unchanged (11/15,
|
|
58
|
+
all stopped). A broader first wording ("flag only if…") reduced co-occurring labels and was rejected.
|
|
59
|
+
|
|
60
|
+
## [0.1.0]
|
|
61
|
+
|
|
62
|
+
Initial version: shared guardrails and universal intents, YAML project intents, rules → embeddings →
|
|
63
|
+
LLM cascade, conversation history, Anthropic/OpenAI backends, eval harness with system comparison,
|
|
64
|
+
HTML report, CI gate, leakage check, public benchmark loaders, synthetic case generation and review.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Contributing to intent-classify
|
|
2
|
+
|
|
3
|
+
Thanks for helping. This library decides what an assistant blocks and what it does, so we hold
|
|
4
|
+
changes to one rule: **a behaviour change has to come with evidence**. Usually that means a test,
|
|
5
|
+
an eval case, and before/after numbers.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
python -m venv .venv
|
|
11
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
12
|
+
pip install -e ".[dev]"
|
|
13
|
+
pytest # ~2 s, no API key needed
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The tests use a fake LLM and the offline `hashing` embedder, so they never call a provider.
|
|
17
|
+
Live evals need `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`, either in your environment or in a local `.env`
|
|
18
|
+
(that file is git-ignored; never commit it).
|
|
19
|
+
|
|
20
|
+
## Where things live
|
|
21
|
+
|
|
22
|
+
| Path | What |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `src/intent_classify/types.py` | The result object. **Public contract.** |
|
|
25
|
+
| `src/intent_classify/taxonomy.py` | Project YAML schema and loading. **Public contract.** |
|
|
26
|
+
| `src/intent_classify/builtin/` | Built-in guardrails and universal intents (shared by every user) |
|
|
27
|
+
| `src/intent_classify/pipeline.py`, `stages/`, `planner.py` | The cascade: rules → embeddings → LLM → policy → plan |
|
|
28
|
+
| `src/intent_classify/backends/` | LLM and embedding providers |
|
|
29
|
+
| `src/intent_classify/evals/` | Eval harness; `evals/data/` holds the core suites that ship with the package |
|
|
30
|
+
| `projects/shopease.yaml`, `evals/datasets/` | The example project and its eval suites |
|
|
31
|
+
|
|
32
|
+
## Kinds of change and what they need
|
|
33
|
+
|
|
34
|
+
**Bug fix or refactor.** Add a test that fails before the fix. `pytest` must pass.
|
|
35
|
+
|
|
36
|
+
**New feature.** Add tests, plus an eval slice if it changes what gets classified or planned: new
|
|
37
|
+
dataset fields, a metric in `evals/metrics.py`, and a row in `docs/EVALS.md`. A feature without a
|
|
38
|
+
way to measure it won't be merged.
|
|
39
|
+
|
|
40
|
+
**Prompt or cascade changes** (`stages/llm.py`, `pipeline.py` thresholds, fast-path rules). Run the
|
|
41
|
+
live comparison before and after on the same model, and paste the headline table into the PR:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
ic eval --project projects/shopease.yaml --datasets "evals/datasets/*.jsonl" \
|
|
45
|
+
--systems zero_shot,full_no_history,full --llm openai:gpt-5.4-mini --effort low
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Differences under ~5 points on slices with fewer than ~30 cases are noise. Say so instead of claiming a win.
|
|
49
|
+
|
|
50
|
+
**Built-in guardrails or universal intents** (`builtin/*.yaml`). These change behaviour for every user, so:
|
|
51
|
+
- read the guardrail section of the versioning policy in [CHANGELOG.md](CHANGELOG.md) first (they need a `CORE_VERSION` bump);
|
|
52
|
+
- add cases to `src/intent_classify/evals/data/core_*.jsonl`, both attacks that should be caught **and** benign look-alikes that must not be blocked;
|
|
53
|
+
- report guardrail recall **together with** benign false-block rate. One without the other means nothing;
|
|
54
|
+
- keep regex `patterns` strict. A rule hit can skip the LLM, and the LLM can only veto heuristic hits when it runs.
|
|
55
|
+
|
|
56
|
+
**New provider backend.** Implement `LLMBackend` / `EmbeddingBackend` in `backends/` (see `base.py`),
|
|
57
|
+
register it in `backends/__init__.py`, and add it as an optional extra in `pyproject.toml`.
|
|
58
|
+
Structured output must enforce the JSON schema. Provider refusals must come back as `refusal`, not as an exception.
|
|
59
|
+
|
|
60
|
+
## Eval data rules
|
|
61
|
+
|
|
62
|
+
- **Never commit real user conversations, personal data or secrets**, even in tests. Every case here is synthetic.
|
|
63
|
+
- **Core suites** (`src/intent_classify/evals/data/`) must work for any domain. Only use built-in
|
|
64
|
+
labels there. Cases that depend on the domain (off-topic, scary-but-benign) belong in a project suite.
|
|
65
|
+
- **No leakage.** Eval messages must not copy taxonomy examples:
|
|
66
|
+
`ic check-leakage --project projects/shopease.yaml --datasets "evals/datasets/*.jsonl"`.
|
|
67
|
+
- LLM-generated cases (`ic generate`) are reviewed by a person before `ic promote`.
|
|
68
|
+
- Mark genuinely ambiguous cases with `acceptable_intents` rather than picking one label and fitting the model to it.
|
|
69
|
+
- Don't edit a case just to make your change pass. If a label is wrong, fix it in a separate commit and explain why.
|
|
70
|
+
|
|
71
|
+
## Style
|
|
72
|
+
|
|
73
|
+
- Python 3.10+, type hints on public functions, `from __future__ import annotations`.
|
|
74
|
+
- Keep the core dependencies at three (`pydantic`, `pyyaml`, `numpy`). Anything else goes behind an optional extra.
|
|
75
|
+
- Fail at load time, not at runtime: validate YAML in `taxonomy.py` with a clear error message.
|
|
76
|
+
- New result fields need defaults. Never rename or remove a field without a major version bump.
|
|
77
|
+
|
|
78
|
+
## Continuous integration
|
|
79
|
+
|
|
80
|
+
Every pull request runs [`.github/workflows/ci.yml`](.github/workflows/ci.yml). It needs no API key:
|
|
81
|
+
|
|
82
|
+
- **tests** on Python 3.10–3.13 (Linux) and 3.12 (Windows);
|
|
83
|
+
- **offline eval smoke**: the datasets load and an eval runs end to end with rules and embeddings only;
|
|
84
|
+
- **package**: build, `twine check`, then install the wheel in a fresh virtualenv and use it.
|
|
85
|
+
|
|
86
|
+
The **live eval** ([`.github/workflows/live-eval.yml`](.github/workflows/live-eval.yml)) calls a real model and
|
|
87
|
+
applies `evals/gates.yaml`. It only runs when a maintainer starts it from the Actions tab (repo secrets
|
|
88
|
+
`OPENAI_API_KEY` / `ANTHROPIC_API_KEY`). Maintainers run it before merging prompt, cascade, guardrail or planner changes.
|
|
89
|
+
|
|
90
|
+
## Pull request checklist
|
|
91
|
+
|
|
92
|
+
- [ ] `pytest` passes
|
|
93
|
+
- [ ] Tests (and eval cases, for behaviour changes) added
|
|
94
|
+
- [ ] Before/after eval table in the PR description, for prompt, cascade, guardrail or planner changes
|
|
95
|
+
- [ ] `CHANGELOG.md` updated under the unreleased version
|
|
96
|
+
- [ ] Docs updated (`README.md`, `docs/EVALS.md`, `evals/datasets/README.md`) if behaviour or the YAML schema changed
|
|
97
|
+
|
|
98
|
+
## Reporting a guardrail bypass
|
|
99
|
+
|
|
100
|
+
Don't post working bypasses (jailbreaks, injections that get past the guardrails) in a public issue.
|
|
101
|
+
Report them privately to the maintainer first, so a fix and a regression case can ship together.
|
|
102
|
+
|
|
103
|
+
## Releasing (maintainers)
|
|
104
|
+
|
|
105
|
+
1. Bump `src/intent_classify/_version.py` and move the `CHANGELOG.md` entries under that version.
|
|
106
|
+
2. `python scripts/release_check.py --results evals/results/<live-run>.json` runs the tests, builds,
|
|
107
|
+
runs `twine check`, smoke-tests the wheel in a clean virtualenv, and applies the eval gate.
|
|
108
|
+
3. `python -m twine upload dist/*`
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
By contributing, you agree that your contributions are licensed under the [Apache License 2.0](LICENSE).
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Extra files for the source distribution, so `pytest` works from an unpacked sdist.
|
|
2
|
+
include CHANGELOG.md CONTRIBUTING.md
|
|
3
|
+
recursive-include tests *.py
|
|
4
|
+
include projects/shopease.yaml
|
|
5
|
+
include evals/datasets/*.jsonl evals/datasets/README.md
|
|
6
|
+
include evals/gates.yaml
|
|
7
|
+
# Never ship: local run outputs, unreviewed candidates, third-party benchmark copies, secrets.
|
|
8
|
+
prune evals/results
|
|
9
|
+
prune evals/candidates
|
|
10
|
+
prune evals/datasets/public
|
|
11
|
+
exclude .env
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: intent-classify
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Conversation-aware intent classification, guardrails and query planning for LLM assistants. Intents in YAML, evals built in.
|
|
5
|
+
Author: Shubhankar Saket
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Shubhankar-saket/Intent-classifier-sdk
|
|
8
|
+
Project-URL: Repository, https://github.com/Shubhankar-saket/Intent-classifier-sdk
|
|
9
|
+
Project-URL: Issues, https://github.com/Shubhankar-saket/Intent-classifier-sdk/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/Shubhankar-saket/Intent-classifier-sdk/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: intent-classification,guardrails,prompt-injection,llm,chatbot,query-planning,slot-filling,evaluation,anthropic,openai
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
License-File: NOTICE
|
|
28
|
+
Requires-Dist: pydantic>=2.6
|
|
29
|
+
Requires-Dist: pyyaml>=6
|
|
30
|
+
Requires-Dist: numpy>=1.26
|
|
31
|
+
Provides-Extra: anthropic
|
|
32
|
+
Requires-Dist: anthropic<2,>=1; extra == "anthropic"
|
|
33
|
+
Provides-Extra: openai
|
|
34
|
+
Requires-Dist: openai>=1.40; extra == "openai"
|
|
35
|
+
Provides-Extra: local-embeddings
|
|
36
|
+
Requires-Dist: sentence-transformers>=3; extra == "local-embeddings"
|
|
37
|
+
Provides-Extra: all
|
|
38
|
+
Requires-Dist: anthropic<2,>=1; extra == "all"
|
|
39
|
+
Requires-Dist: openai>=1.40; extra == "all"
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
42
|
+
Requires-Dist: anthropic<2,>=1; extra == "dev"
|
|
43
|
+
Requires-Dist: openai>=1.40; extra == "dev"
|
|
44
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
45
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
# intent-classify
|
|
49
|
+
|
|
50
|
+
[](https://github.com/Shubhankar-saket/Intent-classifier-sdk/actions/workflows/ci.yml)
|
|
51
|
+
|
|
52
|
+
Intent classification, guardrails and query planning for LLM assistants and chatbots.
|
|
53
|
+
|
|
54
|
+
- **Guardrails and common conversational intents are built in**: prompt injection, jailbreaks, PII, off-topic, greetings, human handoff and more. You add only your own intents, in a YAML file.
|
|
55
|
+
- **Conversation-aware.** "yes", "the second one" and "cancel it" are resolved from the last N turns, and so are attacks spread across several turns.
|
|
56
|
+
- **Plans, not just labels (optional).** Validated slots plus ordered tool-call and retrieval steps for your executor.
|
|
57
|
+
- **Evals are built in.** One command compares the cascade against a zero-shot baseline on accuracy, safety, cost and latency.
|
|
58
|
+
- **Works with any provider.** Anthropic, OpenAI and anything OpenAI-compatible (Azure, vLLM, Ollama).
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install "intent-classify[anthropic]" # or [openai], or [all]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
user message + last N turns
|
|
66
|
+
│
|
|
67
|
+
├─ L0 normalise unicode folding, invisible-char stripping, history window
|
|
68
|
+
├─ L1 guardrails (shared) injection · jailbreak · prompt extraction · harmful · exfiltration
|
|
69
|
+
│ self-harm · toxicity · PII · off-topic → allow/flag/escalate/block
|
|
70
|
+
├─ L2 universal (shared) greeting · goodbye · thanks · small talk · human handoff · complaint
|
|
71
|
+
│ feedback · affirm · deny · capabilities · clarification · gibberish
|
|
72
|
+
├─ L3 project intents from projects/<name>.yaml
|
|
73
|
+
└─ L4 slots + plan (optional) validated slots -> tool / retrieval / ask_user steps
|
|
74
|
+
▼
|
|
75
|
+
ClassificationResult { guardrail.action, flags[], intents[] (primary first), slots, plan, language, usage, ... }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## How a message is classified (cheapest first)
|
|
79
|
+
|
|
80
|
+
1. **Rules.** Free and deterministic:
|
|
81
|
+
- Strict regexes catch obvious injection or jailbreak attempts. These are *heuristic*: the LLM can veto them.
|
|
82
|
+
- Validated detectors catch PII, e.g. Luhn-checked card numbers, SSN, PAN, and disclosed passwords or OTPs. These are *deterministic* and always kept.
|
|
83
|
+
- Exact matches handle one-liners like "hi" or "thanks".
|
|
84
|
+
2. **Embeddings.** Nearest neighbour against the intent examples. If the match is clear, nothing looks risky, and the message doesn't depend on context, we answer without an LLM.
|
|
85
|
+
3. **LLM.** Gets a structured-output prompt generated from the taxonomy (cached per project) plus the last N turns. It resolves context ("yes" → `order.cancel`) and catches multi-turn attacks.
|
|
86
|
+
4. **Policy.** The guardrail action is the most severe flag at or above the threshold. Below `abstain_threshold`, the primary intent becomes `unknown`.
|
|
87
|
+
|
|
88
|
+
Providers are swappable: `anthropic[:model]`, `openai:<model>` (which also covers Azure, vLLM and Ollama via `base_url`), and embedders `hashing` (offline), `openai`, or `st` (local multilingual sentence-transformers).
|
|
89
|
+
|
|
90
|
+
## Slots and planning (classifier + query planner)
|
|
91
|
+
|
|
92
|
+
Optional, per project. When the YAML declares `slots`, `tools`, `retrievers` and per-intent
|
|
93
|
+
`plan` templates, every result also carries validated `slots` and a `plan`: an ordered list of
|
|
94
|
+
tool calls, retrieval queries, canned replies or clarifying questions. **The library plans; your
|
|
95
|
+
executor runs the steps.**
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
slots:
|
|
99
|
+
order_id: {type: string, pattern: "[0-9]{4,6}", ask: "Which order is this about?"}
|
|
100
|
+
products: {type: list, description: Product names or models mentioned}
|
|
101
|
+
tools:
|
|
102
|
+
orders.get: {required_args: [order_id]}
|
|
103
|
+
orders.cancel: {required_args: [order_id], side_effect: true} # -> requires_confirmation
|
|
104
|
+
retrievers:
|
|
105
|
+
catalog: {description: Product catalogue}
|
|
106
|
+
intents:
|
|
107
|
+
- name: order.cancel
|
|
108
|
+
slots: {order_id: required, items: optional}
|
|
109
|
+
plan:
|
|
110
|
+
- {id: lookup, tool: orders.get, args: {order_id: $order_id}}
|
|
111
|
+
- {id: cancel, tool: orders.cancel, args: {order_id: $order_id, items: $items}, depends_on: [lookup]}
|
|
112
|
+
- name: product.info
|
|
113
|
+
slots: {products: required, aspect: optional}
|
|
114
|
+
plan:
|
|
115
|
+
- {retrieve: catalog, for_each: products, query: "{item} {aspect}"} # one sub-query per product
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
r = clf.classify("yes", history=[...cancel order 5512... Shall I cancel it?])
|
|
120
|
+
r.slots["order_id"] # SlotValue(value="5512", source="history", extractor="llm")
|
|
121
|
+
r.plan.status # "ready" (or "needs_input" | "blocked" | "no_plan")
|
|
122
|
+
[s.signature for s in r.plan.steps] # ["tool:orders.get", "tool:orders.cancel"]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
How it works:
|
|
126
|
+
- **Slots come from the same LLM call** as the intents. The schema and prompt only grow when a project declares slots. Identifier slots (those with a `pattern`) are also pulled out by regex, so the fast path and offline mode still get them. A plan that needs a slot only the LLM can extract skips the fast path.
|
|
127
|
+
- **Values are validated, never trusted.** Each value is checked for type, pattern, enum and length. Identifier slots must also appear verbatim in the conversation, so an order number the LLM invents is dropped. Dropped values are listed in `plan.notes`.
|
|
128
|
+
- **Planning is deterministic.** Templates are filled from slots. `$slot` gives the raw value, `"{slot} text"` interpolates it, `for_each` fans one step out into parallel sub-queries, and `when`/`unless` pick steps based on which slots are present. Every confident intent gets planned, so a multi-intent message yields one combined plan.
|
|
129
|
+
- **Missing required slot:** the plan contains a single `ask_user` step with the slot's question, instead of guessing.
|
|
130
|
+
- **Guardrails come first.** A `block` or `escalate` result gets `status: blocked` and no steps. An abstained (`unknown`) intent gets `no_plan`.
|
|
131
|
+
- **Every reference is checked when the YAML loads:** tools, retrievers, slots, `depends_on`, and the tools' required args.
|
|
132
|
+
|
|
133
|
+
Not yet built: an LLM planner for open-ended requests that no template covers (step 3 in [docs/PLAN.md](https://github.com/Shubhankar-saket/Intent-classifier-sdk/blob/main/docs/PLAN.md)).
|
|
134
|
+
|
|
135
|
+
## Quick start
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
import intent_classify as ic
|
|
139
|
+
|
|
140
|
+
clf = ic.IntentClassifier.from_project("projects/shopease.yaml", llm="anthropic", embedder="hashing")
|
|
141
|
+
r = clf.classify("yes", history=[
|
|
142
|
+
{"role": "user", "content": "I'd like to cancel order 5512"},
|
|
143
|
+
{"role": "assistant", "content": "It hasn't shipped yet. Shall I cancel it?"},
|
|
144
|
+
])
|
|
145
|
+
r.guardrail.action # Action.ALLOW
|
|
146
|
+
r.top_intent.name # "order.cancel" (secondary: "affirm")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Credentials: `ANTHROPIC_API_KEY` (or an `ant auth login` profile) / `OPENAI_API_KEY`. The CLI
|
|
150
|
+
(`intent-classify`, or the short alias `ic`) also reads them from a local `.env`.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
ic classify "where is order 55120?" --project projects/shopease.yaml --llm none # offline: rules + embeddings
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`projects/shopease.yaml` is a complete example project (a synthetic e-commerce support bot). Copy it to start your own.
|
|
157
|
+
|
|
158
|
+
## Your own project
|
|
159
|
+
|
|
160
|
+
1. Copy `projects/shopease.yaml`. Write a one-paragraph `domain` (this drives off-topic detection) and your intents. For each intent, give a precise description, 5–8 examples, and **negative examples** for the intents it's most often confused with.
|
|
161
|
+
2. Optionally use `core:` to switch off universal intents you don't want, or change a guardrail's action (e.g. `toxicity: block`).
|
|
162
|
+
3. Write `evals/datasets/<project>_*.jsonl` (format in [evals/datasets/README.md](https://github.com/Shubhankar-saket/Intent-classifier-sdk/blob/main/evals/datasets/README.md)). Include
|
|
163
|
+
**off-topic** and **scary-but-benign** cases from your own domain, since only you know what those are. The core
|
|
164
|
+
guardrail and universal suites ship with the package and run automatically, adapted to your taxonomy.
|
|
165
|
+
4. Run `ic eval --project projects/<project>.yaml --datasets "evals/datasets/*.jsonl"` and commit gate thresholds.
|
|
166
|
+
|
|
167
|
+
## Evals
|
|
168
|
+
|
|
169
|
+
See **[docs/EVALS.md](https://github.com/Shubhankar-saket/Intent-classifier-sdk/blob/main/docs/EVALS.md)**. One command compares six systems: the zero-shot baseline vs. each layer of the cascade. It reports accuracy, guardrail recall *with* false-block rate, context and multilingual slices, calibration, latency and cost, plus a failure browser.
|
|
170
|
+
|
|
171
|
+
## Layout
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
src/intent_classify/
|
|
175
|
+
types.py stable result contract
|
|
176
|
+
taxonomy.py YAML loading + merging of shared and project layers, versioning
|
|
177
|
+
builtin/ shared guardrails.yaml + universal.yaml
|
|
178
|
+
normalize.py L0 + history window
|
|
179
|
+
stages/ rules · embedding · llm (prompt + schema)
|
|
180
|
+
pipeline.py cascade + policy (IntentClassifier, ClassifierConfig)
|
|
181
|
+
planner.py slot extraction/validation + deterministic plan templates
|
|
182
|
+
backends/ anthropic · openai · embeddings · registry
|
|
183
|
+
evals/ dataset · systems · metrics · runner · report · gate · leakage
|
|
184
|
+
evals/data/ core eval suites shipped with the package
|
|
185
|
+
cli.py intent-classify / ic: classify | eval | report | gate | check-leakage | generate ...
|
|
186
|
+
projects/shopease.yaml example project (synthetic e-commerce support)
|
|
187
|
+
evals/datasets/ example project's eval suites
|
|
188
|
+
scripts/release_check.py pre-release check (tests, build, clean-venv smoke test, gate)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Contributing
|
|
192
|
+
|
|
193
|
+
Contributions are welcome. See [CONTRIBUTING.md](https://github.com/Shubhankar-saket/Intent-classifier-sdk/blob/main/CONTRIBUTING.md). Changes are listed in [CHANGELOG.md](https://github.com/Shubhankar-saket/Intent-classifier-sdk/blob/main/CHANGELOG.md).
|
|
194
|
+
|
|
195
|
+
## License
|
|
196
|
+
|
|
197
|
+
[Apache-2.0](https://github.com/Shubhankar-saket/Intent-classifier-sdk/blob/main/LICENSE)
|
|
198
|
+
|
|
199
|
+
## Design decisions worth knowing
|
|
200
|
+
|
|
201
|
+
- **Primary intent = the task, resolved with context.** Dialogue acts like affirm, deny or complaint come second when a task is present.
|
|
202
|
+
- **Conversation content is data, not instructions.** It's escaped and wrapped in tags. An injected instruction becomes evidence for a guardrail, never a command.
|
|
203
|
+
- **Provider refusals become a `provider_refusal` flag** (default `block`). When the model's own safety layer declines to even classify a message, that is itself a strong signal. On Claude Opus 5.5 / Sonnet 5.5 the adapter enables server-side refusal fallbacks first.
|
|
204
|
+
- **LLM errors degrade instead of crash** (`on_llm_error="fallback"`). The result records `errors`, so callers can choose to fail closed.
|
|
205
|
+
- **Default model is `claude-opus-5-5` at `low` effort.** Cheaper options are one flag away (`--llm anthropic:claude-haiku-4-5`). Compare them in the eval report before choosing; don't guess.
|