aid-runtime-python 0.1.158__tar.gz → 0.1.160__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/PKG-INFO +1 -1
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/pyproject.toml +1 -1
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/__init__.py +11 -1
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/errors.py +11 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/__init__.py +8 -1
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/agent_runner.py +78 -9
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/dataset.py +38 -2
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/metrics.py +156 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/trajectory.py +45 -4
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime_python.egg-info/PKG-INFO +1 -1
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_agent_eval_runner.py +100 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_dataset.py +35 -1
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_evals_trajectory.py +168 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/README.md +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/setup.cfg +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/__init__.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/chat_model.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/deep_agents.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/engine.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/guardrails.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/ir.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/loop.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/managed.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/memory.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/policy.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/agents/state.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/cache.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/concurrency.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/control.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/cost.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/decisions.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/gate.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/predicate.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/runner.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/gateway.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/local_trace.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/metrics.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/pipeline.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/prompts.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/__init__.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/anthropic.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/base.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/bedrock.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/fake.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/gemini.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/gemini_wire.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/http.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/recorded.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/providers/vertex.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/py.typed +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/__init__.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/chunking.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/citations.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/connectors.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/embedding.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/filters.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/gate.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/hybrid.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/knowledge_base.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/metrics.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/pgvector.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/rerank.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/retriever.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/stores.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/retrieval/types.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/steps.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/structured.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/telemetry.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/tools.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/tracing.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/types.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime_python.egg-info/SOURCES.txt +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime_python.egg-info/dependency_links.txt +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime_python.egg-info/requires.txt +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime_python.egg-info/top_level.txt +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_agents_budget.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_agents_deep_agents.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_agents_hitl.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_agents_loop.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_agents_memory.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_anthropic_provider.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_bedrock_provider.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_cache.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_concurrency.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_control.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_cost.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_decisions.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_evals.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_evals_assert_gate.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_evals_budgets.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_evals_decision.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_evals_gate.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_evals_predicate.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_gateway.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_gemini_provider.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_guardrails.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_guardrails_managed.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_guardrails_model_armor.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_http_provider.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_local_trace.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_metrics.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_package.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_pipeline.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_prompts.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_recorded_provider.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_chunking.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_citations.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_connectors.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_embedding.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_filters.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_gate.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_hybrid.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_knowledge_base.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_metrics.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_rerank.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_stores.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_retrieval_types.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_steps.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_streaming.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_structured.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_telemetry.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_tool_permissions.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_tools.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_tracing.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_types.py +0 -0
- {aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/tests/test_vertex_provider.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aid-runtime-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.160
|
|
4
4
|
Summary: The AID Framework Python runtime: model gateway with pinning and cost budgets, prompt registry, tool executor, OTel GenAI tracing, plain-async pipeline, and an eval harness that gates on statistical regression against a stored baseline.
|
|
5
5
|
Author: The AID Framework authors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aid-runtime-python"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.160"
|
|
8
8
|
description = "The AID Framework Python runtime: model gateway with pinning and cost budgets, prompt registry, tool executor, OTel GenAI tracing, plain-async pipeline, and an eval harness that gates on statistical regression against a stored baseline."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -112,10 +112,12 @@ from aid_runtime.errors import (
|
|
|
112
112
|
ToolNotFoundError,
|
|
113
113
|
ToolPermissionError,
|
|
114
114
|
UnknownModelAliasError,
|
|
115
|
+
UnreviewedCasesError,
|
|
115
116
|
)
|
|
116
117
|
from aid_runtime.evals import (
|
|
117
118
|
AgentEvalRunner,
|
|
118
119
|
ApprovalPolicy,
|
|
120
|
+
ApprovalRespected,
|
|
119
121
|
BaselineGate,
|
|
120
122
|
CaseOutcome,
|
|
121
123
|
CostCeiling,
|
|
@@ -125,6 +127,7 @@ from aid_runtime.evals import (
|
|
|
125
127
|
EvalCase,
|
|
126
128
|
EvalRun,
|
|
127
129
|
ExactMatch,
|
|
130
|
+
ForbiddenTool,
|
|
128
131
|
GateResult,
|
|
129
132
|
GatewayRunner,
|
|
130
133
|
JsonSchemaValid,
|
|
@@ -140,6 +143,7 @@ from aid_runtime.evals import (
|
|
|
140
143
|
RunContext,
|
|
141
144
|
Runner,
|
|
142
145
|
RunOutput,
|
|
146
|
+
StepCount,
|
|
143
147
|
Threshold,
|
|
144
148
|
ToolTrace,
|
|
145
149
|
Trajectory,
|
|
@@ -149,6 +153,7 @@ from aid_runtime.evals import (
|
|
|
149
153
|
gateway_judge,
|
|
150
154
|
metric_names,
|
|
151
155
|
normalize,
|
|
156
|
+
require_reviewed,
|
|
152
157
|
run_evaluation,
|
|
153
158
|
z_critical,
|
|
154
159
|
)
|
|
@@ -344,7 +349,7 @@ from aid_runtime.types import (
|
|
|
344
349
|
)
|
|
345
350
|
|
|
346
351
|
#: Kept in sync with ``pyproject.toml`` by a test, so the two cannot drift.
|
|
347
|
-
__version__ = "0.1.
|
|
352
|
+
__version__ = "0.1.160"
|
|
348
353
|
|
|
349
354
|
__all__ = [
|
|
350
355
|
"AGENT_LABEL",
|
|
@@ -392,6 +397,7 @@ __all__ = [
|
|
|
392
397
|
"AidRuntimeError",
|
|
393
398
|
"AnthropicProvider",
|
|
394
399
|
"ApprovalPolicy",
|
|
400
|
+
"ApprovalRespected",
|
|
395
401
|
"BaselineGate",
|
|
396
402
|
"BedrockProvider",
|
|
397
403
|
"Budget",
|
|
@@ -445,6 +451,7 @@ __all__ = [
|
|
|
445
451
|
"FileMemoryStore",
|
|
446
452
|
"FinishReason",
|
|
447
453
|
"FixedChunker",
|
|
454
|
+
"ForbiddenTool",
|
|
448
455
|
"GateConfigurationError",
|
|
449
456
|
"GateResult",
|
|
450
457
|
"GatewayRunner",
|
|
@@ -540,6 +547,7 @@ __all__ = [
|
|
|
540
547
|
"SourceSpec",
|
|
541
548
|
"SpendSummary",
|
|
542
549
|
"Step",
|
|
550
|
+
"StepCount",
|
|
543
551
|
"StepKind",
|
|
544
552
|
"StepRecord",
|
|
545
553
|
"StepResult",
|
|
@@ -568,6 +576,7 @@ __all__ = [
|
|
|
568
576
|
"Transcript",
|
|
569
577
|
"TranscriptEntry",
|
|
570
578
|
"UnknownModelAliasError",
|
|
579
|
+
"UnreviewedCasesError",
|
|
571
580
|
"VectorStore",
|
|
572
581
|
"VectorStoreSpec",
|
|
573
582
|
"VertexProvider",
|
|
@@ -628,6 +637,7 @@ __all__ = [
|
|
|
628
637
|
"record_usage",
|
|
629
638
|
"reduce_step",
|
|
630
639
|
"repair_prompt",
|
|
640
|
+
"require_reviewed",
|
|
631
641
|
"reranker_for",
|
|
632
642
|
"resolve_source",
|
|
633
643
|
"resolve_uri",
|
|
@@ -35,6 +35,7 @@ __all__ = [
|
|
|
35
35
|
"ToolExecutionError",
|
|
36
36
|
"ToolNotFoundError",
|
|
37
37
|
"UnknownModelAliasError",
|
|
38
|
+
"UnreviewedCasesError",
|
|
38
39
|
]
|
|
39
40
|
|
|
40
41
|
|
|
@@ -335,3 +336,13 @@ class GateConfigurationError(EvalError):
|
|
|
335
336
|
itself produced by a model. Gating on one source of non-determinism using
|
|
336
337
|
another is not a gate.
|
|
337
338
|
"""
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
class UnreviewedCasesError(GateConfigurationError):
|
|
342
|
+
"""A CI-gating eval was handed a dataset that still carries unreviewed cases.
|
|
343
|
+
|
|
344
|
+
``aid trace export`` writes every case it produces tagged ``unreviewed``, because
|
|
345
|
+
a machine turned captured traffic into a case and nobody has read it. That is the
|
|
346
|
+
raw material of the improvement loop, not evidence that a change is safe, so a
|
|
347
|
+
``gate.ci`` eval refuses it rather than letting unread data approve a release.
|
|
348
|
+
"""
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from aid_runtime.evals.agent_runner import AgentEvalRunner, ApprovalPolicy
|
|
6
|
-
from aid_runtime.evals.dataset import Dataset, EvalCase
|
|
6
|
+
from aid_runtime.evals.dataset import Dataset, EvalCase, require_reviewed
|
|
7
7
|
from aid_runtime.evals.gate import (
|
|
8
8
|
BaselineGate,
|
|
9
9
|
EvalBaseline,
|
|
@@ -17,10 +17,12 @@ from aid_runtime.evals.gate import (
|
|
|
17
17
|
z_critical,
|
|
18
18
|
)
|
|
19
19
|
from aid_runtime.evals.metrics import (
|
|
20
|
+
ApprovalRespected,
|
|
20
21
|
AssertMetric,
|
|
21
22
|
CostCeiling,
|
|
22
23
|
DecisionScore,
|
|
23
24
|
ExactMatch,
|
|
25
|
+
ForbiddenTool,
|
|
24
26
|
JsonSchemaValid,
|
|
25
27
|
JudgeVerdict,
|
|
26
28
|
LatencyCeiling,
|
|
@@ -29,6 +31,7 @@ from aid_runtime.evals.metrics import (
|
|
|
29
31
|
MetricResult,
|
|
30
32
|
NormalizedContains,
|
|
31
33
|
RunContext,
|
|
34
|
+
StepCount,
|
|
32
35
|
ToolTrace,
|
|
33
36
|
default_metrics,
|
|
34
37
|
metric_names,
|
|
@@ -48,6 +51,7 @@ from aid_runtime.evals.trajectory import RunOutput, Trajectory
|
|
|
48
51
|
__all__ = [
|
|
49
52
|
"AgentEvalRunner",
|
|
50
53
|
"ApprovalPolicy",
|
|
54
|
+
"ApprovalRespected",
|
|
51
55
|
"AssertMetric",
|
|
52
56
|
"BaselineGate",
|
|
53
57
|
"CaseOutcome",
|
|
@@ -59,6 +63,7 @@ __all__ = [
|
|
|
59
63
|
"EvalCase",
|
|
60
64
|
"EvalRun",
|
|
61
65
|
"ExactMatch",
|
|
66
|
+
"ForbiddenTool",
|
|
62
67
|
"GateResult",
|
|
63
68
|
"GatewayRunner",
|
|
64
69
|
"JsonSchemaValid",
|
|
@@ -74,6 +79,7 @@ __all__ = [
|
|
|
74
79
|
"RunContext",
|
|
75
80
|
"RunOutput",
|
|
76
81
|
"Runner",
|
|
82
|
+
"StepCount",
|
|
77
83
|
"Threshold",
|
|
78
84
|
"ToolTrace",
|
|
79
85
|
"Trajectory",
|
|
@@ -83,6 +89,7 @@ __all__ = [
|
|
|
83
89
|
"gateway_judge",
|
|
84
90
|
"metric_names",
|
|
85
91
|
"normalize",
|
|
92
|
+
"require_reviewed",
|
|
86
93
|
"run_evaluation",
|
|
87
94
|
"z_critical",
|
|
88
95
|
]
|
{aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/agent_runner.py
RENAMED
|
@@ -31,7 +31,8 @@ needs a pinned provider and belongs with the baselines, not with a gate.
|
|
|
31
31
|
|
|
32
32
|
from __future__ import annotations
|
|
33
33
|
|
|
34
|
-
from collections.abc import Iterable, Iterator, Mapping
|
|
34
|
+
from collections.abc import Iterable, Iterator, Mapping, Sequence
|
|
35
|
+
from dataclasses import dataclass
|
|
35
36
|
from enum import StrEnum
|
|
36
37
|
|
|
37
38
|
from aid_runtime.agents.loop import AgentRuntime
|
|
@@ -139,14 +140,22 @@ class AgentEvalRunner:
|
|
|
139
140
|
before = runtime.gateway.ledger.cost_usd
|
|
140
141
|
try:
|
|
141
142
|
result = await runtime.run(self._agent_id, case.input)
|
|
142
|
-
result = await self._settle(runtime, case, result)
|
|
143
|
+
result, approvals = await self._settle(runtime, case, result)
|
|
143
144
|
finally:
|
|
144
145
|
# Charged even when the run raised: a case stopped by a guardrail was billed,
|
|
145
146
|
# and a cost series that only saw completed cases would under-report exactly
|
|
146
147
|
# when the guardrails fire.
|
|
147
148
|
self._cost_usd += max(runtime.gateway.ledger.cost_usd - before, 0.0)
|
|
148
149
|
self._last = result
|
|
149
|
-
return RunOutput(
|
|
150
|
+
return RunOutput(
|
|
151
|
+
text=result.answer,
|
|
152
|
+
trajectory=Trajectory.from_run(
|
|
153
|
+
result,
|
|
154
|
+
pauses=approvals.pauses,
|
|
155
|
+
decisions=approvals.decisions,
|
|
156
|
+
ignored=approvals.ignored,
|
|
157
|
+
),
|
|
158
|
+
)
|
|
150
159
|
|
|
151
160
|
def _runtime(self) -> AgentRuntime:
|
|
152
161
|
# A fresh memory store per case, for the same reason as the fresh ledger: ``run``
|
|
@@ -159,10 +168,14 @@ class AgentEvalRunner:
|
|
|
159
168
|
memory_store=InProcessMemoryStore(),
|
|
160
169
|
)
|
|
161
170
|
|
|
162
|
-
async def _settle(
|
|
163
|
-
|
|
171
|
+
async def _settle(
|
|
172
|
+
self, runtime: AgentRuntime, case: EvalCase, result: RunResult
|
|
173
|
+
) -> tuple[RunResult, _Approvals]:
|
|
174
|
+
"""Resume through every pause the case has decisions for, and record what happened."""
|
|
164
175
|
decisions = iter(case.approvals)
|
|
165
|
-
|
|
176
|
+
applied: list[str] = []
|
|
177
|
+
rejections: list[_Rejection] = []
|
|
178
|
+
pauses = 0
|
|
166
179
|
while result.status is RunStatus.PAUSED:
|
|
167
180
|
checkpoint = result.checkpoint
|
|
168
181
|
if checkpoint is None:
|
|
@@ -171,15 +184,33 @@ class AgentEvalRunner:
|
|
|
171
184
|
"cannot be resumed; the loop must record one before reporting a pause"
|
|
172
185
|
)
|
|
173
186
|
decision = self._decision(case, decisions)
|
|
174
|
-
|
|
175
|
-
if
|
|
187
|
+
pauses += 1
|
|
188
|
+
if pauses > self._max_resumes:
|
|
176
189
|
raise EvalError(
|
|
177
190
|
f"case {case.id!r} paused {self._max_resumes} times and is still asking; "
|
|
178
191
|
"the case is supplying decisions to a run that is not converging, and "
|
|
179
192
|
"resuming it again would only multiply the spend"
|
|
180
193
|
)
|
|
194
|
+
applied.append(decision.value)
|
|
195
|
+
# The calls this pause is asking about. `Checkpoint.calls` is empty when the
|
|
196
|
+
# pause came from a guardrail releasing an answer rather than a tool call, so
|
|
197
|
+
# a rejection there blocks nothing and records no boundary.
|
|
198
|
+
names = frozenset(call.name for call in checkpoint.calls)
|
|
199
|
+
if decision is HumanDecision.REJECT:
|
|
200
|
+
rejections.append(_Rejection(boundary=len(result.steps), names=names))
|
|
201
|
+
else:
|
|
202
|
+
# A later approval of the same calls lifts the earlier rejection, so the
|
|
203
|
+
# only names left to check at the end are the ones nobody ever approved.
|
|
204
|
+
rejections = [
|
|
205
|
+
_Rejection(boundary=rejection.boundary, names=rejection.names - names)
|
|
206
|
+
for rejection in rejections
|
|
207
|
+
]
|
|
181
208
|
result = await runtime.resume(checkpoint, decision)
|
|
182
|
-
return result
|
|
209
|
+
return result, _Approvals(
|
|
210
|
+
pauses=pauses,
|
|
211
|
+
decisions=tuple(applied),
|
|
212
|
+
ignored=_ignored_calls(result, [r for r in rejections if r.names]),
|
|
213
|
+
)
|
|
183
214
|
|
|
184
215
|
def _decision(self, case: EvalCase, decisions: Iterator[str]) -> HumanDecision:
|
|
185
216
|
if self._policy is ApprovalPolicy.APPROVE:
|
|
@@ -196,6 +227,44 @@ class AgentEvalRunner:
|
|
|
196
227
|
)
|
|
197
228
|
|
|
198
229
|
|
|
230
|
+
@dataclass(frozen=True)
|
|
231
|
+
class _Approvals:
|
|
232
|
+
"""What the harness observed about a case's approvals, for the trajectory to carry."""
|
|
233
|
+
|
|
234
|
+
pauses: int = 0
|
|
235
|
+
decisions: tuple[str, ...] = ()
|
|
236
|
+
ignored: tuple[str, ...] = ()
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@dataclass(frozen=True)
|
|
240
|
+
class _Rejection:
|
|
241
|
+
"""One rejection, and where in the run's steps it was answered.
|
|
242
|
+
|
|
243
|
+
``boundary`` is the number of steps recorded when the rejection was given. Steps only
|
|
244
|
+
ever append -- a resume restores the ones the checkpoint holds and continues from
|
|
245
|
+
there -- so the same index slices the final run and yields exactly what happened
|
|
246
|
+
after the answer, which is the only place a call could ignore it.
|
|
247
|
+
"""
|
|
248
|
+
|
|
249
|
+
boundary: int
|
|
250
|
+
names: frozenset[str]
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def _ignored_calls(result: RunResult, rejections: Sequence[_Rejection]) -> tuple[str, ...]:
|
|
254
|
+
"""Names of rejected tools that nonetheless ran after the rejection.
|
|
255
|
+
|
|
256
|
+
A rejection tells the run that a call did not happen. A call that happens anyway is
|
|
257
|
+
the one safety finding this metric reports: everything else it checks is a mismatch
|
|
258
|
+
between what a case scripted and what the run did, but this one is a bound the spec
|
|
259
|
+
promised a person that the machinery then crossed.
|
|
260
|
+
"""
|
|
261
|
+
found: set[str] = set()
|
|
262
|
+
for rejection in rejections:
|
|
263
|
+
for step in result.steps[rejection.boundary :]:
|
|
264
|
+
found.update(name for name in step.tool_names if name in rejection.names)
|
|
265
|
+
return tuple(sorted(found))
|
|
266
|
+
|
|
267
|
+
|
|
199
268
|
def _declared_agents(document: Mapping[str, object]) -> set[str]:
|
|
200
269
|
"""The ids the document declares, read structurally so a typo fails before case one.
|
|
201
270
|
|
|
@@ -12,9 +12,17 @@ from pathlib import Path
|
|
|
12
12
|
|
|
13
13
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
14
14
|
|
|
15
|
-
from aid_runtime.errors import EvalError
|
|
15
|
+
from aid_runtime.errors import EvalError, UnreviewedCasesError
|
|
16
16
|
|
|
17
|
-
__all__ = ["Dataset", "EvalCase"]
|
|
17
|
+
__all__ = ["UNREVIEWED_TAG", "Dataset", "EvalCase", "require_reviewed"]
|
|
18
|
+
|
|
19
|
+
UNREVIEWED_TAG = "unreviewed"
|
|
20
|
+
"""The tag ``aid trace export`` puts on every case it writes.
|
|
21
|
+
|
|
22
|
+
A case carrying it was produced by a machine from captured traffic, so no human has
|
|
23
|
+
read it. It is a legitimate case -- the raw material of the improvement loop -- but it
|
|
24
|
+
is not evidence that a change is safe.
|
|
25
|
+
"""
|
|
18
26
|
|
|
19
27
|
|
|
20
28
|
class EvalCase(BaseModel):
|
|
@@ -110,3 +118,31 @@ class Dataset(BaseModel):
|
|
|
110
118
|
if not case.get("approvals"):
|
|
111
119
|
case.pop("approvals", None)
|
|
112
120
|
return payload
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def require_reviewed(dataset: Dataset, *, eval_id: str) -> Dataset:
|
|
124
|
+
"""Refuse a dataset that still carries cases no human has reviewed.
|
|
125
|
+
|
|
126
|
+
Returns the dataset so a generated CI-gating eval can wrap its loader:
|
|
127
|
+
``require_reviewed(load_dataset(), eval_id=EVAL_ID)``. An eval that does not gate
|
|
128
|
+
CI is left alone -- unreviewed cases are the point of the improvement loop.
|
|
129
|
+
|
|
130
|
+
The refusal is the product. A ``gate.ci`` eval decides whether a change ships, so a
|
|
131
|
+
case exported from traffic and never read would let unread data approve a release.
|
|
132
|
+
Dropping those cases silently would be worse than refusing: the dataset would look
|
|
133
|
+
complete while part of it never ran. The message names the cases and the fix, because
|
|
134
|
+
the fix is a human reading them -- nothing in the runtime can clear the tag for them.
|
|
135
|
+
"""
|
|
136
|
+
unreviewed = dataset.by_tag(UNREVIEWED_TAG)
|
|
137
|
+
if not unreviewed:
|
|
138
|
+
return dataset
|
|
139
|
+
named = ", ".join(case.id for case in unreviewed[:5])
|
|
140
|
+
remainder = "" if len(unreviewed) <= 5 else f" and {len(unreviewed) - 5} more"
|
|
141
|
+
raise UnreviewedCasesError(
|
|
142
|
+
f"eval {eval_id!r} gates CI but its dataset {dataset.name!r} ({dataset.version}) "
|
|
143
|
+
f"carries {len(unreviewed)} case(s) tagged {UNREVIEWED_TAG!r}: {named}{remainder}. "
|
|
144
|
+
f"A case tagged {UNREVIEWED_TAG!r} came from `aid trace export` and no human has "
|
|
145
|
+
f"read it, so it cannot decide whether a change ships. Review each case, then drop "
|
|
146
|
+
f"{UNREVIEWED_TAG!r} from its tags; or point this eval at a dataset you curated. "
|
|
147
|
+
f"An eval with `gate.ci: false` may use an unreviewed dataset as it is."
|
|
148
|
+
)
|
|
@@ -25,10 +25,12 @@ from aid_runtime.evals.trajectory import Trajectory
|
|
|
25
25
|
from aid_runtime.structured import run_structured
|
|
26
26
|
|
|
27
27
|
__all__ = [
|
|
28
|
+
"ApprovalRespected",
|
|
28
29
|
"AssertMetric",
|
|
29
30
|
"CostCeiling",
|
|
30
31
|
"DecisionScore",
|
|
31
32
|
"ExactMatch",
|
|
33
|
+
"ForbiddenTool",
|
|
32
34
|
"JsonSchemaValid",
|
|
33
35
|
"JudgeVerdict",
|
|
34
36
|
"LatencyCeiling",
|
|
@@ -37,6 +39,7 @@ __all__ = [
|
|
|
37
39
|
"MetricResult",
|
|
38
40
|
"NormalizedContains",
|
|
39
41
|
"RunContext",
|
|
42
|
+
"StepCount",
|
|
40
43
|
"ToolTrace",
|
|
41
44
|
"default_metrics",
|
|
42
45
|
"metric_names",
|
|
@@ -588,6 +591,159 @@ def _tool_list(names: Sequence[str]) -> str:
|
|
|
588
591
|
return ", ".join(names) if names else "no tools"
|
|
589
592
|
|
|
590
593
|
|
|
594
|
+
class StepCount(_Ceiling):
|
|
595
|
+
"""Whether a run finished inside a declared ceiling on model calls.
|
|
596
|
+
|
|
597
|
+
The agent's own ``maxSteps`` already bounds a run, so this is not a second safety
|
|
598
|
+
net -- it is the eval asserting the bound held for *this* case. A case expected to
|
|
599
|
+
take three steps that takes nine is a run that looped, and the answer it eventually
|
|
600
|
+
produced is not the run the case described.
|
|
601
|
+
|
|
602
|
+
Refuses a trajectory that reports no steps rather than passing one: an agent run is
|
|
603
|
+
model calls, so a count of zero means nobody counted, and a ceiling over an
|
|
604
|
+
uncounted run would pass every case by accident.
|
|
605
|
+
"""
|
|
606
|
+
|
|
607
|
+
_quantity = "took"
|
|
608
|
+
|
|
609
|
+
def __init__(self, *, max_steps: int, name: str = "step-count") -> None:
|
|
610
|
+
if max_steps <= 0:
|
|
611
|
+
raise ConfigurationError(f"a step ceiling must be above zero, got {max_steps}")
|
|
612
|
+
super().__init__(name=name)
|
|
613
|
+
self._max = max_steps
|
|
614
|
+
|
|
615
|
+
def _limit(self) -> float:
|
|
616
|
+
return float(self._max)
|
|
617
|
+
|
|
618
|
+
def _measure(self, case: EvalCase, context: RunContext | None) -> float:
|
|
619
|
+
if context is None or context.trajectory is None:
|
|
620
|
+
raise EvalError(
|
|
621
|
+
f"case {case.id!r} carries a step ceiling, but its runner reported no "
|
|
622
|
+
"trajectory, so there is no step count to compare against it"
|
|
623
|
+
)
|
|
624
|
+
if context.trajectory.steps == 0:
|
|
625
|
+
raise EvalError(
|
|
626
|
+
f"case {case.id!r} carries a step ceiling, but its trajectory records no "
|
|
627
|
+
"steps; an agent run is at least one model call, so a count of zero means "
|
|
628
|
+
"the count was never taken and the ceiling would pass over it"
|
|
629
|
+
)
|
|
630
|
+
return float(context.trajectory.steps)
|
|
631
|
+
|
|
632
|
+
def _format(self, value: float) -> str:
|
|
633
|
+
return f"{value:.0f} steps"
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
class ForbiddenTool:
|
|
637
|
+
"""Whether a run reached for a tool it was told not to use.
|
|
638
|
+
|
|
639
|
+
The inverse of ``ToolTrace``: that one asks whether the run did a thing, this asks
|
|
640
|
+
whether it crossed a line. A run that calls no tools at all passes, because "did not
|
|
641
|
+
use the forbidden tool" is true of it -- but a runner that reports no trajectory is
|
|
642
|
+
refused, since silence about tool calls is not evidence that none were made.
|
|
643
|
+
"""
|
|
644
|
+
|
|
645
|
+
def __init__(self, *, forbid: Sequence[str], name: str = "forbidden-tool") -> None:
|
|
646
|
+
if not forbid:
|
|
647
|
+
raise ConfigurationError("a forbidden-tool metric must name at least one tool")
|
|
648
|
+
self._name = name
|
|
649
|
+
self._forbid = tuple(forbid)
|
|
650
|
+
|
|
651
|
+
@property
|
|
652
|
+
def name(self) -> str:
|
|
653
|
+
return self._name
|
|
654
|
+
|
|
655
|
+
@property
|
|
656
|
+
def deterministic(self) -> bool:
|
|
657
|
+
return True
|
|
658
|
+
|
|
659
|
+
async def score(
|
|
660
|
+
self, case: EvalCase, prediction: str, *, context: RunContext | None = None
|
|
661
|
+
) -> MetricResult:
|
|
662
|
+
if context is None or context.trajectory is None:
|
|
663
|
+
raise EvalError(
|
|
664
|
+
f"case {case.id!r} carries a forbidden-tool metric, but its runner reported "
|
|
665
|
+
"no tool calls, so there is nothing to clear the run of"
|
|
666
|
+
)
|
|
667
|
+
hit = tuple(sorted(set(self._forbid).intersection(context.trajectory.calls)))
|
|
668
|
+
ok = not hit
|
|
669
|
+
return MetricResult(
|
|
670
|
+
metric=self.name,
|
|
671
|
+
score=1.0 if ok else 0.0,
|
|
672
|
+
passed=ok,
|
|
673
|
+
detail=(
|
|
674
|
+
f"called none of {_tool_list(self._forbid)}"
|
|
675
|
+
if ok
|
|
676
|
+
else f"called forbidden {_tool_list(hit)}"
|
|
677
|
+
),
|
|
678
|
+
)
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
class ApprovalRespected:
|
|
682
|
+
"""Whether a run paused when a person had to decide, and obeyed the answer.
|
|
683
|
+
|
|
684
|
+
Three findings, and a case passes only when none of them fires. They are separate
|
|
685
|
+
because they mean different things to whoever reads the failure:
|
|
686
|
+
|
|
687
|
+
``pause-missed`` is a case that scripted a decision the run never asked for, so the
|
|
688
|
+
decision was never tested. ``pause-unexpected`` is a pause the case supplied no
|
|
689
|
+
decision for -- the run stopped where the dataset said nothing would. Both are
|
|
690
|
+
mismatches between the dataset and the machinery.
|
|
691
|
+
|
|
692
|
+
``decision-ignored`` is the safety finding: a call ran after a reviewer rejected it.
|
|
693
|
+
It fails the case even when the answer matches what the case expected, because a
|
|
694
|
+
correct answer reached by crossing an approval is not a correct answer.
|
|
695
|
+
|
|
696
|
+
The counts come from the runner, since no metric can recover them from an answer.
|
|
697
|
+
A trajectory that carries none of them is refused when the case scripted a decision;
|
|
698
|
+
an unrecorded approval is not a respected one.
|
|
699
|
+
"""
|
|
700
|
+
|
|
701
|
+
def __init__(self, *, name: str = "approval-respected") -> None:
|
|
702
|
+
self._name = name
|
|
703
|
+
|
|
704
|
+
@property
|
|
705
|
+
def name(self) -> str:
|
|
706
|
+
return self._name
|
|
707
|
+
|
|
708
|
+
@property
|
|
709
|
+
def deterministic(self) -> bool:
|
|
710
|
+
return True
|
|
711
|
+
|
|
712
|
+
async def score(
|
|
713
|
+
self, case: EvalCase, prediction: str, *, context: RunContext | None = None
|
|
714
|
+
) -> MetricResult:
|
|
715
|
+
if context is None or context.trajectory is None:
|
|
716
|
+
raise EvalError(
|
|
717
|
+
f"case {case.id!r} carries an approval-respected metric, but its runner "
|
|
718
|
+
"reported no trajectory, so there is no approval record to judge"
|
|
719
|
+
)
|
|
720
|
+
trajectory = context.trajectory
|
|
721
|
+
findings: list[str] = []
|
|
722
|
+
if case.approvals and trajectory.pauses == 0:
|
|
723
|
+
findings.append("pause-missed: the case supplies a decision the run never asked for")
|
|
724
|
+
if not case.approvals and trajectory.pauses > 0:
|
|
725
|
+
findings.append(
|
|
726
|
+
f"pause-unexpected: the run paused {trajectory.pauses} time(s) and the case "
|
|
727
|
+
"supplies no decision"
|
|
728
|
+
)
|
|
729
|
+
if trajectory.ignored:
|
|
730
|
+
findings.append(
|
|
731
|
+
f"decision-ignored: {_tool_list(trajectory.ignored)} ran after a rejection"
|
|
732
|
+
)
|
|
733
|
+
ok = not findings
|
|
734
|
+
return MetricResult(
|
|
735
|
+
metric=self.name,
|
|
736
|
+
score=1.0 if ok else 0.0,
|
|
737
|
+
passed=ok,
|
|
738
|
+
detail=(
|
|
739
|
+
f"respected {len(trajectory.decisions)} decision(s) across "
|
|
740
|
+
f"{trajectory.pauses} pause(s)"
|
|
741
|
+
if ok
|
|
742
|
+
else "; ".join(findings)
|
|
743
|
+
),
|
|
744
|
+
)
|
|
745
|
+
|
|
746
|
+
|
|
591
747
|
def default_metrics() -> tuple[Metric, ...]:
|
|
592
748
|
"""The deterministic gate metrics: everything that needs no model call."""
|
|
593
749
|
return (ExactMatch(), NormalizedContains(), JsonSchemaValid())
|
{aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime/evals/trajectory.py
RENAMED
|
@@ -9,6 +9,12 @@ names that step called, so the sequence is a flatten, not a new instrumentation
|
|
|
9
9
|
still works and still scores every text metric; what it cannot do is satisfy a
|
|
10
10
|
``tool-trace`` metric, which refuses rather than passing over a run it was never told the
|
|
11
11
|
tool calls of.
|
|
12
|
+
|
|
13
|
+
The same holds for approvals. A pause, the decision that answered it, and whether a
|
|
14
|
+
rejected call ran anyway are facts about the run that no metric can recover from the
|
|
15
|
+
answer text, so a runner that resumes a paused agent records them on the trajectory it
|
|
16
|
+
returns. ``approval-respected`` reads them and refuses a trajectory that carries no
|
|
17
|
+
record at all.
|
|
12
18
|
"""
|
|
13
19
|
|
|
14
20
|
from __future__ import annotations
|
|
@@ -16,7 +22,7 @@ from __future__ import annotations
|
|
|
16
22
|
from collections.abc import Sequence
|
|
17
23
|
from typing import TYPE_CHECKING
|
|
18
24
|
|
|
19
|
-
from pydantic import BaseModel, ConfigDict
|
|
25
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
20
26
|
|
|
21
27
|
if TYPE_CHECKING:
|
|
22
28
|
# Type-only: this module reaches into a record's shape, never its definitions, so
|
|
@@ -32,25 +38,60 @@ class Trajectory(BaseModel):
|
|
|
32
38
|
Deliberately just the names, not arguments or results: an expectation is written
|
|
33
39
|
against *what* a run did, and pinning the arguments of a model-authored call would
|
|
34
40
|
make the assertion fail on a paraphrase that was equally correct.
|
|
41
|
+
|
|
42
|
+
``steps`` counts model calls, not tool calls: one step can raise several tools, and a
|
|
43
|
+
run that pauses records the step that asked before it stops. The two are separate
|
|
44
|
+
because they answer different questions -- "did it stay inside its step ceiling" is
|
|
45
|
+
about ``steps``, "did it reach for a tool it was told not to use" is about ``calls``.
|
|
46
|
+
|
|
47
|
+
``pauses``, ``decisions`` and ``ignored`` are the approval record. A metric cannot
|
|
48
|
+
reconstruct them from a finished answer: whether a case paused, what the harness
|
|
49
|
+
answered, and whether a call ran after a rejection are all facts only the runner
|
|
50
|
+
observes, so it writes them here.
|
|
35
51
|
"""
|
|
36
52
|
|
|
37
53
|
model_config = ConfigDict(frozen=True, extra="forbid")
|
|
38
54
|
|
|
39
55
|
calls: tuple[str, ...] = ()
|
|
56
|
+
steps: int = Field(default=0, ge=0)
|
|
57
|
+
pauses: int = Field(default=0, ge=0)
|
|
58
|
+
decisions: tuple[str, ...] = ()
|
|
59
|
+
ignored: tuple[str, ...] = ()
|
|
40
60
|
|
|
41
61
|
@classmethod
|
|
42
62
|
def from_steps(cls, steps: Sequence[StepRecord]) -> Trajectory:
|
|
43
|
-
return cls(
|
|
63
|
+
return cls(
|
|
64
|
+
calls=tuple(name for step in steps for name in step.tool_names),
|
|
65
|
+
steps=len(steps),
|
|
66
|
+
)
|
|
44
67
|
|
|
45
68
|
@classmethod
|
|
46
|
-
def from_run(
|
|
69
|
+
def from_run(
|
|
70
|
+
cls,
|
|
71
|
+
result: RunResult,
|
|
72
|
+
*,
|
|
73
|
+
pauses: int = 0,
|
|
74
|
+
decisions: tuple[str, ...] = (),
|
|
75
|
+
ignored: tuple[str, ...] = (),
|
|
76
|
+
) -> Trajectory:
|
|
47
77
|
"""The trajectory of an agent run, read off the steps it recorded.
|
|
48
78
|
|
|
49
79
|
A paused or blocked run still has one: the loop records a step before it decides
|
|
50
80
|
what to do with it, so a run that stopped at an approval records the calls that
|
|
51
81
|
asked for it.
|
|
82
|
+
|
|
83
|
+
The keyword arguments carry what only the runner knows. A caller that ran the
|
|
84
|
+
loop directly leaves them at their defaults, which reads as "no approval was
|
|
85
|
+
involved" -- and ``approval-respected`` refuses that reading rather than passing
|
|
86
|
+
on it when the case asked for one.
|
|
52
87
|
"""
|
|
53
|
-
return cls
|
|
88
|
+
return cls(
|
|
89
|
+
calls=tuple(name for step in result.steps for name in step.tool_names),
|
|
90
|
+
steps=len(result.steps),
|
|
91
|
+
pauses=pauses,
|
|
92
|
+
decisions=decisions,
|
|
93
|
+
ignored=ignored,
|
|
94
|
+
)
|
|
54
95
|
|
|
55
96
|
def __bool__(self) -> bool:
|
|
56
97
|
return bool(self.calls)
|
{aid_runtime_python-0.1.158 → aid_runtime_python-0.1.160}/src/aid_runtime_python.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aid-runtime-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.160
|
|
4
4
|
Summary: The AID Framework Python runtime: model gateway with pinning and cost budgets, prompt registry, tool executor, OTel GenAI tracing, plain-async pipeline, and an eval harness that gates on statistical regression against a stored baseline.
|
|
5
5
|
Author: The AID Framework authors
|
|
6
6
|
License-Expression: Apache-2.0
|