aid-runtime-python 0.1.185__tar.gz → 0.1.186__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.185 → aid_runtime_python-0.1.186}/PKG-INFO +1 -1
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/pyproject.toml +1 -1
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/__init__.py +15 -1
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/__init__.py +16 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/loop.py +64 -2
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/resume.py +5 -3
- aid_runtime_python-0.1.186/src/aid_runtime/agents/runs.py +438 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/state.py +5 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime_python.egg-info/PKG-INFO +1 -1
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime_python.egg-info/SOURCES.txt +2 -0
- aid_runtime_python-0.1.186/tests/test_agents_runs.py +320 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/README.md +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/setup.cfg +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/chat_model.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/deep_agents.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/engine.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/guardrails.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/ir.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/managed.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/memory.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/policy.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/cache.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/concurrency.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/control.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/cost.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/decisions.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/errors.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/evals/__init__.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/evals/agent_runner.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/evals/dataset.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/evals/gate.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/evals/metrics.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/evals/predicate.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/evals/runner.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/evals/trajectory.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/gateway.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/local_trace.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/metrics.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/pipeline.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/prompts.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/__init__.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/anthropic.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/base.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/bedrock.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/fake.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/gemini.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/gemini_wire.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/http.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/recorded.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/providers/vertex.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/py.typed +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/redaction.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/__init__.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/chunking.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/citations.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/connectors.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/embedding.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/filters.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/gate.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/hybrid.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/knowledge_base.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/metrics.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/pgvector.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/rerank.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/retriever.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/stores.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/retrieval/types.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/steps.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/structured.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/telemetry.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/tools.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/tracing.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/types.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime_python.egg-info/dependency_links.txt +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime_python.egg-info/requires.txt +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime_python.egg-info/top_level.txt +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agent_eval_runner.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agents_budget.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agents_checkpoint_integrity.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agents_deep_agents.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agents_hitl.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agents_loop.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agents_memory.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agents_redaction.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_agents_resume_hardening.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_anthropic_provider.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_bedrock_provider.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_cache.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_concurrency.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_control.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_cost.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_dataset.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_decisions.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_evals.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_evals_assert_gate.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_evals_budgets.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_evals_decision.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_evals_gate.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_evals_predicate.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_evals_trajectory.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_gateway.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_gemini_provider.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_guardrails.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_guardrails_managed.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_guardrails_model_armor.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_http_provider.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_local_trace.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_metrics.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_package.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_pipeline.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_prompts.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_recorded_provider.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_redaction.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_chunking.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_citations.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_connectors.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_embedding.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_filters.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_gate.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_hybrid.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_knowledge_base.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_metrics.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_rerank.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_stores.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_retrieval_types.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_steps.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_streaming.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_structured.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_telemetry.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_tool_permissions.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_tools.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_tracing.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/tests/test_types.py +0 -0
- {aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/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.186
|
|
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.186"
|
|
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"
|
|
@@ -35,19 +35,26 @@ from aid_runtime.agents import (
|
|
|
35
35
|
HumanApproval,
|
|
36
36
|
HumanDecision,
|
|
37
37
|
InProcessMemoryStore,
|
|
38
|
+
InProcessRunStore,
|
|
38
39
|
MemoryDefinition,
|
|
39
40
|
MemoryStore,
|
|
40
41
|
NonceStore,
|
|
41
42
|
PendingApproval,
|
|
43
|
+
PostgresRunStore,
|
|
42
44
|
Principal,
|
|
43
45
|
RunResult,
|
|
44
46
|
RunStatus,
|
|
47
|
+
RunStore,
|
|
45
48
|
RuntimeSpec,
|
|
49
|
+
SqliteRunStore,
|
|
46
50
|
StepKind,
|
|
47
51
|
StepRecord,
|
|
48
52
|
ThreadMemory,
|
|
49
53
|
ToolSpec,
|
|
54
|
+
new_run_id,
|
|
50
55
|
nonce_store_from_env,
|
|
56
|
+
run_store_for,
|
|
57
|
+
run_store_from_env,
|
|
51
58
|
signer_from_env,
|
|
52
59
|
)
|
|
53
60
|
from aid_runtime.cache import CompletionCache, cache_key_for
|
|
@@ -357,7 +364,7 @@ from aid_runtime.types import (
|
|
|
357
364
|
)
|
|
358
365
|
|
|
359
366
|
#: Kept in sync with ``pyproject.toml`` by a test, so the two cannot drift.
|
|
360
|
-
__version__ = "0.1.
|
|
367
|
+
__version__ = "0.1.186"
|
|
361
368
|
|
|
362
369
|
__all__ = [
|
|
363
370
|
"AGENT_LABEL",
|
|
@@ -475,6 +482,7 @@ __all__ = [
|
|
|
475
482
|
"HumanDecision",
|
|
476
483
|
"InMemoryVectorStore",
|
|
477
484
|
"InProcessMemoryStore",
|
|
485
|
+
"InProcessRunStore",
|
|
478
486
|
"IndexSpec",
|
|
479
487
|
"IngestReport",
|
|
480
488
|
"JsonSchemaValid",
|
|
@@ -515,6 +523,7 @@ __all__ = [
|
|
|
515
523
|
"PipelineContext",
|
|
516
524
|
"PipelineError",
|
|
517
525
|
"PolicyEvaluationError",
|
|
526
|
+
"PostgresRunStore",
|
|
518
527
|
"Principal",
|
|
519
528
|
"PromptNotFoundError",
|
|
520
529
|
"PromptRegistry",
|
|
@@ -550,6 +559,7 @@ __all__ = [
|
|
|
550
559
|
"RunOutput",
|
|
551
560
|
"RunResult",
|
|
552
561
|
"RunStatus",
|
|
562
|
+
"RunStore",
|
|
553
563
|
"Runner",
|
|
554
564
|
"RuntimeSpec",
|
|
555
565
|
"ScoredChunk",
|
|
@@ -560,6 +570,7 @@ __all__ = [
|
|
|
560
570
|
"SourceKind",
|
|
561
571
|
"SourceSpec",
|
|
562
572
|
"SpendSummary",
|
|
573
|
+
"SqliteRunStore",
|
|
563
574
|
"Step",
|
|
564
575
|
"StepCount",
|
|
565
576
|
"StepKind",
|
|
@@ -638,6 +649,7 @@ __all__ = [
|
|
|
638
649
|
"local_trace_enabled",
|
|
639
650
|
"map_step",
|
|
640
651
|
"metric_names",
|
|
652
|
+
"new_run_id",
|
|
641
653
|
"nonce_store_from_env",
|
|
642
654
|
"normalize",
|
|
643
655
|
"open_connector",
|
|
@@ -663,6 +675,8 @@ __all__ = [
|
|
|
663
675
|
"route",
|
|
664
676
|
"rrf_score",
|
|
665
677
|
"run_evaluation",
|
|
678
|
+
"run_store_for",
|
|
679
|
+
"run_store_from_env",
|
|
666
680
|
"run_structured",
|
|
667
681
|
"signer_from_env",
|
|
668
682
|
"similarity",
|
{aid_runtime_python-0.1.185 → aid_runtime_python-0.1.186}/src/aid_runtime/agents/__init__.py
RENAMED
|
@@ -74,6 +74,15 @@ from aid_runtime.agents.resume import (
|
|
|
74
74
|
nonce_store_from_env,
|
|
75
75
|
signer_from_env,
|
|
76
76
|
)
|
|
77
|
+
from aid_runtime.agents.runs import (
|
|
78
|
+
InProcessRunStore,
|
|
79
|
+
PostgresRunStore,
|
|
80
|
+
RunStore,
|
|
81
|
+
SqliteRunStore,
|
|
82
|
+
new_run_id,
|
|
83
|
+
run_store_for,
|
|
84
|
+
run_store_from_env,
|
|
85
|
+
)
|
|
77
86
|
from aid_runtime.agents.state import (
|
|
78
87
|
AgentCheckpoint,
|
|
79
88
|
CheckpointIntegrity,
|
|
@@ -118,6 +127,7 @@ __all__ = [
|
|
|
118
127
|
"HumanDecision",
|
|
119
128
|
"InProcessMemoryStore",
|
|
120
129
|
"InProcessNonceStore",
|
|
130
|
+
"InProcessRunStore",
|
|
121
131
|
"ManagedGuardrailSettings",
|
|
122
132
|
"MemoryDefinition",
|
|
123
133
|
"MemoryStore",
|
|
@@ -126,11 +136,14 @@ __all__ = [
|
|
|
126
136
|
"NonceStore",
|
|
127
137
|
"PendingApproval",
|
|
128
138
|
"PostgresNonceStore",
|
|
139
|
+
"PostgresRunStore",
|
|
129
140
|
"Principal",
|
|
130
141
|
"RunResult",
|
|
131
142
|
"RunStatus",
|
|
143
|
+
"RunStore",
|
|
132
144
|
"RuntimeSpec",
|
|
133
145
|
"SqliteNonceStore",
|
|
146
|
+
"SqliteRunStore",
|
|
134
147
|
"StepKind",
|
|
135
148
|
"StepRecord",
|
|
136
149
|
"ThreadMemory",
|
|
@@ -140,9 +153,12 @@ __all__ = [
|
|
|
140
153
|
"evaluate_policy",
|
|
141
154
|
"managed_guardrail_settings",
|
|
142
155
|
"model_armor_settings",
|
|
156
|
+
"new_run_id",
|
|
143
157
|
"nonce_store_for",
|
|
144
158
|
"nonce_store_from_env",
|
|
145
159
|
"policy_source",
|
|
146
160
|
"render_context",
|
|
161
|
+
"run_store_for",
|
|
162
|
+
"run_store_from_env",
|
|
147
163
|
"signer_from_env",
|
|
148
164
|
]
|
|
@@ -33,6 +33,7 @@ alias. It is never a retry loop: a degraded frame that still does not fit fails.
|
|
|
33
33
|
|
|
34
34
|
from __future__ import annotations
|
|
35
35
|
|
|
36
|
+
import time
|
|
36
37
|
from collections.abc import Iterable, Mapping, Sequence
|
|
37
38
|
from dataclasses import dataclass, field
|
|
38
39
|
from typing import Any
|
|
@@ -73,6 +74,7 @@ from aid_runtime.agents.resume import (
|
|
|
73
74
|
InProcessNonceStore,
|
|
74
75
|
NonceStore,
|
|
75
76
|
)
|
|
77
|
+
from aid_runtime.agents.runs import RunStore, new_run_id
|
|
76
78
|
from aid_runtime.agents.state import (
|
|
77
79
|
AgentCheckpoint,
|
|
78
80
|
HumanDecision,
|
|
@@ -207,6 +209,7 @@ class AgentRuntime:
|
|
|
207
209
|
limiter: ConcurrencyLimiter | None = None,
|
|
208
210
|
signer: CheckpointSigner | None = None,
|
|
209
211
|
nonces: NonceStore | None = None,
|
|
212
|
+
runs: RunStore | None = None,
|
|
210
213
|
) -> None:
|
|
211
214
|
self._spec = spec
|
|
212
215
|
self._gateway = gateway
|
|
@@ -221,6 +224,11 @@ class AgentRuntime:
|
|
|
221
224
|
# before: a library embedding it directly is not silently given a key.
|
|
222
225
|
self._signer = signer
|
|
223
226
|
self._nonces: NonceStore = nonces if nonces is not None else InProcessNonceStore()
|
|
227
|
+
# Where a paused run is written so a *later process* can continue it. `None` keeps
|
|
228
|
+
# the pre-store behaviour exactly: the checkpoint returns to the caller and the run
|
|
229
|
+
# outlives the request only, so a library embedder is not silently handed a
|
|
230
|
+
# database, and no `run_id` is reported for a run nothing stored.
|
|
231
|
+
self._runs = runs
|
|
224
232
|
self._guardrails = GuardrailEngine(spec.guardrails, decisions=spec.decisions)
|
|
225
233
|
self._tools_by_name: dict[str, ToolSpec] = {
|
|
226
234
|
definition.name: definition for definition in spec.tools.values()
|
|
@@ -241,6 +249,7 @@ class AgentRuntime:
|
|
|
241
249
|
tracer: Tracer | None = None,
|
|
242
250
|
signer: CheckpointSigner | None = None,
|
|
243
251
|
nonces: NonceStore | None = None,
|
|
252
|
+
runs: RunStore | None = None,
|
|
244
253
|
) -> AgentRuntime:
|
|
245
254
|
"""Build a runtime from an emitted IR document.
|
|
246
255
|
|
|
@@ -263,6 +272,7 @@ class AgentRuntime:
|
|
|
263
272
|
limiter=limiter,
|
|
264
273
|
signer=signer,
|
|
265
274
|
nonces=nonces,
|
|
275
|
+
runs=runs,
|
|
266
276
|
)
|
|
267
277
|
|
|
268
278
|
@property
|
|
@@ -319,7 +329,7 @@ class AgentRuntime:
|
|
|
319
329
|
# The refusal is re-raised unchanged: publishing the spend is not a recovery.
|
|
320
330
|
self._publish_spend(agent.id, start_cost, start_tokens)
|
|
321
331
|
raise
|
|
322
|
-
return self._wrap(outcome, start_cost, start_tokens)
|
|
332
|
+
return await self._store(self._wrap(outcome, start_cost, start_tokens))
|
|
323
333
|
|
|
324
334
|
async def resume(
|
|
325
335
|
self,
|
|
@@ -343,7 +353,59 @@ class AgentRuntime:
|
|
|
343
353
|
# Same rule as `run`: a resumed run that fails has been billed too.
|
|
344
354
|
self._publish_spend(checkpoint.agent_id, start_cost, start_tokens)
|
|
345
355
|
raise
|
|
346
|
-
return self._wrap(outcome, start_cost, start_tokens)
|
|
356
|
+
return await self._store(self._wrap(outcome, start_cost, start_tokens))
|
|
357
|
+
|
|
358
|
+
async def resume_run(
|
|
359
|
+
self,
|
|
360
|
+
run_id: str,
|
|
361
|
+
decision: HumanDecision | str,
|
|
362
|
+
*,
|
|
363
|
+
principal: Principal | None = None,
|
|
364
|
+
) -> RunResult:
|
|
365
|
+
"""Continue a paused run by id, reading its checkpoint from the store.
|
|
366
|
+
|
|
367
|
+
The distinction from :meth:`resume` is where the authority comes from. A caller
|
|
368
|
+
holding a checkpoint holds a capability; a caller naming a ``run_id`` holds only a
|
|
369
|
+
reference, and the store is what turns it back into a run. That makes the stored
|
|
370
|
+
path safe in two ways the hand-back path is not: the body was authored by the app,
|
|
371
|
+
so nothing the caller sends can be resumed after editing; and the row is claimed in
|
|
372
|
+
the write that reads it, so the id resumes once even across replicas.
|
|
373
|
+
|
|
374
|
+
Everything :meth:`resume` checks still happens -- signature, deadline, owner
|
|
375
|
+
binding, nonce -- because the store returns the *same* signed checkpoint the pause
|
|
376
|
+
produced. A refusal is raised before the decision is read, so an unbound caller
|
|
377
|
+
never learns whether their answer would have been accepted.
|
|
378
|
+
"""
|
|
379
|
+
if self._runs is None:
|
|
380
|
+
raise ConfigurationError(
|
|
381
|
+
"this runtime was built without a run store, so there is no paused run "
|
|
382
|
+
"to resume by id; declare `agentState` so the app writes one"
|
|
383
|
+
)
|
|
384
|
+
checkpoint = await self._runs.load(run_id=run_id, now=int(time.time()))
|
|
385
|
+
return await self.resume(checkpoint, decision, principal=principal)
|
|
386
|
+
|
|
387
|
+
async def _store(self, result: RunResult) -> RunResult:
|
|
388
|
+
"""Write a paused run and report the id it can be resumed by.
|
|
389
|
+
|
|
390
|
+
Only a pause is stored. A completed run has nothing to continue, and a run that
|
|
391
|
+
hit a ceiling is a failure the caller should see rather than a checkpoint to keep.
|
|
392
|
+
An unsigned checkpoint has no deadline inside it, so ``expires_at`` is ``None``
|
|
393
|
+
rather than a number this method invented: a document that declared no signing key
|
|
394
|
+
declared no window either, and the store records that instead of guessing.
|
|
395
|
+
"""
|
|
396
|
+
if self._runs is None or result.status is not RunStatus.PAUSED:
|
|
397
|
+
return result
|
|
398
|
+
if result.checkpoint is None:
|
|
399
|
+
return result
|
|
400
|
+
integrity = result.checkpoint.integrity
|
|
401
|
+
run_id = new_run_id()
|
|
402
|
+
await self._runs.save(
|
|
403
|
+
run_id=run_id,
|
|
404
|
+
checkpoint=result.checkpoint,
|
|
405
|
+
expires_at=None if integrity is None else integrity.expires_at,
|
|
406
|
+
now=int(time.time()),
|
|
407
|
+
)
|
|
408
|
+
return result.model_copy(update={"run_id": run_id})
|
|
347
409
|
|
|
348
410
|
async def _accept(self, checkpoint: AgentCheckpoint, principal: Principal) -> AgentCheckpoint:
|
|
349
411
|
"""Refuse a checkpoint this app did not issue, has expired, or already spent.
|
|
@@ -123,9 +123,11 @@ class CheckpointRefusalError(AidRuntimeError):
|
|
|
123
123
|
"""A resume body this app will not honour, with a stable machine-readable reason.
|
|
124
124
|
|
|
125
125
|
``reason`` is one of ``tampered``, ``expired``, ``unbound``, ``replayed`` or
|
|
126
|
-
``unsigned``.
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
``unsigned``. ``unknown-run`` is raised by the run store instead of the signer, when a
|
|
127
|
+
caller names a ``run_id`` nothing is stored under. Every one of them is for the log:
|
|
128
|
+
the generated route answers all of them with the same opaque 403, so a caller cannot
|
|
129
|
+
use the distinction as an oracle. Library embedders that want the distinction can read
|
|
130
|
+
it here.
|
|
129
131
|
"""
|
|
130
132
|
|
|
131
133
|
def __init__(self, reason: str, message: str) -> None:
|