ruhken-agent-runtime 0.0.1__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.
- ruhken_agent_runtime-0.0.1/.github/workflows/publish.yml +95 -0
- ruhken_agent_runtime-0.0.1/.gitignore +67 -0
- ruhken_agent_runtime-0.0.1/.python-version +1 -0
- ruhken_agent_runtime-0.0.1/AGENTS.md +15 -0
- ruhken_agent_runtime-0.0.1/CLAUDE.md +15 -0
- ruhken_agent_runtime-0.0.1/CONTEXT.md +113 -0
- ruhken_agent_runtime-0.0.1/LICENSE +22 -0
- ruhken_agent_runtime-0.0.1/PKG-INFO +151 -0
- ruhken_agent_runtime-0.0.1/README.md +131 -0
- ruhken_agent_runtime-0.0.1/docs/adr/.gitkeep +1 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0001-runtime-ownership-migration.md +20 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0002-runtime-compatibility-artifact-policy.md +22 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0003-stage-resolution-and-failure-policy.md +19 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0004-runtime-public-surface-narrowing.md +77 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0005-runtime-session-lifecycle-entrypoints.md +32 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0006-built-in-provider-only-runtime.md +29 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0007-live-runtime-output-observation.md +34 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0008-live-provider-smoke-runner.md +57 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0009-provider-invocation-argv-stdin-boundary.md +3 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0010-no-documentation-regression-tests.md +3 -0
- ruhken_agent_runtime-0.0.1/docs/adr/0011-single-candidate-provider-selection.md +12 -0
- ruhken_agent_runtime-0.0.1/docs/adr/README.md +13 -0
- ruhken_agent_runtime-0.0.1/docs/agents/domain.md +30 -0
- ruhken_agent_runtime-0.0.1/docs/agents/issue-tracker.md +28 -0
- ruhken_agent_runtime-0.0.1/docs/public-api.md +340 -0
- ruhken_agent_runtime-0.0.1/pycastle/.gitignore +6 -0
- ruhken_agent_runtime-0.0.1/pyproject.toml +53 -0
- ruhken_agent_runtime-0.0.1/scripts/build_release_artifacts.py +46 -0
- ruhken_agent_runtime-0.0.1/scripts/live-smoke/.env.example +2 -0
- ruhken_agent_runtime-0.0.1/scripts/live_provider_smoke.py +1422 -0
- ruhken_agent_runtime-0.0.1/scripts/live_provider_smoke_plan.py +871 -0
- ruhken_agent_runtime-0.0.1/setup.cfg +4 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/__init__.py +69 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_builtin_runtime_client.py +3219 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_execution_contracts.py +708 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_import_isolation.py +32 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_portable_continuation_payload.py +141 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_provider_invocation.py +367 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_provider_session_adapter.py +61 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_request_normalization.py +306 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_runtime_compat.py +94 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_runtime_facade_lifecycle.py +723 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_runtime_lifecycle.py +908 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_service_registry.py +127 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/_time.py +5 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/agent_log.py +205 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/contracts.py +288 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/errors.py +231 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/execution_contracts.py +10 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/identity.py +36 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/invocation_progress.py +11 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/provider_errors.py +16 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/provider_output.py +99 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/provider_session_adapter.py +10 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/provider_usage.py +16 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/py.typed +1 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/roles.py +19 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/runtime.py +396 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/service_registry.py +10 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/session.py +227 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/session_planning.py +409 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/stage_priority_chain.py +213 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/types.py +84 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/usage_limit_decision.py +154 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/usage_limit_scope.py +19 -0
- ruhken_agent_runtime-0.0.1/src/agent_runtime/work.py +521 -0
- ruhken_agent_runtime-0.0.1/src/ruhken_agent_runtime.egg-info/PKG-INFO +151 -0
- ruhken_agent_runtime-0.0.1/src/ruhken_agent_runtime.egg-info/SOURCES.txt +90 -0
- ruhken_agent_runtime-0.0.1/src/ruhken_agent_runtime.egg-info/dependency_links.txt +1 -0
- ruhken_agent_runtime-0.0.1/src/ruhken_agent_runtime.egg-info/requires.txt +7 -0
- ruhken_agent_runtime-0.0.1/src/ruhken_agent_runtime.egg-info/top_level.txt +1 -0
- ruhken_agent_runtime-0.0.1/tests/__init__.py +1 -0
- ruhken_agent_runtime-0.0.1/tests/conftest.py +182 -0
- ruhken_agent_runtime-0.0.1/tests/runtime_boundary_fakes.py +219 -0
- ruhken_agent_runtime-0.0.1/tests/test_agent_runtime.py +2978 -0
- ruhken_agent_runtime-0.0.1/tests/test_builtin_provider_client_behavior.py +6896 -0
- ruhken_agent_runtime-0.0.1/tests/test_live_provider_smoke_artifacts.py +2967 -0
- ruhken_agent_runtime-0.0.1/tests/test_live_provider_smoke_plan.py +1266 -0
- ruhken_agent_runtime-0.0.1/tests/test_portable_continuation_payload_behavior.py +129 -0
- ruhken_agent_runtime-0.0.1/tests/test_provider_invocation_adapter_behavior.py +610 -0
- ruhken_agent_runtime-0.0.1/tests/test_provider_output_behavior.py +262 -0
- ruhken_agent_runtime-0.0.1/tests/test_release_artifacts.py +125 -0
- ruhken_agent_runtime-0.0.1/tests/test_resumed_session_run_request.py +454 -0
- ruhken_agent_runtime-0.0.1/tests/test_runtime_continuation_behavior.py +3445 -0
- ruhken_agent_runtime-0.0.1/tests/test_runtime_ephemeral_behavior.py +3335 -0
- ruhken_agent_runtime-0.0.1/tests/test_runtime_metadata_behavior.py +318 -0
- ruhken_agent_runtime-0.0.1/tests/test_runtime_new_session_behavior.py +2655 -0
- ruhken_agent_runtime-0.0.1/tests/test_runtime_outcome_behavior.py +372 -0
- ruhken_agent_runtime-0.0.1/tests/test_runtime_public_surface.py +758 -0
- ruhken_agent_runtime-0.0.1/tests/test_runtime_request_construction.py +1097 -0
- ruhken_agent_runtime-0.0.1/tests/test_runtime_session_planning_behavior.py +645 -0
- ruhken_agent_runtime-0.0.1/tests/test_smoke.py +4 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- "v*.*.*"
|
|
9
|
+
pull_request:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
- run: pip install -e ".[dev]"
|
|
22
|
+
- run: ruff check
|
|
23
|
+
- run: mypy src
|
|
24
|
+
- run: pytest
|
|
25
|
+
|
|
26
|
+
build:
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
needs: test
|
|
29
|
+
if: github.event_name == 'push'
|
|
30
|
+
outputs:
|
|
31
|
+
is_tag: ${{ steps.version.outputs.is_tag }}
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
with:
|
|
35
|
+
fetch-depth: 0
|
|
36
|
+
fetch-tags: true
|
|
37
|
+
|
|
38
|
+
- uses: actions/setup-python@v5
|
|
39
|
+
with:
|
|
40
|
+
python-version: "3.12"
|
|
41
|
+
|
|
42
|
+
- name: Compute version
|
|
43
|
+
id: version
|
|
44
|
+
run: |
|
|
45
|
+
pip install setuptools-scm
|
|
46
|
+
VERSION=$(python -m setuptools_scm)
|
|
47
|
+
echo "Computed version: $VERSION"
|
|
48
|
+
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
|
49
|
+
if [[ "$VERSION" == *".dev"* ]]; then
|
|
50
|
+
echo "ERROR: dev version on tag build" >&2
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
echo "is_tag=true" >> "$GITHUB_OUTPUT"
|
|
54
|
+
else
|
|
55
|
+
echo "is_tag=false" >> "$GITHUB_OUTPUT"
|
|
56
|
+
fi
|
|
57
|
+
echo "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RUHKEN_AGENT_RUNTIME=$VERSION" >> "$GITHUB_ENV"
|
|
58
|
+
|
|
59
|
+
- name: Build
|
|
60
|
+
run: pip install build && python -m build
|
|
61
|
+
|
|
62
|
+
- uses: actions/upload-artifact@v4
|
|
63
|
+
with:
|
|
64
|
+
name: dist
|
|
65
|
+
path: dist/
|
|
66
|
+
|
|
67
|
+
publish-testpypi:
|
|
68
|
+
runs-on: ubuntu-latest
|
|
69
|
+
needs: build
|
|
70
|
+
if: needs.build.outputs.is_tag == 'false'
|
|
71
|
+
environment: testpypi
|
|
72
|
+
permissions:
|
|
73
|
+
id-token: write
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/download-artifact@v4
|
|
76
|
+
with:
|
|
77
|
+
name: dist
|
|
78
|
+
path: dist/
|
|
79
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
80
|
+
with:
|
|
81
|
+
repository-url: https://test.pypi.org/legacy/
|
|
82
|
+
|
|
83
|
+
publish-pypi:
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
needs: build
|
|
86
|
+
if: needs.build.outputs.is_tag == 'true'
|
|
87
|
+
environment: pypi
|
|
88
|
+
permissions:
|
|
89
|
+
id-token: write
|
|
90
|
+
steps:
|
|
91
|
+
- uses: actions/download-artifact@v4
|
|
92
|
+
with:
|
|
93
|
+
name: dist
|
|
94
|
+
path: dist/
|
|
95
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
live-smoke-artifacts/*
|
|
2
|
+
|
|
3
|
+
.idea/
|
|
4
|
+
.claude/
|
|
5
|
+
*.pyc
|
|
6
|
+
.tmp*.md
|
|
7
|
+
|
|
8
|
+
# Byte-compiled / optimized / DLL files
|
|
9
|
+
__pycache__/
|
|
10
|
+
*.py[codz]
|
|
11
|
+
*$py.class
|
|
12
|
+
|
|
13
|
+
# C extensions
|
|
14
|
+
*.so
|
|
15
|
+
|
|
16
|
+
# Distribution / packaging
|
|
17
|
+
.Python
|
|
18
|
+
build/
|
|
19
|
+
develop-eggs/
|
|
20
|
+
dist/
|
|
21
|
+
downloads/
|
|
22
|
+
eggs/
|
|
23
|
+
.eggs/
|
|
24
|
+
lib/
|
|
25
|
+
lib64/
|
|
26
|
+
parts/
|
|
27
|
+
sdist/
|
|
28
|
+
var/
|
|
29
|
+
wheels/
|
|
30
|
+
share/python-wheels/
|
|
31
|
+
*.egg-info/
|
|
32
|
+
.installed.cfg
|
|
33
|
+
*.egg
|
|
34
|
+
MANIFEST
|
|
35
|
+
|
|
36
|
+
# Unit test / coverage reports
|
|
37
|
+
htmlcov/
|
|
38
|
+
.tox/
|
|
39
|
+
.nox/
|
|
40
|
+
.coverage
|
|
41
|
+
.coverage.*
|
|
42
|
+
.cache
|
|
43
|
+
nosetests.xml
|
|
44
|
+
coverage.xml
|
|
45
|
+
*.cover
|
|
46
|
+
*.py.cover
|
|
47
|
+
.hypothesis/
|
|
48
|
+
.pytest_cache/
|
|
49
|
+
cover/
|
|
50
|
+
|
|
51
|
+
# Environments
|
|
52
|
+
.env
|
|
53
|
+
.envrc
|
|
54
|
+
.venv
|
|
55
|
+
env/
|
|
56
|
+
venv/
|
|
57
|
+
ENV/
|
|
58
|
+
env.bak/
|
|
59
|
+
venv.bak/
|
|
60
|
+
|
|
61
|
+
# Mypy / Ruff / other caches
|
|
62
|
+
.mypy_cache/
|
|
63
|
+
.ruff_cache/
|
|
64
|
+
.pyre/
|
|
65
|
+
.pytype/
|
|
66
|
+
cython_debug/
|
|
67
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11.3
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# AGENTS.md instructions for D:\Bootcamp\Projects\agent_runtime
|
|
2
|
+
|
|
3
|
+
<INSTRUCTIONS>
|
|
4
|
+
## Agent skills
|
|
5
|
+
|
|
6
|
+
### Issue tracker
|
|
7
|
+
|
|
8
|
+
Issues live in GitHub Issues (`Johannes-Kutsch/agent_runtime`). See `docs/agents/issue-tracker.md`.
|
|
9
|
+
|
|
10
|
+
### Domain docs
|
|
11
|
+
|
|
12
|
+
Single-context repo - `CONTEXT.md` at the root plus `docs/adr/`. See `docs/agents/domain.md`.
|
|
13
|
+
|
|
14
|
+
</INSTRUCTIONS>
|
|
15
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# CLAUDE.md instructions for D:\Bootcamp\Projects\agent_runtime
|
|
2
|
+
|
|
3
|
+
<INSTRUCTIONS>
|
|
4
|
+
## Agent skills
|
|
5
|
+
|
|
6
|
+
### Issue tracker
|
|
7
|
+
|
|
8
|
+
Issues live in GitHub Issues (`Johannes-Kutsch/agent_runtime`). See `docs/agents/issue-tracker.md`.
|
|
9
|
+
|
|
10
|
+
### Domain docs
|
|
11
|
+
|
|
12
|
+
Single-context repo - `CONTEXT.md` at the root plus `docs/adr/`. See `docs/agents/domain.md`.
|
|
13
|
+
|
|
14
|
+
</INSTRUCTIONS>
|
|
15
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# agent_runtime Context
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
`agent_runtime` is the reusable runtime boundary for agent execution. It owns contracts consumed by application adapters without importing the application.
|
|
6
|
+
|
|
7
|
+
## Ubiquitous Language
|
|
8
|
+
|
|
9
|
+
| Term | Meaning |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `agent_runtime` | Reusable runtime package and stable core public surface. |
|
|
12
|
+
| `Runtime Public Surface` | Documented stability surface: runtime consumer entrypoints, runtime value objects, and built-in provider selection, not every importable symbol. |
|
|
13
|
+
| `Runtime Consumer Surface` | Ordinary consuming-project entrypoints for executing prepared agent work without implementing runtime or provider adapters. |
|
|
14
|
+
| `Built-in Provider Invocation` | Internal runtime mechanism behind `RuntimeClient` that executes one prepared built-in provider command and returns observable invocation facts. |
|
|
15
|
+
| `ProviderAuth` | Immutable credential data carried by `ProviderSelection` for new provider selection, or supplied to Resume Session Run because continuations must not store credentials. |
|
|
16
|
+
| `ProviderSelection` | Public request value selecting one service, model, effort, and provider credentials for one runtime invocation. |
|
|
17
|
+
| `Consumer Fallback` | Consuming-project orchestration that chooses whether to start a separate runtime invocation after a prior invocation completes or fails. |
|
|
18
|
+
| `ToolPolicy` | Closed public value describing allowed provider tools: `NONE`, `INSPECT_ONLY`, `NO_FILE_MUTATION`, or `UNRESTRICTED`. |
|
|
19
|
+
| `Invocation Directory` | Host directory where runtime launches a provider command; public request field is `invocation_dir`. |
|
|
20
|
+
| `Tool Workspace` | Invocation Directory when runtime exposes it through provider tools. |
|
|
21
|
+
| `Ephemeral Run` | Runtime invocation that does not prepare or promise provider-session continuity. |
|
|
22
|
+
| `Start Session Run` | Runtime invocation that selects a service and prepares provider-session continuity. |
|
|
23
|
+
| `Resume Session Run` | Runtime invocation that continues an existing provider-session continuity chain without fallback or reselection. |
|
|
24
|
+
| `Session-backed Provider` | Built-in provider that can produce and consume portable continuation data. |
|
|
25
|
+
| `Continuation` | Opaque portable resume token callers persist and pass back to resume a continuity chain. |
|
|
26
|
+
| `InvocationRecord` | Structured runtime output describing an invocation for caller persistence or display. |
|
|
27
|
+
| `Live Runtime Output` | Provider-neutral observable agent-message text and selected service identity emitted during runtime invocation. |
|
|
28
|
+
| `RuntimeClient` | Caller-owned runtime object that executes runtime requests without durable provider session storage or cross-call provider availability policy. |
|
|
29
|
+
| `RuntimeOutcome` | Canonical result category for one runtime invocation: completion, usage limits, cancellation, timeout, selected-provider temporary unavailability, or retryable provider failure. |
|
|
30
|
+
| `Live Provider Smoke Test` | Opt-in validation run outside default tests that exercises real built-in providers through Runtime Public Surface. |
|
|
31
|
+
| `Full Live Smoke Matrix` | Maintainer confidence scope for Live Provider Smoke Tests: all lifecycle modes plus every public `ToolPolicy` for each selected configured provider. |
|
|
32
|
+
| `Live Smoke Default` | Cost-first runtime-supported provider/model/effort tuple used by Live Provider Smoke Tests when callers provide no CLI or environment override. |
|
|
33
|
+
| `ProviderUsage` | Provider-reported usage metadata: input/output tokens, cache-read/cache-creation input tokens, optional USD cost, and optional provider duration. |
|
|
34
|
+
|
|
35
|
+
## Boundary Rules
|
|
36
|
+
|
|
37
|
+
- Runtime package must remain importable without application modules.
|
|
38
|
+
- Application prompt rendering, CLI wiring, issue orchestration, output parsing, display, redaction, durable trace persistence, and retention belong outside runtime boundary.
|
|
39
|
+
- Runtime Public Surface is documented stability promise, not inventory of importable symbols.
|
|
40
|
+
- Runtime Consumer Surface uses `RuntimeClient`, lifecycle requests, public outcome/result values, `ProviderSelection`, `ProviderAuth`, `Continuation`, `InvocationRecord`, and `ToolPolicy`.
|
|
41
|
+
- Consumers import ToolPolicy from public runtime/root modules, not from adapter contract modules.
|
|
42
|
+
- Ordinary consumers select built-in providers through runtime call arguments, not provider services, service registries, execution adapters, provider-session adapters, command builders, provider event parsers, or provider DTO streams.
|
|
43
|
+
- Consumer-defined provider services are not supported runtime functionality.
|
|
44
|
+
- Prompt-runtime execution adapter paths are retired.
|
|
45
|
+
- `RuntimeClient` owns no cross-call provider availability policy, durable provider state, or logs.
|
|
46
|
+
- Provider selection remains caller-supplied through the `provider_selection` request field; runtime validates built-in service, model, effort, and relevant credentials.
|
|
47
|
+
- ProviderSelection construction validates value shape; invocation validates built-in provider support and availability.
|
|
48
|
+
- ProviderSelection requires explicit service, model, and effort; selection defaults belong to consumers or maintainer tooling.
|
|
49
|
+
- `ProviderSelection.auth` is optional; selected providers that require explicit credentials validate the relevant ProviderAuth field during invocation.
|
|
50
|
+
- ProviderSelection equality includes credentials, but textual representations must not reveal credential values.
|
|
51
|
+
- ProviderAuth equality includes credential values, but textual representations must redact them.
|
|
52
|
+
- Resume Session Run derives provider identity from the continuation and accepts request-time ProviderAuth only for credentials.
|
|
53
|
+
- Runtime does not perform provider fallback inside a single invocation; fallback is Consumer Fallback across separate invocations.
|
|
54
|
+
- Runtime outcomes and exceptions describe one invocation only and do not classify Consumer Fallback eligibility.
|
|
55
|
+
- `no_service_available` describes temporary unavailability of the selected provider before model work starts, not exhaustion of a provider chain.
|
|
56
|
+
- Unsupported service, model, or effort selections are configuration errors, not `no_service_available` outcomes.
|
|
57
|
+
- Normal RuntimeOutcome values identify the selected provider service, model, and effort for the invocation.
|
|
58
|
+
- Runtime results report selected provider facts for one invocation, not Consumer Fallback attempt paths.
|
|
59
|
+
- Invocation records describe one runtime invocation and do not carry Consumer Fallback group or attempt identifiers.
|
|
60
|
+
- Built-in provider credentials are part of `ProviderSelection`; missing explicit credentials are credential failures and do not trigger Consumer Fallback inside runtime.
|
|
61
|
+
- Runtime-owned selection, availability, resumability, failure classification, path-safety validation, and provider parsing stay inside runtime boundary.
|
|
62
|
+
- Built-in Provider Invocation is internal and must not become a consumer-defined adapter extension point or request-time injection point.
|
|
63
|
+
- WorkInvocation and execution adapter seams are internal and must not be consumer-accessible.
|
|
64
|
+
- Public-looking internal modules should be moved behind underscore-prefixed module names before release where practical.
|
|
65
|
+
- Retiring a concept means deleting obsolete code where feasible; any internal survival requires a current built-in runtime purpose and must not reappear on documented/root/runtime surfaces.
|
|
66
|
+
- Built-in Provider Invocation must use runtime-neutral internal artifact names, not pycastle-specific prompt or session naming.
|
|
67
|
+
- Provider event DTOs, provider-specific session details, command rendering, stream parsing, and provider flag profiles are internal.
|
|
68
|
+
- Public provider failure diagnostics may expose provider observations; consumers own storage, display, and redaction.
|
|
69
|
+
- Live Runtime Output is per-request observation of `AgentMessageTurn` values, not arbitrary provider chunks, token streaming, replay, logs, or alternate lifecycle entrypoints.
|
|
70
|
+
- Live Runtime Output is independent of session lifecycle and `ToolPolicy`; completed runtime output remains authoritative.
|
|
71
|
+
- Live Runtime Output observers are synchronous, notification-only, at-most-once per provider attempt, and consumer-owned for async bridging and backpressure.
|
|
72
|
+
- Live Runtime Output callback failures propagate as exceptional consumer failures.
|
|
73
|
+
- Session continuity and tool policy are independent runtime concerns.
|
|
74
|
+
- Ephemeral execution does not intentionally prepare provider-session continuity.
|
|
75
|
+
- Start Session Run returns continuation state; callers own persistence and retention.
|
|
76
|
+
- Resume Session Run continues an existing continuity chain without Consumer Fallback or reselection.
|
|
77
|
+
- Continuations are opaque, portable, semantically immutable, and may carry provider-owned serializable resume state.
|
|
78
|
+
- Continuations and invocation records must not intentionally persist ProviderAuth values.
|
|
79
|
+
- Runtime does not guarantee redaction of arbitrary prompt text, provider output, or diagnostics; consumers own durable redaction policy.
|
|
80
|
+
- Continuations may carry provider identity and resume state, but not ProviderSelection objects.
|
|
81
|
+
- Session-backed execution is limited to built-in providers that produce and consume portable continuation data.
|
|
82
|
+
- Runtime must not own durable provider-session storage, durable invocation-log storage, or cleanup policy.
|
|
83
|
+
- Resumed-session availability or usage-limit failures do not invalidate continuations and must not trigger automatic Consumer Fallback inside runtime.
|
|
84
|
+
- Session-backed interruptions report invocation progress so callers can choose retry or continuation prompts.
|
|
85
|
+
- Usage limits, cancellation, timeout, temporary unavailability, and confidently retryable provider failures are normal `RuntimeOutcome` values.
|
|
86
|
+
- Credential failures, runtime configuration errors, hard provider failures, adapter/protocol bugs, unclassified provider failures, invalid service references, and unexpected exceptions remain exceptional failures.
|
|
87
|
+
- Provider-reported usage belongs on runtime outcomes whenever observed, including interrupted outcomes.
|
|
88
|
+
- Cancellation and timeout outcomes report only usage observed before interruption; runtime does not perform provider-specific post-kill usage recovery.
|
|
89
|
+
- A new continuation becomes meaningful only after provider work has started.
|
|
90
|
+
- Resumed-session execution keeps service, model, effort, and `ToolPolicy` fixed from the continuation while receiving credentials separately.
|
|
91
|
+
- Runtime requests require explicit `ToolPolicy`; non-`NONE` policies grant Invocation Directory as Tool Workspace.
|
|
92
|
+
- ToolPolicy is an invocation permission grant, not part of ProviderSelection identity.
|
|
93
|
+
- Invocation Directory and Tool Workspace are distinct permission concepts, but not separate public paths in current runtime model.
|
|
94
|
+
- ProviderSelection is the canonical single-candidate selection value for one runtime invocation.
|
|
95
|
+
- Runtime Compatibility Aliases are not Runtime Public Surface promises and may be removed before release without tailored migration behavior.
|
|
96
|
+
- Lifecycle-specific runtime execution adapter names are canonical public spellings even when they share adapter protocols.
|
|
97
|
+
- Live Provider Smoke Tests are opt-in maintainer tooling, not default automated tests or Runtime Public Surface additions.
|
|
98
|
+
- Live Provider Smoke Tests prove real provider invocation through Runtime Public Surface; they do not judge answer quality, tool usefulness, or strict instruction following.
|
|
99
|
+
- Live Smoke Defaults prefer the cheapest runtime-supported provider tuple over stronger models; smoke prompts must remain simple enough for those defaults.
|
|
100
|
+
|
|
101
|
+
## Flagged Ambiguities
|
|
102
|
+
|
|
103
|
+
- "Resumable": use **Start Session Run** and **Resume Session Run** for lifecycle APIs; keep resumable only for provider capabilities or lower-level planning.
|
|
104
|
+
- "One-shot": use **Ephemeral Run** for execution without provider-session continuity.
|
|
105
|
+
- "stage", "StageSelection", "StageOverride", and "stage chain": use **ProviderSelection** and the `provider_selection` request field for one runtime invocation, or **Consumer Fallback** for consuming-project retry orchestration.
|
|
106
|
+
- "OpenAI" in issue #93 meant **OpenCode**.
|
|
107
|
+
- "Claude API key": use **ClaudeCodeOAuthToken**, not generic Anthropic API key.
|
|
108
|
+
- "Adapter author": custom provider services are not supported runtime extension point.
|
|
109
|
+
- "worktree": use **Invocation Directory** for command location and **Tool Workspace** for tool access to that directory.
|
|
110
|
+
- `ToolAccess`: use **ToolPolicy**.
|
|
111
|
+
- `ToolPolicyProfile`: use **ToolPolicy** in consumer-facing language; provider flag profiles are internal implementation details.
|
|
112
|
+
- `InvocationRole`, `UsageLimitScope`, and `SessionNamespace`: caller labels and grouping policy belong outside the Runtime Consumer Surface.
|
|
113
|
+
- `ToolPolicy.RESTRICTED`, `ToolPolicy.PARTIAL`, and `ToolPolicy.FULL`: use `ToolPolicy.INSPECT_ONLY`, `ToolPolicy.NO_FILE_MUTATION`, and `ToolPolicy.UNRESTRICTED`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Johannes Kutsch
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ruhken-agent-runtime
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Reusable agent runtime package boundary
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest; extra == "dev"
|
|
15
|
+
Requires-Dist: mypy; extra == "dev"
|
|
16
|
+
Requires-Dist: ruff; extra == "dev"
|
|
17
|
+
Requires-Dist: setuptools>=68; extra == "dev"
|
|
18
|
+
Requires-Dist: setuptools-scm>=8; extra == "dev"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# agent_runtime
|
|
22
|
+
|
|
23
|
+
`agent_runtime` is the reusable Python runtime package for executing already-prepared agent work through built-in provider integrations.
|
|
24
|
+
|
|
25
|
+
Install the distribution as `ruhken-agent-runtime` and import it as `agent_runtime`. Python 3.11 or newer is required.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install ruhken-agent-runtime
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The accepted runtime direction is to ship Claude, Codex, and OpenCode execution inside this package. Consuming projects select a built-in provider, model, effort, credentials, tool policy, invocation directory, and session lifecycle through runtime call arguments; they do not construct provider services, service registries, command builders, provider-session adapters, or provider event parsers.
|
|
32
|
+
|
|
33
|
+
For complete target signatures and invariants, see [the public API reference](docs/public-api.md). For the portable continuation decision, see [ADR 0010](docs/adr/0010-portable-continuations.md).
|
|
34
|
+
|
|
35
|
+
Only the documented import paths are stable. Internal runtime modules may be reorganized as the implementation is split, but ordinary consumers should continue importing from `agent_runtime` and `agent_runtime.runtime`.
|
|
36
|
+
|
|
37
|
+
## Consumer Integration
|
|
38
|
+
|
|
39
|
+
Ordinary consumers should use a caller-owned `RuntimeClient` and the small package vocabulary such as `StageSelection`, `ToolPolicy`, `ProviderAuth`, and `Continuation`.
|
|
40
|
+
|
|
41
|
+
The runtime executes prompts and returns data. Callers own persistence for continuations, invocation records, workflow correlation, durable logs, and any usage-limit grouping policy.
|
|
42
|
+
|
|
43
|
+
Every run receives an `invocation_dir`, the host directory where the provider command is launched. Tool policy is explicit: `ToolPolicy.NONE` forbids provider tools, `ToolPolicy.INSPECT_ONLY` allows workspace inspection, `ToolPolicy.NO_FILE_MUTATION` permits tools while forbidding direct workspace file mutation, and `ToolPolicy.UNRESTRICTED` adds no runtime restriction beyond provider defaults.
|
|
44
|
+
|
|
45
|
+
### Ephemeral Execution
|
|
46
|
+
|
|
47
|
+
Use ephemeral execution for an already-rendered prompt when the runtime should not prepare provider-session continuity. Tool policy is explicit; `ToolPolicy.NONE` is the closed no-tools value.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from pathlib import Path
|
|
51
|
+
|
|
52
|
+
from agent_runtime import ProviderAuth, StageSelection, ToolPolicy
|
|
53
|
+
from agent_runtime.runtime import EphemeralRunRequest, RuntimeClient
|
|
54
|
+
|
|
55
|
+
runtime = RuntimeClient()
|
|
56
|
+
|
|
57
|
+
result = await runtime.run_ephemeral(
|
|
58
|
+
EphemeralRunRequest(
|
|
59
|
+
prompt=rendered_prompt,
|
|
60
|
+
invocation_dir=Path("."),
|
|
61
|
+
stage=StageSelection(
|
|
62
|
+
service="claude",
|
|
63
|
+
model="sonnet",
|
|
64
|
+
effort="medium",
|
|
65
|
+
),
|
|
66
|
+
provider_auth=ProviderAuth(
|
|
67
|
+
claude_code_oauth_token=claude_code_oauth_token,
|
|
68
|
+
),
|
|
69
|
+
tool_policy=ToolPolicy.NONE,
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
if result.kind == "completed":
|
|
74
|
+
print(result.output)
|
|
75
|
+
print(result.usage)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Ephemeral execution does not return a continuation and does not require session storage inputs.
|
|
79
|
+
|
|
80
|
+
### New-Session Execution
|
|
81
|
+
|
|
82
|
+
Use new-session execution when the runtime should preserve provider transcript continuity and return an opaque portable `Continuation` for later calls. A completed session-backed run always returns output text and a meaningful continuation.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from pathlib import Path
|
|
86
|
+
|
|
87
|
+
from agent_runtime import ProviderAuth, StageSelection, ToolPolicy
|
|
88
|
+
from agent_runtime.runtime import NewSessionRunRequest, RuntimeClient
|
|
89
|
+
|
|
90
|
+
runtime = RuntimeClient()
|
|
91
|
+
|
|
92
|
+
result = await runtime.run_new_session(
|
|
93
|
+
NewSessionRunRequest(
|
|
94
|
+
prompt=rendered_prompt,
|
|
95
|
+
invocation_dir=Path("."),
|
|
96
|
+
stage=StageSelection(
|
|
97
|
+
service="opencode",
|
|
98
|
+
model="github-copilot/gpt-5.1-codex",
|
|
99
|
+
effort="medium",
|
|
100
|
+
),
|
|
101
|
+
provider_auth=ProviderAuth(opencode_api_key=opencode_api_key),
|
|
102
|
+
tool_policy=ToolPolicy.NO_FILE_MUTATION,
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
if result.kind == "completed":
|
|
107
|
+
print(result.output)
|
|
108
|
+
continuation = result.result.continuation
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Callers persist the continuation object wherever they want. The continuation is a resume token, not a public schema for provider state, display data, or policy decisions.
|
|
112
|
+
|
|
113
|
+
### Resumed-Session Execution
|
|
114
|
+
|
|
115
|
+
Use resumed-session execution to continue an existing provider-session continuity chain. The continuation fixes the selected service and tool policy. Resumed execution does not perform fallback and only allows model or effort overrides.
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from pathlib import Path
|
|
119
|
+
|
|
120
|
+
from agent_runtime import ProviderAuth
|
|
121
|
+
from agent_runtime.runtime import ResumedSessionRunRequest, RuntimeClient
|
|
122
|
+
|
|
123
|
+
runtime = RuntimeClient()
|
|
124
|
+
|
|
125
|
+
result = await runtime.run_resumed_session(
|
|
126
|
+
ResumedSessionRunRequest(
|
|
127
|
+
prompt=rendered_prompt,
|
|
128
|
+
invocation_dir=Path("."),
|
|
129
|
+
continuation=continuation,
|
|
130
|
+
provider_auth=ProviderAuth(opencode_api_key=opencode_api_key),
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
if result.kind == "completed":
|
|
135
|
+
print(result.output)
|
|
136
|
+
continuation = result.result.continuation
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Invocation Records
|
|
140
|
+
|
|
141
|
+
The runtime may return structured invocation records for callers that want traces. Callers decide if, where, and how to persist those records. The runtime does not own durable log file names, directories, retention, or cleanup policy.
|
|
142
|
+
|
|
143
|
+
### Runtime Outcomes
|
|
144
|
+
|
|
145
|
+
Lifecycle entrypoints return `RuntimeOutcome`. Completed work has `kind == "completed"` and carries the completed result on `result.result`. When a provider reports usage, the outcome also carries `usage` with input tokens, output tokens, cache-read input tokens, cache-creation input tokens, optional cost, and optional provider duration.
|
|
146
|
+
|
|
147
|
+
Expected interruptions are normal outcomes: `usage_limited`, `no_service_available`, `cancelled`, `timed_out`, and `retryable_provider_failure`. Session-backed interruption outcomes may carry `continuation` only when provider progress made resume meaningful, and they always report `invocation_progress`.
|
|
148
|
+
|
|
149
|
+
Usage-limit outcomes expose provider and service facts such as service name, account label, reset time, invocation progress, provider usage, and continuation state. Caller workflow grouping and retry/sleep policy stay outside the runtime package.
|
|
150
|
+
|
|
151
|
+
Exceptional failures remain errors: malformed runtime inputs, credential problems, hard provider failures, adapter/protocol bugs, unclassified provider failures, and unexpected exceptions.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# agent_runtime
|
|
2
|
+
|
|
3
|
+
`agent_runtime` is the reusable Python runtime package for executing already-prepared agent work through built-in provider integrations.
|
|
4
|
+
|
|
5
|
+
Install the distribution as `ruhken-agent-runtime` and import it as `agent_runtime`. Python 3.11 or newer is required.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install ruhken-agent-runtime
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The accepted runtime direction is to ship Claude, Codex, and OpenCode execution inside this package. Consuming projects select a built-in provider, model, effort, credentials, tool policy, invocation directory, and session lifecycle through runtime call arguments; they do not construct provider services, service registries, command builders, provider-session adapters, or provider event parsers.
|
|
12
|
+
|
|
13
|
+
For complete target signatures and invariants, see [the public API reference](docs/public-api.md). For the portable continuation decision, see [ADR 0010](docs/adr/0010-portable-continuations.md).
|
|
14
|
+
|
|
15
|
+
Only the documented import paths are stable. Internal runtime modules may be reorganized as the implementation is split, but ordinary consumers should continue importing from `agent_runtime` and `agent_runtime.runtime`.
|
|
16
|
+
|
|
17
|
+
## Consumer Integration
|
|
18
|
+
|
|
19
|
+
Ordinary consumers should use a caller-owned `RuntimeClient` and the small package vocabulary such as `StageSelection`, `ToolPolicy`, `ProviderAuth`, and `Continuation`.
|
|
20
|
+
|
|
21
|
+
The runtime executes prompts and returns data. Callers own persistence for continuations, invocation records, workflow correlation, durable logs, and any usage-limit grouping policy.
|
|
22
|
+
|
|
23
|
+
Every run receives an `invocation_dir`, the host directory where the provider command is launched. Tool policy is explicit: `ToolPolicy.NONE` forbids provider tools, `ToolPolicy.INSPECT_ONLY` allows workspace inspection, `ToolPolicy.NO_FILE_MUTATION` permits tools while forbidding direct workspace file mutation, and `ToolPolicy.UNRESTRICTED` adds no runtime restriction beyond provider defaults.
|
|
24
|
+
|
|
25
|
+
### Ephemeral Execution
|
|
26
|
+
|
|
27
|
+
Use ephemeral execution for an already-rendered prompt when the runtime should not prepare provider-session continuity. Tool policy is explicit; `ToolPolicy.NONE` is the closed no-tools value.
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
|
|
32
|
+
from agent_runtime import ProviderAuth, StageSelection, ToolPolicy
|
|
33
|
+
from agent_runtime.runtime import EphemeralRunRequest, RuntimeClient
|
|
34
|
+
|
|
35
|
+
runtime = RuntimeClient()
|
|
36
|
+
|
|
37
|
+
result = await runtime.run_ephemeral(
|
|
38
|
+
EphemeralRunRequest(
|
|
39
|
+
prompt=rendered_prompt,
|
|
40
|
+
invocation_dir=Path("."),
|
|
41
|
+
stage=StageSelection(
|
|
42
|
+
service="claude",
|
|
43
|
+
model="sonnet",
|
|
44
|
+
effort="medium",
|
|
45
|
+
),
|
|
46
|
+
provider_auth=ProviderAuth(
|
|
47
|
+
claude_code_oauth_token=claude_code_oauth_token,
|
|
48
|
+
),
|
|
49
|
+
tool_policy=ToolPolicy.NONE,
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if result.kind == "completed":
|
|
54
|
+
print(result.output)
|
|
55
|
+
print(result.usage)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Ephemeral execution does not return a continuation and does not require session storage inputs.
|
|
59
|
+
|
|
60
|
+
### New-Session Execution
|
|
61
|
+
|
|
62
|
+
Use new-session execution when the runtime should preserve provider transcript continuity and return an opaque portable `Continuation` for later calls. A completed session-backed run always returns output text and a meaningful continuation.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from pathlib import Path
|
|
66
|
+
|
|
67
|
+
from agent_runtime import ProviderAuth, StageSelection, ToolPolicy
|
|
68
|
+
from agent_runtime.runtime import NewSessionRunRequest, RuntimeClient
|
|
69
|
+
|
|
70
|
+
runtime = RuntimeClient()
|
|
71
|
+
|
|
72
|
+
result = await runtime.run_new_session(
|
|
73
|
+
NewSessionRunRequest(
|
|
74
|
+
prompt=rendered_prompt,
|
|
75
|
+
invocation_dir=Path("."),
|
|
76
|
+
stage=StageSelection(
|
|
77
|
+
service="opencode",
|
|
78
|
+
model="github-copilot/gpt-5.1-codex",
|
|
79
|
+
effort="medium",
|
|
80
|
+
),
|
|
81
|
+
provider_auth=ProviderAuth(opencode_api_key=opencode_api_key),
|
|
82
|
+
tool_policy=ToolPolicy.NO_FILE_MUTATION,
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
if result.kind == "completed":
|
|
87
|
+
print(result.output)
|
|
88
|
+
continuation = result.result.continuation
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Callers persist the continuation object wherever they want. The continuation is a resume token, not a public schema for provider state, display data, or policy decisions.
|
|
92
|
+
|
|
93
|
+
### Resumed-Session Execution
|
|
94
|
+
|
|
95
|
+
Use resumed-session execution to continue an existing provider-session continuity chain. The continuation fixes the selected service and tool policy. Resumed execution does not perform fallback and only allows model or effort overrides.
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from pathlib import Path
|
|
99
|
+
|
|
100
|
+
from agent_runtime import ProviderAuth
|
|
101
|
+
from agent_runtime.runtime import ResumedSessionRunRequest, RuntimeClient
|
|
102
|
+
|
|
103
|
+
runtime = RuntimeClient()
|
|
104
|
+
|
|
105
|
+
result = await runtime.run_resumed_session(
|
|
106
|
+
ResumedSessionRunRequest(
|
|
107
|
+
prompt=rendered_prompt,
|
|
108
|
+
invocation_dir=Path("."),
|
|
109
|
+
continuation=continuation,
|
|
110
|
+
provider_auth=ProviderAuth(opencode_api_key=opencode_api_key),
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
if result.kind == "completed":
|
|
115
|
+
print(result.output)
|
|
116
|
+
continuation = result.result.continuation
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Invocation Records
|
|
120
|
+
|
|
121
|
+
The runtime may return structured invocation records for callers that want traces. Callers decide if, where, and how to persist those records. The runtime does not own durable log file names, directories, retention, or cleanup policy.
|
|
122
|
+
|
|
123
|
+
### Runtime Outcomes
|
|
124
|
+
|
|
125
|
+
Lifecycle entrypoints return `RuntimeOutcome`. Completed work has `kind == "completed"` and carries the completed result on `result.result`. When a provider reports usage, the outcome also carries `usage` with input tokens, output tokens, cache-read input tokens, cache-creation input tokens, optional cost, and optional provider duration.
|
|
126
|
+
|
|
127
|
+
Expected interruptions are normal outcomes: `usage_limited`, `no_service_available`, `cancelled`, `timed_out`, and `retryable_provider_failure`. Session-backed interruption outcomes may carry `continuation` only when provider progress made resume meaningful, and they always report `invocation_progress`.
|
|
128
|
+
|
|
129
|
+
Usage-limit outcomes expose provider and service facts such as service name, account label, reset time, invocation progress, provider usage, and continuation state. Caller workflow grouping and retry/sleep policy stay outside the runtime package.
|
|
130
|
+
|
|
131
|
+
Exceptional failures remain errors: malformed runtime inputs, credential problems, hard provider failures, adapter/protocol bugs, unclassified provider failures, and unexpected exceptions.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Runtime ownership migration
|
|
2
|
+
|
|
3
|
+
The reusable runtime layer owns shared execution contracts and lifecycle behavior: service selection, stage-chain resolution, session planning, provider state contracts, work invocation, result/error vocabulary, and importable runtime modules.
|
|
4
|
+
|
|
5
|
+
The runtime package is not the application. It receives prepared inputs from an adapter boundary and returns execution results or runtime-owned failures. Application prompt rendering, command wiring, issue orchestration, UI, and presentation stay outside the package.
|
|
6
|
+
|
|
7
|
+
## Decision
|
|
8
|
+
|
|
9
|
+
- Make the runtime package the owner of reusable execution contracts and lifecycle behavior.
|
|
10
|
+
- Keep the public surface narrow and adapter-driven.
|
|
11
|
+
- Require runtime importability without application modules.
|
|
12
|
+
- Keep application orchestration out of the runtime distribution.
|
|
13
|
+
- Keep provider-specific policy behind runtime adapter contracts.
|
|
14
|
+
- Require the built artifact to match the editable-source boundary.
|
|
15
|
+
|
|
16
|
+
## Consequences
|
|
17
|
+
|
|
18
|
+
- Core behavior can be reused without importing a consuming application.
|
|
19
|
+
- Application code remains an adapter around runtime-owned contracts.
|
|
20
|
+
- Boundary regressions show up as package import failures and artifact tests.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Runtime compatibility artifact policy
|
|
2
|
+
|
|
3
|
+
Status: Partially refined by [0006 - Built-in provider-only runtime](0006-built-in-provider-only-runtime.md) for built-in Claude, Codex, and OpenCode integration behavior.
|
|
4
|
+
|
|
5
|
+
The runtime package should expose neutral public vocabulary. Compatibility names, legacy paths, or older record shapes may exist only as adapter-layer shims when needed to preserve existing behavior.
|
|
6
|
+
|
|
7
|
+
## Decision
|
|
8
|
+
|
|
9
|
+
- Use neutral public names for runtime-owned errors, session paths, and log records.
|
|
10
|
+
- Require caller-supplied paths and directories where filesystem layout matters.
|
|
11
|
+
- Treat compatibility-specific vocabulary as a transitional adapter concern.
|
|
12
|
+
- Keep supported Python version metadata and classifiers aligned with verified release versions.
|
|
13
|
+
- Do not let provider migration artifacts define public runtime vocabulary.
|
|
14
|
+
- Keep install-time dependencies absent unless a built-in provider dependency is deliberately shipped as runtime behavior; development dependencies stay outside the runtime dependency set.
|
|
15
|
+
|
|
16
|
+
## Consequences
|
|
17
|
+
|
|
18
|
+
- The runtime package can be adopted without inheriting application-specific naming.
|
|
19
|
+
- Layout decisions stay at the adapter boundary instead of becoming hidden defaults.
|
|
20
|
+
- Tests can assert that neutral public contracts remain the default.
|
|
21
|
+
- Consumers can rely on package metadata to reflect supported Python versions.
|
|
22
|
+
- Consumers do not inherit provider migration or development dependency trees accidentally.
|