Ask the trigger grader LLM whether the description suggests this skill should be loaded for the given question. The grader deliberately sees ONLY the description — that is the trigger surface external agents will see when deciding to load the skill. The body is irrelevant to *this*
(
description: str,
question: str,
*,
model: str,
)
| 272 | |
| 273 | |
| 274 | async def grade_one( |
| 275 | description: str, |
| 276 | question: str, |
| 277 | *, |
| 278 | model: str, |
| 279 | ) -> Literal["trigger", "no-trigger"]: |
| 280 | """Ask the trigger grader LLM whether the description suggests this |
| 281 | skill should be loaded for the given question. |
| 282 | |
| 283 | The grader deliberately sees ONLY the description — that is the |
| 284 | trigger surface external agents will see when deciding to load the |
| 285 | skill. The body is irrelevant to *this* metric; see |
| 286 | :func:`grade_coverage` for the body-aware check. |
| 287 | """ |
| 288 | instructions = ( |
| 289 | "You are deciding whether an agent should load a specific skill to " |
| 290 | "answer a user question. You will be given the skill's activation " |
| 291 | "description and a single user question. Answer with one word: " |
| 292 | "TRIGGER (load the skill) or NO-TRIGGER (don't load).\n\n" |
| 293 | f"Skill description:\n {description}\n\n" |
| 294 | "Reply with exactly one of: TRIGGER, NO-TRIGGER." |
| 295 | ) |
| 296 | agent = Agent( |
| 297 | name="trigger-grader", |
| 298 | instructions=instructions, |
| 299 | model=f"litellm/{model}", |
| 300 | model_settings=ModelSettings( |
| 301 | extra_headers=get_extra_headers() or None, |
| 302 | extra_args=get_timeout_extra_args(), |
| 303 | ), |
| 304 | ) |
| 305 | try: |
| 306 | result = await Runner.run(agent, f"Question: {question}", max_turns=2) |
| 307 | except MaxTurnsExceeded as exc: |
| 308 | raise RuntimeError( |
| 309 | f"Trigger grader hit the max-turn cap on question: {question!r}. " |
| 310 | f"Try a more capable model." |
| 311 | ) from exc |
| 312 | raw = (result.final_output or "").strip().upper() |
| 313 | if "NO-TRIGGER" in raw or "NO TRIGGER" in raw: |
| 314 | return "no-trigger" |
| 315 | if "TRIGGER" in raw: |
| 316 | return "trigger" |
| 317 | # Default: assume no-trigger on ambiguous output |
| 318 | return "no-trigger" |
| 319 | |
| 320 | |
| 321 | async def grade_coverage( |