reach.run¶
Orchestration engine for conducting evaluation runs, assembling catalogs, and executing probe loops.
Orchestrate evaluation runs, catalog composition, probe execution, and persistence.
Composition ¶
Bases: BaseModel
Hold validated components including config, query set, catalog, and corpus.
Source code in src/reach/run.py
provenance
property
¶
provenance: Provenance
Derive Provenance metadata from configuration, corpus, and query set.
ConfigSidecar ¶
Bases: BaseModel
Record provenance digests and configuration beside a results file.
Source code in src/reach/run.py
Plan ¶
Bases: BaseModel
Summarize execution parameters, target sizes, and workloads.
Source code in src/reach/run.py
per_query_resolution
property
¶
Calculate detectable effect size threshold for individual queries.
ProbeHarness ¶
Coordinate concurrent probe attempts, retries, and result streaming.
Source code in src/reach/run.py
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 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 | |
__init__ ¶
__init__(
runtime: AgentRuntime,
*,
workers: int = 1,
retries: int = 2,
backoff_s: float = 5.0,
pause_s: float = 0.0,
sleep: Callable[[float], None] = sleep,
cache_outcomes: bool = True,
outcome_cache: dict[_ProbeOutcomeCacheKey, Any]
| None = None,
) -> None
Initialize probe harness with runtime driver and execution options.
Source code in src/reach/run.py
probe ¶
probe(
query: Query,
catalog: Catalog,
workdir: Path,
*,
attempt: int = 1,
provenance: Provenance | None = None,
fit: CatalogFit | None = None,
) -> ProbeResult
Execute a single query probe attempt with catalog residency validation.
Source code in src/reach/run.py
run ¶
run(
composition: Composition,
*,
out_path: Path | None = None,
resume: bool = True,
append_across_arms: bool = False,
allow_truncation: bool = False,
progress: Callable[[int, int, ProbeResult], None]
| None = None,
) -> RunOutcome
Execute an evaluation run end-to-end and persist results and sidecar configuration.
Source code in src/reach/run.py
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 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 | |
run_probes ¶
run_probes(
queries: Sequence[Query],
catalog: Catalog,
workdir: Path,
*,
attempts: int = DEFAULT_ATTEMPTS,
out_path: Path | None = None,
skip: set[tuple[str, int]] | None = None,
provenance: Provenance | None = None,
fit: CatalogFit | None = None,
) -> Iterator[ProbeResult]
Execute probe batches across queries with thread pooling, retries, and persistence.
Source code in src/reach/run.py
RunOutcome ¶
Bases: BaseModel
Hold results, artifact, and full context models from a completed evaluation run.
Source code in src/reach/run.py
composition
property
¶
composition: Composition
Construct the Composition corresponding to this run outcome.
artifact ¶
artifact(
*,
roots: Sequence[Path] | None = None,
contested: Sequence[ContestedSkill] = (),
sample_queries: int = DEFAULT_SAMPLE_QUERIES,
) -> Artifact
Construct the canonical Artifact document for this evaluation outcome.
Source code in src/reach/run.py
append_result ¶
append_result(
path: Path | str, result: ProbeResult
) -> None
Append a ProbeResult model as a JSON line to the target file.
completed_attempts ¶
Return completed, successful (query_id, attempt) pairs from existing results.
Source code in src/reach/run.py
compose ¶
compose(
config: RunConfig, skills: Sequence[Skill] | None = None
) -> Composition
Resolve and validate the target catalog and query set for an evaluation run.
Source code in src/reach/run.py
conduct ¶
conduct(
config: RunConfig,
runtime: AgentRuntime | None = None,
*,
progress: Callable[[int, int, ProbeResult], None]
| None = None,
resume: bool = True,
append_across_arms: bool = False,
allow_truncation: bool = False,
composed: Composition | None = None,
workers: int | None = None,
outcome_cache: dict[_ProbeOutcomeCacheKey, Any]
| None = None,
) -> RunOutcome
Execute an evaluation run end-to-end and return the full RunOutcome.
Source code in src/reach/run.py
evaluate ¶
evaluate(
config: RunConfig,
runtime: AgentRuntime | None = None,
*,
skills: Sequence[Skill] | None = None,
auto_draft: bool = False,
progress: Callable[[int, int, ProbeResult], None]
| None = None,
resume: bool = True,
append_across_arms: bool = False,
allow_truncation: bool = False,
composed: Composition | None = None,
workers: int | None = None,
) -> RunOutcome
Execute an evaluation run, resolving or drafting queries, and probing skills.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
RunConfig
|
Run configuration specifying study parameters and options. |
required |
runtime
|
AgentRuntime | None
|
Optional AgentRuntime instance to use; if None, built from config. |
None
|
skills
|
Sequence[Skill] | None
|
Optional sequence of pre-loaded Skill instances; if None, loaded from corpus. |
None
|
auto_draft
|
bool
|
Whether to automatically draft queries if not already present on disk. |
False
|
progress
|
Callable[[int, int, ProbeResult], None] | None
|
Optional callback invoked as each probe completes. |
None
|
resume
|
bool
|
Whether to resume from existing results on disk. |
True
|
append_across_arms
|
bool
|
Whether to append results across different study arms. |
False
|
allow_truncation
|
bool
|
Whether to proceed if the catalog exceeds runtime prompt limits. |
False
|
composed
|
Composition | None
|
Optional pre-constructed Composition instance. |
None
|
workers
|
int | None
|
Number of concurrent workers executing probes. |
None
|
Returns:
| Type | Description |
|---|---|
RunOutcome
|
A RunOutcome instance containing results, catalog, query set, and artifact. |
Source code in src/reach/run.py
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 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | |
load_corpus ¶
Load skill corpus from configured path.
Source code in src/reach/run.py
load_results ¶
load_results(path: Path | str) -> list[ProbeResult]
Load previously recorded ProbeResult records from a JSONL file.
Source code in src/reach/run.py
plan_only ¶
plan_probes ¶
plan_probes(
queries: Sequence[Query],
attempts: int = DEFAULT_ATTEMPTS,
) -> list[tuple[Query, int]]
Generate an interleaved list of (query, attempt) pairs for probing.
Source code in src/reach/run.py
read_sidecar ¶
read_sidecar(path: Path) -> ConfigSidecar
Load and validate sidecar configuration metadata from disk.
Source code in src/reach/run.py
recorded_fingerprints ¶
Return all unique config fingerprints recorded in a results file.
Source code in src/reach/run.py
sidecar_path ¶
validate_appendable ¶
validate_appendable(
path: Path | str,
fingerprint: str,
condition: str = "",
queries: str = "",
) -> None
Validate new probes match existing experimental conditions in results.
Source code in src/reach/run.py
validate_catalog_fit ¶
validate_catalog_fit(
runtime: AgentRuntime,
catalog: Catalog,
skills: Sequence[Skill],
*,
allow_truncation: bool = False,
) -> CatalogFit
Verify that resident catalog fits within runtime listing budgets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
AgentRuntime
|
Target agent runtime adapter. |
required |
catalog
|
Catalog
|
Catalog definition specifying resident skill names. |
required |
skills
|
Sequence[Skill]
|
Resident Skill objects loaded from disk. |
required |
allow_truncation
|
bool
|
If True, allow execution even if runtime truncates descriptions. |
False
|
Returns:
| Type | Description |
|---|---|
CatalogFit
|
A CatalogFit assessment recording whether the catalog fits and truncation counts. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the catalog exceeds runtime prompt budget and allow_truncation is False. |
Source code in src/reach/run.py
validate_query_coverage ¶
validate_query_coverage(
query_set: QuerySet,
skills: Sequence[str],
*,
partial: bool = False,
) -> None
Validate query set expected skills align with resident catalog skills.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_set
|
QuerySet
|
Labeled evaluation queries with assigned target skills. |
required |
skills
|
Sequence[str]
|
Names of skills resident in the catalog. |
required |
partial
|
bool
|
If True, allow query sets that target only a subset of resident skills. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If resident skills have no queries (unless partial is True) or if queries target skills not resident in the catalog. |
Source code in src/reach/run.py
validate_residency ¶
validate_residency(
catalog: Catalog,
observed: tuple[str, ...],
*,
dynamic: bool = False,
) -> str | None
Return error string if catalog skill is missing or unrecognized.
Source code in src/reach/run.py
write_results ¶
write_results(
path: Path | str, results: Iterable[ProbeResult]
) -> Path
Persist a collection of ProbeResult models as JSON lines to the target file.