Skill Runner¶
skill
¶
Generic skill runner framework.
Provides SkillConfig and run_skill() — a reusable pipeline for
running AI agent skills against tickets/issues in CI. All domain-specific
behavior is injected via callable hooks on SkillConfig, making this
framework agnostic to the issue tracker, git forge, and skill content.
Usage::
from agentic_ci.skill import SkillConfig, run_skill
config = SkillConfig(
skill_name="my-resolve",
prompt_builder=my_prompt_fn,
verdict_loader=my_verdict_fn,
label_applier=my_label_fn,
)
rc = run_skill(config, ticket_key="PROJ-123", work_dir=Path("/tmp/work"), ...)
run_routed_skill() wraps the same pipeline with difficulty-based model
routing: a classifier run on the default model rates the task, and the
skill then runs on the matching ModelTier (see agentic_ci.routing).
SkillHook
¶
Bases: _SkillHookRequired
Structured definition of an extra skill to run at a pipeline hook point.
SkillConfig(skill_name, skill_source='', skill_ref='main', prompt_builder=lambda **kw: '', context_writer=_noop, verdict_loader=_noop_verdict, verdict_path_fn=lambda wd: wd / 'verdict.json', label_applier=_noop, cost_formatter=lambda d: None, extension_config_writer=_noop, pre_gates=list(), post_gates=list(), extra_skills=list(), context_dir='.context', artifacts=list(), max_retries=1, retryable_modes=frozenset({'resolve'}), backend_name='podman', harness_name='claude-code', container_image=None, container_env=dict(), container_runner=None, model_tiers=dict(), sandbox_profile=None)
dataclass
¶
Configuration for a skill run. All domain-specific behavior via hooks.
model_tiers = field(default_factory=dict)
class-attribute
instance-attribute
¶
Per-tier overrides of the harness default routing tiers (run_routed_skill only).
sandbox_profile = None
class-attribute
instance-attribute
¶
What the target repo needs in the sandbox (see agentic_ci.sandbox_profile).
Reaches the backend through the container runner; only the OpenShell
backend uses it, and in this release only its resources. A custom
container_runner receives it as the sandbox_profile keyword, and
only when it is set.
RoutedSkillResult(rc, route)
dataclass
¶
Result of :func:run_routed_skill.
route is None when no agent ran (dry run or a pre-gate blocked
the run), so no routing decision was made.
run_skill(config, ticket_key, work_dir, config_dir, *, mode='resolve', ticket=None, dry_run=False, dry_run_verdict_path=None, **extra_kwargs)
¶
Run a skill pipeline for a single ticket. Returns exit code.
Flow: 1. Run pre-gates (skip container if any gate returns a non-None message) 2. Write context via context_writer hook 3. Write extension config via extension_config_writer hook 4. Build prompt via prompt_builder hook 5. Launch container (or dry-run) 6. Read cost data (OTEL) 7. Run post-gates 8. Load verdict via verdict_loader hook 9. Format comment and apply labels via label_applier hook
Source code in src/agentic_ci/skill.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | |
run_routed_skill(config, ticket_key, work_dir, config_dir, *, mode='resolve', ticket=None, dry_run=False, dry_run_verdict_path=None, classifier_max_turns=DEFAULT_CLASSIFIER_MAX_TURNS, classifier_prompt_builder=None, force_tier=None, **extra_kwargs)
¶
Run a skill with difficulty-based model routing.
Behaves like :func:run_skill with one addition: before the skill runs,
a classifier invocation on the harness default model (CLAUDE_MODEL,
OPENCODE_MODEL or CODEX_MODEL, else Harness.default_model())
rates the task as low, medium or high and writes
_run/route.json. The skill then runs on the matching
:class:~agentic_ci.routing.ModelTier from the harness defaults,
overridden per key by config.model_tiers.
The classifier runs inside the same sandbox as the skill (same container,
credentials and network policy). Its raw stream is written to
_run/classifier-output.txt. Any classifier failure (non-zero exit,
exception, missing or invalid route file) logs a warning and falls back to
the default model at the harness's effective default effort (env var or
registry default_effort), which is exactly what :func:run_skill
would do. Only configuration errors raise, and they
raise before any container starts.
The decision is made once per call and reused by every retry that
:func:run_skill performs, so all attempts use the same model. A
skill.routed event is appended to the run's _run/claude-otel.jsonl.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
classifier_max_turns
|
int
|
turn cap for the classifier where the CLI
supports one (Claude Code |
DEFAULT_CLASSIFIER_MAX_TURNS
|
classifier_prompt_builder
|
Callable[[str], str] | None
|
replaces the default classifier prompt; receives the skill prompt and returns the classifier prompt. |
None
|
force_tier
|
str | None
|
skip the classifier and pin this tier. |
None
|
config.container_runner must be None; custom runners have no
model surface. extension_config_writer receives a copy of config
whose container_runner is the routing runner.
Returns:
| Type | Description |
|---|---|
RoutedSkillResult
|
class: |
RoutedSkillResult
|
( |
Source code in src/agentic_ci/skill.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | |