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, allow_host_setup=False)
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.
allow_host_setup = False
class-attribute
instance-attribute
¶
Deprecated: run the target repo's .agentic-ci/config.yml setup steps
on this host, outside any sandbox (local use only; the backend refuses it
in CI). Reaches the backend through the container runner like
sandbox_profile; a custom container_runner receives it as the
allow_host_setup keyword, and only when it is true.
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
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 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 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 | |
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
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 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |