Repository navigation
feat(trigger): precision/recall with near-miss negatives and k repeated runs - #2
Merged
Merged
Conversation
…ed runs run_triggers(cases, skill, agent, k=3, threshold=0.5, competing=...) reports precision, recall, false-trigger rate, F1, run-level fire rates and flaky cases. from_observations scores recorded runs; split_cases gives a stratified train/val split for description tuning. Zero deps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This adds trigger precision/recall for skill descriptions. Today
compare_skill/run_abcomputetrigger_rateonly overexpect == "call"cases, so they measure recall. False triggers on prompts that should not load the skill are never measured, and each case runs once.New
skill_eval.triggermodule:TriggerCase(tid, prompt, should_trigger, note=""). Useshould_trigger=Falsefor near-miss negatives: prompts that share words or a domain with the skill but belong elsewhere.run_triggers(cases, skill, agent, k=3, threshold=0.5, competing=())agent(case, offered, run_index)k times per case.offeredis the skill under test followed by any competing skills.None, or a bool.thresholdof its runs.TriggerReportgives:run_levelraw fire rates for positive and negative casesflakylist (cases that fired on some runs but not all) andfailures()as_dict()and a markdowntable()with the worst cases firstfrom_observations(cases, skill_name, fired=[[...], ...])scores runs you already logged.split_cases(cases, val_fraction=0.4, seed=0)gives a deterministic, stratified train/val split, so you can tune the description on train and report on val.These are pure functions with no new deps. The existing A/B API is unchanged.
Why
Skill authors iterate on the description, and the failure mode is a description that fires everywhere. A recall-only metric rewards that.
How to try
Tests
tests/test_trigger.pyadds 7 tests:from_observationsLocally: 13 passed (6 existing + 7 new) on Python 3.13. CI runs 3.10 and 3.12.
OSS / learning project; no production claims.