nextloop 0.2.0rc1__tar.gz → 0.4.0rc1__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.
- nextloop-0.4.0rc1/MANIFEST.in +4 -0
- {nextloop-0.2.0rc1/src/nextloop.egg-info → nextloop-0.4.0rc1}/PKG-INFO +61 -7
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/README.md +60 -6
- nextloop-0.4.0rc1/docs/adr/0001-embeddable-agent-loop.md +48 -0
- nextloop-0.4.0rc1/docs/adr/0002-dsh-aligned-agent-loop.md +42 -0
- nextloop-0.4.0rc1/docs/adr/0003-python-and-centralized-contracts.md +56 -0
- nextloop-0.4.0rc1/docs/architecture/agent-loop-capability-review.md +147 -0
- nextloop-0.4.0rc1/docs/architecture/development-plan.md +47 -0
- nextloop-0.4.0rc1/docs/architecture/discussion-roadmap.md +53 -0
- nextloop-0.4.0rc1/docs/architecture/feature-worklist.md +30 -0
- nextloop-0.4.0rc1/docs/architecture/requirements.md +30 -0
- nextloop-0.4.0rc1/docs/design/agent-loop.md +162 -0
- nextloop-0.4.0rc1/docs/design/context-builder.md +139 -0
- nextloop-0.4.0rc1/docs/design/harness.md +120 -0
- nextloop-0.4.0rc1/docs/design/loop-interface.md +88 -0
- nextloop-0.4.0rc1/docs/design/react-protocol.md +53 -0
- nextloop-0.4.0rc1/docs/design/skills.md +105 -0
- nextloop-0.4.0rc1/docs/design/verification-matrix.md +93 -0
- nextloop-0.4.0rc1/docs/research/2026-11-02-dsh-primary-sources.md +144 -0
- nextloop-0.4.0rc1/docs/research/2026-11-02-loop-evidence-notes.md +122 -0
- nextloop-0.4.0rc1/docs/research/2026-11-03-hermes-turn-control.md +96 -0
- nextloop-0.4.0rc1/docs/research/2026-11-03-tool-batch-failures.md +109 -0
- nextloop-0.4.0rc1/docs/research/2026-11-03-tool-call-validation.md +69 -0
- nextloop-0.4.0rc1/docs/research/2026-11-03-yomi-turn-control.md +5 -0
- nextloop-0.4.0rc1/docs/research/2026-11-06-open-source-agent-loops.md +204 -0
- nextloop-0.4.0rc1/docs/research/2026-11-06-react-tool-event-recovery.md +292 -0
- nextloop-0.4.0rc1/examples/basic.py +64 -0
- nextloop-0.4.0rc1/examples/harness-skills/echo/SKILL.md +7 -0
- nextloop-0.4.0rc1/examples/harness.toml +29 -0
- nextloop-0.4.0rc1/examples/live_smoke.py +571 -0
- nextloop-0.4.0rc1/examples/python_tools.py +20 -0
- nextloop-0.4.0rc1/examples/skills/coding/SKILL.md +13 -0
- nextloop-0.4.0rc1/examples/skills_demo.py +16 -0
- nextloop-0.4.0rc1/examples/workers/cpp_worker.cpp +111 -0
- nextloop-0.4.0rc1/examples/workers/python_worker.py +153 -0
- nextloop-0.4.0rc1/examples/workers/rust_worker.rs +103 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/pyproject.toml +4 -1
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/__init__.py +59 -0
- nextloop-0.4.0rc1/src/nextloop/adapters/__init__.py +14 -0
- nextloop-0.4.0rc1/src/nextloop/adapters/observing.py +236 -0
- nextloop-0.4.0rc1/src/nextloop/cli.py +156 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/contracts.py +181 -3
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/driver.py +2 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/events/__init__.py +3 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/events/outcome.py +36 -7
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/events/repair.py +5 -3
- nextloop-0.4.0rc1/src/nextloop/events/trace.py +351 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/execute/batch.py +27 -11
- nextloop-0.4.0rc1/src/nextloop/execute/cleanup.py +17 -0
- nextloop-0.4.0rc1/src/nextloop/execute/composite.py +176 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/execute/model.py +84 -13
- nextloop-0.4.0rc1/src/nextloop/execute/stdio.py +499 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/execute/tools.py +38 -34
- nextloop-0.4.0rc1/src/nextloop/harness.py +574 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/skills.py +13 -11
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1/src/nextloop.egg-info}/PKG-INFO +61 -7
- nextloop-0.4.0rc1/src/nextloop.egg-info/SOURCES.txt +86 -0
- nextloop-0.4.0rc1/src/nextloop.egg-info/entry_points.txt +2 -0
- nextloop-0.4.0rc1/tests/test_aggregate_close.py +109 -0
- nextloop-0.4.0rc1/tests/test_cli.py +60 -0
- nextloop-0.4.0rc1/tests/test_harness.py +260 -0
- nextloop-0.4.0rc1/tests/test_observability.py +800 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/tests/test_skills.py +10 -0
- nextloop-0.4.0rc1/tests/test_stdio.py +114 -0
- nextloop-0.4.0rc1/tests/test_stdio_cleanup.py +203 -0
- nextloop-0.4.0rc1/tests/test_stdio_frames.py +78 -0
- nextloop-0.4.0rc1/tests/test_stdio_safety.py +267 -0
- nextloop-0.4.0rc1/tests/test_worker_conformance.py +171 -0
- nextloop-0.2.0rc1/src/nextloop/adapters/__init__.py +0 -6
- nextloop-0.2.0rc1/src/nextloop.egg-info/SOURCES.txt +0 -35
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/LICENSE +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/setup.cfg +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/adapters/_sse.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/adapters/anthropic.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/adapters/memory.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/adapters/openai.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/adapters/sqlite.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/events/project.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/events/response.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/execute/__init__.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/loop.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop/py.typed +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop.egg-info/dependency_links.txt +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop.egg-info/requires.txt +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/src/nextloop.egg-info/top_level.txt +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/tests/test_events.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/tests/test_failures.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/tests/test_loop.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/tests/test_providers.py +0 -0
- {nextloop-0.2.0rc1 → nextloop-0.4.0rc1}/tests/test_stores.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nextloop
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0rc1
|
|
4
4
|
Summary: An embeddable AgentLoop with explicit event, tool, recovery, and delivery semantics
|
|
5
5
|
Author-email: 12bitsD <bis12@163.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -28,14 +28,18 @@ Dynamic: license-file
|
|
|
28
28
|
|
|
29
29
|
# nextloop
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
**Small core. Serious runtime semantics.**
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
nextloop is an embeddable Python AgentLoop for developers who want to build their own agent runtime — not inherit a heavyweight framework. Deterministic ReAct execution, append-only history, explicit crash recovery, typed Tools, and committed-event observability, all in a package you can actually read.
|
|
34
|
+
|
|
35
|
+
**Your agent, your rules. No magic, no black box.**
|
|
36
|
+
|
|
37
|
+
Current version: **0.4.0rc1**.
|
|
34
38
|
|
|
35
39
|
## Install
|
|
36
40
|
|
|
37
41
|
```bash
|
|
38
|
-
python -m pip install nextloop==0.
|
|
42
|
+
python -m pip install nextloop==0.4.0rc1
|
|
39
43
|
```
|
|
40
44
|
|
|
41
45
|
For local development:
|
|
@@ -45,7 +49,17 @@ uv venv --python 3.11 .venv
|
|
|
45
49
|
uv pip install --python .venv/bin/python -e '.[dev]'
|
|
46
50
|
```
|
|
47
51
|
|
|
48
|
-
##
|
|
52
|
+
## Why nextloop
|
|
53
|
+
|
|
54
|
+
- **Execution you can reason about.** DSH-aligned Session/Turn/Step/attempt coordinates, writer fencing, and append-only Trajectory instead of implicit runner state.
|
|
55
|
+
- **Crash recovery without blind replay.** Resource locks, uncertain outcomes, crash closers, and delivery-only recovery tell you what is known, what is unknown, and what must not run twice.
|
|
56
|
+
- **Tools without framework lock-in.** Register Python functions directly, or run persistent Rust and C++ workers over stdio JSON-RPC. Schema validation, parallel calls, and exclusive barriers are built in.
|
|
57
|
+
- **Observability from committed facts.** Structured Model/Tool/Turn traces, asynchronous Exporters, and Session history. No second execution path and no telemetry-driven control flow.
|
|
58
|
+
- **Small, explicit integration.** Assemble Providers, Stores, Tools, and Skills with `harness.toml`, or keep everything in Python. OpenAI-compatible and Anthropic Providers are included.
|
|
59
|
+
|
|
60
|
+
It is a library, not an HTTP service, product bot, Router, EventBus, or multi-agent framework. **The Loop stays in your application; the decisions stay with you.**
|
|
61
|
+
|
|
62
|
+
## Under the hood
|
|
49
63
|
|
|
50
64
|
- DSH-aligned Session/Turn/Step execution with 4D integer coordinates and writer fencing.
|
|
51
65
|
- Append-only Trajectory and O(Δ) `surface_op` watermark projection.
|
|
@@ -56,8 +70,9 @@ uv pip install --python .venv/bin/python -e '.[dev]'
|
|
|
56
70
|
- SQLite and in-memory EventStores, crash closers, and delivery-only recovery.
|
|
57
71
|
- OpenAI-compatible and Anthropic streaming Provider adapters.
|
|
58
72
|
- Directory-based `SkillRegistry` for progressive, on-demand `SKILL.md` loading with dependency and version validation.
|
|
59
|
-
|
|
60
|
-
|
|
73
|
+
- Strict `harness.toml` assembly, Python `module:register`, and persistent Python/Rust/C++ stdio workers.
|
|
74
|
+
- Offline `nextloop` CLI for configuration, worker, Tool, and Skill diagnostics.
|
|
75
|
+
- Committed-event observability with Model/Tool/Turn DTOs, asynchronous Exporters, and Session history.
|
|
61
76
|
|
|
62
77
|
## Public API
|
|
63
78
|
|
|
@@ -70,6 +85,44 @@ AgentLoop.recover(session_id, store, delivery) -> RecoveryOutcome
|
|
|
70
85
|
|
|
71
86
|
The only four Adapter protocols are `EventStore`, `ModelProvider`, `ToolRuntime`, and `DeliveryOwner`. Context projection and Compaction are built in and configured through `LoopConfig`.
|
|
72
87
|
|
|
88
|
+
`Harness.load("harness.toml")` assembles those adapters without changing the Loop. Use `await harness.check()` for offline validation and `await harness.run("input")` for a model-backed Turn. See [Harness and extension interface](docs/design/harness.md) for the strict TOML schema, stdio protocol, lifecycle rules, and CLI.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
nextloop check examples/harness.toml
|
|
92
|
+
nextloop tools call python_worker__echo '{"text":"hello"}' examples/harness.toml
|
|
93
|
+
nextloop skills view echo-guide examples/harness.toml
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The example Python module is found when running from a source checkout with `PYTHONPATH=examples`. Examples and reference workers ship in the repository and sdist; wheels contain the library and CLI. No API key is needed for these diagnostic commands.
|
|
97
|
+
|
|
98
|
+
## Observability
|
|
99
|
+
|
|
100
|
+
Enable committed-event traces with a built-in stdout Exporter:
|
|
101
|
+
|
|
102
|
+
```toml
|
|
103
|
+
[trace]
|
|
104
|
+
exporter = "stdout"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Or pass a sync/async function directly:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
harness = Harness.load("harness.toml", exporter=my_exporter)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Use `module.path:function` in TOML for a custom Exporter. No Exporter is enabled by default. Every Exporter receives `ModelCallTrace`, `ToolCallTrace`, or `TurnTrace`; exports are queued asynchronously and flushed by `await harness.close()`. Close has a bounded wait, but it cannot forcibly stop an already running synchronous Exporter thread; late residual calls are reported through `on_error`.
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
turn = await harness.get_turn(1)
|
|
117
|
+
if turn is not None:
|
|
118
|
+
for tool in turn.tool_calls:
|
|
119
|
+
print(tool.name, tool.result, tool.duration_ms)
|
|
120
|
+
|
|
121
|
+
history = await harness.history(from_turn=1, to_turn=10)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
History works with memory and SQLite Stores even when no Exporter is configured.
|
|
125
|
+
|
|
73
126
|
`ToolRegistry` is the built-in `ToolRuntime` implementation:
|
|
74
127
|
|
|
75
128
|
```python
|
|
@@ -143,6 +196,7 @@ Current limits:
|
|
|
143
196
|
|
|
144
197
|
- [AgentLoop design](docs/design/agent-loop.md)
|
|
145
198
|
- [Public interface](docs/design/loop-interface.md)
|
|
199
|
+
- [Harness and extension interface](docs/design/harness.md)
|
|
146
200
|
- [ReAct protocol](docs/design/react-protocol.md)
|
|
147
201
|
- [Directory-based SkillRegistry](docs/design/skills.md)
|
|
148
202
|
- [Verification matrix](docs/design/verification-matrix.md)
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
# nextloop
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Small core. Serious runtime semantics.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
nextloop is an embeddable Python AgentLoop for developers who want to build their own agent runtime — not inherit a heavyweight framework. Deterministic ReAct execution, append-only history, explicit crash recovery, typed Tools, and committed-event observability, all in a package you can actually read.
|
|
6
|
+
|
|
7
|
+
**Your agent, your rules. No magic, no black box.**
|
|
8
|
+
|
|
9
|
+
Current version: **0.4.0rc1**.
|
|
6
10
|
|
|
7
11
|
## Install
|
|
8
12
|
|
|
9
13
|
```bash
|
|
10
|
-
python -m pip install nextloop==0.
|
|
14
|
+
python -m pip install nextloop==0.4.0rc1
|
|
11
15
|
```
|
|
12
16
|
|
|
13
17
|
For local development:
|
|
@@ -17,7 +21,17 @@ uv venv --python 3.11 .venv
|
|
|
17
21
|
uv pip install --python .venv/bin/python -e '.[dev]'
|
|
18
22
|
```
|
|
19
23
|
|
|
20
|
-
##
|
|
24
|
+
## Why nextloop
|
|
25
|
+
|
|
26
|
+
- **Execution you can reason about.** DSH-aligned Session/Turn/Step/attempt coordinates, writer fencing, and append-only Trajectory instead of implicit runner state.
|
|
27
|
+
- **Crash recovery without blind replay.** Resource locks, uncertain outcomes, crash closers, and delivery-only recovery tell you what is known, what is unknown, and what must not run twice.
|
|
28
|
+
- **Tools without framework lock-in.** Register Python functions directly, or run persistent Rust and C++ workers over stdio JSON-RPC. Schema validation, parallel calls, and exclusive barriers are built in.
|
|
29
|
+
- **Observability from committed facts.** Structured Model/Tool/Turn traces, asynchronous Exporters, and Session history. No second execution path and no telemetry-driven control flow.
|
|
30
|
+
- **Small, explicit integration.** Assemble Providers, Stores, Tools, and Skills with `harness.toml`, or keep everything in Python. OpenAI-compatible and Anthropic Providers are included.
|
|
31
|
+
|
|
32
|
+
It is a library, not an HTTP service, product bot, Router, EventBus, or multi-agent framework. **The Loop stays in your application; the decisions stay with you.**
|
|
33
|
+
|
|
34
|
+
## Under the hood
|
|
21
35
|
|
|
22
36
|
- DSH-aligned Session/Turn/Step execution with 4D integer coordinates and writer fencing.
|
|
23
37
|
- Append-only Trajectory and O(Δ) `surface_op` watermark projection.
|
|
@@ -28,8 +42,9 @@ uv pip install --python .venv/bin/python -e '.[dev]'
|
|
|
28
42
|
- SQLite and in-memory EventStores, crash closers, and delivery-only recovery.
|
|
29
43
|
- OpenAI-compatible and Anthropic streaming Provider adapters.
|
|
30
44
|
- Directory-based `SkillRegistry` for progressive, on-demand `SKILL.md` loading with dependency and version validation.
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
- Strict `harness.toml` assembly, Python `module:register`, and persistent Python/Rust/C++ stdio workers.
|
|
46
|
+
- Offline `nextloop` CLI for configuration, worker, Tool, and Skill diagnostics.
|
|
47
|
+
- Committed-event observability with Model/Tool/Turn DTOs, asynchronous Exporters, and Session history.
|
|
33
48
|
|
|
34
49
|
## Public API
|
|
35
50
|
|
|
@@ -42,6 +57,44 @@ AgentLoop.recover(session_id, store, delivery) -> RecoveryOutcome
|
|
|
42
57
|
|
|
43
58
|
The only four Adapter protocols are `EventStore`, `ModelProvider`, `ToolRuntime`, and `DeliveryOwner`. Context projection and Compaction are built in and configured through `LoopConfig`.
|
|
44
59
|
|
|
60
|
+
`Harness.load("harness.toml")` assembles those adapters without changing the Loop. Use `await harness.check()` for offline validation and `await harness.run("input")` for a model-backed Turn. See [Harness and extension interface](docs/design/harness.md) for the strict TOML schema, stdio protocol, lifecycle rules, and CLI.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
nextloop check examples/harness.toml
|
|
64
|
+
nextloop tools call python_worker__echo '{"text":"hello"}' examples/harness.toml
|
|
65
|
+
nextloop skills view echo-guide examples/harness.toml
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The example Python module is found when running from a source checkout with `PYTHONPATH=examples`. Examples and reference workers ship in the repository and sdist; wheels contain the library and CLI. No API key is needed for these diagnostic commands.
|
|
69
|
+
|
|
70
|
+
## Observability
|
|
71
|
+
|
|
72
|
+
Enable committed-event traces with a built-in stdout Exporter:
|
|
73
|
+
|
|
74
|
+
```toml
|
|
75
|
+
[trace]
|
|
76
|
+
exporter = "stdout"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or pass a sync/async function directly:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
harness = Harness.load("harness.toml", exporter=my_exporter)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Use `module.path:function` in TOML for a custom Exporter. No Exporter is enabled by default. Every Exporter receives `ModelCallTrace`, `ToolCallTrace`, or `TurnTrace`; exports are queued asynchronously and flushed by `await harness.close()`. Close has a bounded wait, but it cannot forcibly stop an already running synchronous Exporter thread; late residual calls are reported through `on_error`.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
turn = await harness.get_turn(1)
|
|
89
|
+
if turn is not None:
|
|
90
|
+
for tool in turn.tool_calls:
|
|
91
|
+
print(tool.name, tool.result, tool.duration_ms)
|
|
92
|
+
|
|
93
|
+
history = await harness.history(from_turn=1, to_turn=10)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
History works with memory and SQLite Stores even when no Exporter is configured.
|
|
97
|
+
|
|
45
98
|
`ToolRegistry` is the built-in `ToolRuntime` implementation:
|
|
46
99
|
|
|
47
100
|
```python
|
|
@@ -115,6 +168,7 @@ Current limits:
|
|
|
115
168
|
|
|
116
169
|
- [AgentLoop design](docs/design/agent-loop.md)
|
|
117
170
|
- [Public interface](docs/design/loop-interface.md)
|
|
171
|
+
- [Harness and extension interface](docs/design/harness.md)
|
|
118
172
|
- [ReAct protocol](docs/design/react-protocol.md)
|
|
119
173
|
- [Directory-based SkillRegistry](docs/design/skills.md)
|
|
120
174
|
- [Verification matrix](docs/design/verification-matrix.md)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# ADR-0001: Keep nextloop as an embeddable execution library
|
|
2
|
+
|
|
3
|
+
- Status: Accepted
|
|
4
|
+
- Date: 2026-11-06
|
|
5
|
+
- Scope: repository ownership, public interfaces, documentation ownership, and release boundaries
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
nika began with one native AgentLoop alongside Feishu, AgentWiki, Skills, concrete Tools, deployment, and product policy. The execution protocol has value beyond nika, but mixing those responsibilities in one repository makes the Loop harder to reuse and verify independently.
|
|
10
|
+
|
|
11
|
+
The execution design was evaluated against open-source AgentLoop candidates in [open-source-agent-loops.md](../research/2026-11-06-open-source-agent-loops.md). No candidate was suitable as a complete kernel. nextloop therefore uses an independent implementation, with DSH as the primary structural reference and Hermes as a secondary lifecycle reference. [ADR-0002](0002-dsh-aligned-agent-loop.md) later refined this into directly following DSH's AgentLoop structure with explicit execution deltas.
|
|
12
|
+
|
|
13
|
+
## Decision
|
|
14
|
+
|
|
15
|
+
nextloop is an embeddable library, not an HTTP service, product bot, Router, EventBus, or multi-agent framework. Its public interface remains small:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
AgentLoop.run(RunContext) -> RunOutcome
|
|
19
|
+
AgentLoop.steer(input)
|
|
20
|
+
AgentLoop.cancel(cause)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
nextloop owns execution identities and state transitions, input/final-commit ordering, model invocation and retry admission, whole-batch Tool validation, correlated observations, unknown outcomes, event projection and recovery, finalization, and delivery-only recovery.
|
|
24
|
+
|
|
25
|
+
Consumers own their complete personal agent and superagent architecture, including goals, verification, Proactive behavior, and any future supervision or multi-agent collaboration, as well as channels, concrete Tools, credentials, resource supervision, Prompt and WorkingContext content policy, Wiki and Skills, deployment, and product acceptance. nextloop does not own those product or superagent behaviors.
|
|
26
|
+
|
|
27
|
+
## Documentation ownership
|
|
28
|
+
|
|
29
|
+
The canonical execution contracts live only in nextloop:
|
|
30
|
+
|
|
31
|
+
- `docs/design/agent-loop.md`
|
|
32
|
+
- `docs/design/context-builder.md`
|
|
33
|
+
- `docs/architecture/agent-loop-capability-review.md`
|
|
34
|
+
- `docs/research/`
|
|
35
|
+
|
|
36
|
+
nika retains product-specific Prompt, AgentWiki, Feishu, deployment, and product design. Its former Loop paths contain navigation pointers only; they are not alternative copies.
|
|
37
|
+
|
|
38
|
+
Historical nika architecture context remains in nika's [ADR-0002](https://github.com/12bitsD/nika/blob/main/docs/adr/0002-single-agent-loop.md) and [ADR-0001](https://github.com/12bitsD/nika/blob/main/docs/adr/0001-unified-agent-runtime.md). This ADR is nextloop's independent repository decision, not a claim that those product documents moved here.
|
|
39
|
+
|
|
40
|
+
## Interface and release rules
|
|
41
|
+
|
|
42
|
+
- API compatibility and event-schema compatibility are versioned separately.
|
|
43
|
+
- Provider-specific wire types do not leak into the public event envelope or Loop interface.
|
|
44
|
+
- Preview deltas are not authoritative Trajectory events.
|
|
45
|
+
- A release requires the failure and recovery matrix, not only a successful model → Tool → model path.
|
|
46
|
+
- nika is the first consumer, not a special exception in the public contract.
|
|
47
|
+
|
|
48
|
+
If a contract test needs a Feishu ID, Wiki path, concrete desktop lock, or product Prompt, the seam is wrong. If replacing a channel requires changing nextloop, the split is also wrong.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# ADR-0002: Follow DSH's AgentLoop with explicit execution deltas
|
|
2
|
+
|
|
3
|
+
- Status: Accepted (refined 2026-11-06)
|
|
4
|
+
- Date: 2026-11-06
|
|
5
|
+
- Scope: coordinates, driver structure, Tool scheduling, closed `ToolOutcome` ADT, surface watermark projection, and recovery
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
DSH provides the cleanest structural model for an event-sourced AgentLoop: append-only Session logs, surface-folded message derivation, integer `(turn, step)` coordinates, `next-step` inbox checks before Turn completion, parallel/exclusive Tool barriers, and pure crash-closer functions (`repair.ts`).
|
|
10
|
+
|
|
11
|
+
At the same time, an early draft of nextloop accumulated defensive spec bloat: six nested UUID identities (`session/turn/run/step/model_call/attempt`), four orthogonal Tool status fields yielding 80 state combinations, and database exception-driven control flow for in-process `steer` versus `final` races.
|
|
12
|
+
|
|
13
|
+
## Decision
|
|
14
|
+
|
|
15
|
+
nextloop directly adopts DSH's Turn/Step driver and surface-projection architecture, paired with five high-leverage simplifications:
|
|
16
|
+
|
|
17
|
+
1. **4D integer coordinates (`session_id`, `turn: int`, `step: int`, `attempt: int`) + `writer_epoch: int`:**
|
|
18
|
+
- Because interrupted Turns are sealed by crash closers and never replayed in place, `Turn` and `Run` are unified into `turn: int`.
|
|
19
|
+
- Because one `Step` is always one logical model request and its Tool batch, `Step` and `ModelCall` are unified into `step: int`.
|
|
20
|
+
- `writer_epoch` fences stale writers without introducing another execution hierarchy.
|
|
21
|
+
|
|
22
|
+
2. **Closed 5-variant `ToolOutcome` ADT (Make illegal states unrepresentable):**
|
|
23
|
+
- Replaces orthogonal `status × execution_state × effect_state × continuation_allowed` fields with five closed variants: `Completed`, `Skipped`, `Cancelled`, `UncertainSettled`, and `UncertainHanging`.
|
|
24
|
+
- `UncertainSettled` closes the batch and permits a same-Turn inspection Step; `UncertainHanging` closes the batch, locks resources, and blocks the Turn.
|
|
25
|
+
|
|
26
|
+
3. **In-memory single-actor serialization + DB crash invariants:**
|
|
27
|
+
- One active `SessionDriver` per Session serializes `steer`, Step transitions, and `final` commitment in memory.
|
|
28
|
+
- SQLite `PRIMARY KEY (session_id, seq)` and `writer_epoch` checks act strictly as fail-closed crash and split-brain invariants, never as normal `try/except` control flow.
|
|
29
|
+
|
|
30
|
+
4. **`surface_op` (`append | epoch | none`) watermark projection:**
|
|
31
|
+
- Log-only events (`turn/start`, `step/start`, `assistant/attempt`, `tool/call`, `delivery/*`) use `surface_op = 'none'`.
|
|
32
|
+
- Model-visible messages use `surface_op = 'append'`.
|
|
33
|
+
- `compaction` uses `surface_op = 'epoch'`, acting as a watermark so ContextBuilder loads only events since the latest epoch in O(Δ) time.
|
|
34
|
+
|
|
35
|
+
5. **Whole-batch admission, symmetric barrier truncation, and external Provider config:**
|
|
36
|
+
- Any malformed call or Schema error rejects the whole batch before dispatch.
|
|
37
|
+
- Admitted calls use bounded `parallel` pools (`max_parallel = 4`) and `exclusive` barriers, committing `tool/result` in model order. An error on a `parallel` call continues the pool; any error or uncertainty on an `exclusive` barrier call truncates remaining unstarted calls as `Skipped`, structurally preventing broken write chains.
|
|
38
|
+
- Provider connection config (`openai | anthropic`, `model_id`, `base_url`, credentials) stays external; Trajectory persists only execution facts.
|
|
39
|
+
|
|
40
|
+
## Consequences
|
|
41
|
+
|
|
42
|
+
The conceptual surface shrinks dramatically while preserving every safety invariant. Traces are human-readable by integer `(turn, step, attempt, seq)`, illegal Tool states are impossible to construct, and context assembly scales with current epoch length rather than total Session age.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# ADR-0003: Use Python and centralize public contracts
|
|
2
|
+
|
|
3
|
+
- Status: Accepted and implemented for 0.2.0rc1
|
|
4
|
+
- Date: 2026-11-06
|
|
5
|
+
- Scope: implementation language, dependencies, package layout, and `contracts.py` discipline
|
|
6
|
+
|
|
7
|
+
## Decision
|
|
8
|
+
|
|
9
|
+
### Language and dependencies
|
|
10
|
+
|
|
11
|
+
- Python 3.11+ with native `asyncio`; CI covers 3.11, 3.12, and 3.13.
|
|
12
|
+
- Standard-library `dataclasses`, `typing`, and `sqlite3`.
|
|
13
|
+
- `httpx` for Provider HTTP/SSE and `jsonschema` for Tool argument validation.
|
|
14
|
+
- `pytest` and `pytest-asyncio` for tests; `ruff` and `mypy` for static checks.
|
|
15
|
+
|
|
16
|
+
### Centralized `src/nextloop/contracts.py`
|
|
17
|
+
|
|
18
|
+
All public schemas and protocols live in `src/nextloop/contracts.py`:
|
|
19
|
+
|
|
20
|
+
- 4D event coordinates and `SurfaceOp` envelopes;
|
|
21
|
+
- messages, requests, responses, Tool specs, and validation results;
|
|
22
|
+
- the closed five-variant `ToolOutcome` ADT;
|
|
23
|
+
- `LoopConfig`, Turn/Recovery outcomes, errors, and versions;
|
|
24
|
+
- the four Adapter Protocols: `EventStore`, `ModelProvider`, `ToolRuntime`, and `DeliveryOwner`.
|
|
25
|
+
|
|
26
|
+
`src/nextloop/__init__.py` explicitly re-exports the supported public surface. Provider-private wire types and consumer-owned product schemas remain outside this file.
|
|
27
|
+
|
|
28
|
+
### Final package layout
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
src/nextloop/
|
|
32
|
+
contracts.py # public schemas, validation types, outcomes, Protocols, errors
|
|
33
|
+
loop.py # AgentLoop public API and active Session registry
|
|
34
|
+
driver.py # thin Turn/Step orchestration and SessionActor/Inbox
|
|
35
|
+
events/
|
|
36
|
+
project.py # O(Δ) surface projection and Compaction assembly
|
|
37
|
+
response.py # ModelResponse → ResponseDecision + NewEvent[]
|
|
38
|
+
outcome.py # ToolOutcome[] → BatchDecision + NewEvent[]
|
|
39
|
+
repair.py # incomplete history → crash closers and resource locks
|
|
40
|
+
execute/
|
|
41
|
+
model.py # Provider attempts, cancellation, and retry admission
|
|
42
|
+
tools.py # ToolRegistry, whole-batch Schema validation, single Tool execution
|
|
43
|
+
batch.py # parallel/exclusive scheduling and failure truncation
|
|
44
|
+
adapters/
|
|
45
|
+
memory.py # in-memory EventStore
|
|
46
|
+
sqlite.py # SQLite EventStore with epoch watermark index
|
|
47
|
+
openai.py # OpenAI-compatible SSE Adapter
|
|
48
|
+
anthropic.py # Anthropic SSE Adapter
|
|
49
|
+
__init__.py # explicit public exports
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`events/` contains pure functions with no I/O. `execute/` owns asynchronous side effects and normalized failures. `driver.py` only composes these mechanisms and owns finalization.
|
|
53
|
+
|
|
54
|
+
## No generic handler layer
|
|
55
|
+
|
|
56
|
+
There is no EventBus, middleware chain, per-state class hierarchy, or handler registry for Session events. `ToolRegistry` is a concrete ToolRuntime implementation, not a lifecycle hook system. Tool execution and batch scheduling are separate modules because registration/validation and concurrency/truncation are different responsibilities.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# AgentLoop 能力分类与架构收敛分析
|
|
2
|
+
|
|
3
|
+
> 历史评审记录。2026-11-06 起,当前权威架构为 [DSH-aligned AgentLoop](../design/agent-loop.md) 与 [ADR-0002](../adr/0002-dsh-aligned-agent-loop.md);本文保留当时的缺口分析和候选比较,不再代表当前进度或纯串行 Tool 决策。
|
|
4
|
+
|
|
5
|
+
日期:2026-11-02。对照基线:`57713e41124e2b085fc781c993cfebeb7156fc6a`,加本次 [AgentLoop 内部拆分工作稿](../design/agent-loop.md#12-internal-structure-and-module-interfaces)。来源为用户提供的 Agent Loop / DSH / Super-agent 综述,以及本轮公开一手来源核验。本文是分析与候选清单,不把外部机制直接改为 Nika 已确认需求;功能状态仍由 [roadmap](discussion-roadmap.md)、[worklist](feature-worklist.md) 和各设计文件承载。
|
|
6
|
+
|
|
7
|
+
用户要求是:完整记录输入,按综述的标准和分类检查现有设计,判断哪些能力有必要补充;整体架构简单,完整功能范围内的细节打磨到位。当前仓库仍无 runtime,实现和运行验收均未开始。下文的“已有”统一指已有设计。
|
|
8
|
+
|
|
9
|
+
## 1. 核心判断
|
|
10
|
+
|
|
11
|
+
Nika 已覆盖综述中多数基础方向:原生模型/工具循环、runtime 执行规则、运行中接纳 steer、资产化大输出、缓存与压缩、软预算、持久事件、状态与执行分离、Wiki/Skill,以及取消和故障收尾。主要差距是把这些原则补成完整协议并验证,而非缺少同名模块。
|
|
12
|
+
|
|
13
|
+
综述最有价值的增量是三件事:
|
|
14
|
+
|
|
15
|
+
1. 将 **ReAct 的响应判定、行动许可条件、观察回填与出口** 单独作为关闭项。
|
|
16
|
+
2. 将 **目标、验证、停止和恢复信息** 连成场景契约,既检查任务结果,也检查无进展和未知状态;保留当前软预算决定。
|
|
17
|
+
3. 把 **人的注意力、主动触发、长任务响应性与可信授权** 放到所属专题中做具体取舍,而不是通过 Prompt 暗示自动获得这些能力。
|
|
18
|
+
|
|
19
|
+
Router/Worker、后台 job、持久事件订阅、独立业务 Watchdog 是可能有价值的新能力,但它们改变调度和生命周期。其价值需要从 Nika 的实际工作场景推导,不能由某个原型的成绩或“更先进”的描述直接决定。
|
|
20
|
+
|
|
21
|
+
## 2. 外部证据与适用边界
|
|
22
|
+
|
|
23
|
+
一手核验分别在 [DSH / Super-agent 来源笔记](../research/2026-11-02-dsh-primary-sources.md) 与 [Loop Specification / DSH 社区证据](../research/2026-11-02-loop-evidence-notes.md)。笔记保留固定版本、具体位置、核验范围和未证实项;本轮未运行外部原型或复现其 benchmark。
|
|
24
|
+
|
|
25
|
+
| 综述中的依据 | 本轮核验后应如何使用 |
|
|
26
|
+
|---|---|
|
|
27
|
+
| DeepSeek Super-agent 架构与原型 | 官方架构文章、DSH 主仓和独立 Super-agent prototype 必须分开。官方说明属于架构探索,prototype 与文章/内部版本并不完全相同;不能把文章列出的每项能力当成开源代码已有 |
|
|
28
|
+
| Router 靠工具集强制委派、外部 Watchdog | 文章提出相关方向,但公开原型仍给 Router 提供 Bash/read 等工具;本轮检查的原型未找到 Watchdog 实现。“结构保证委派”是可以评估的设计原则,不能当作该原型已证明的强制边界 |
|
|
29
|
+
| p50=12.4、p95=15.7 分钟 | 官方报告的合成负载结果,每方案 5 次,约 300 条消息/20 个工作请求,coding 用耗时工具模拟。可提示尾延迟和人工协调的价值,不证明真实代码质量或 Nika 的收益 |
|
|
30
|
+
| 约 23.2M cache-read tokens | 跨所有 Sessions、每次运行累计的缓存读取量;不是上下文容量,也不能单独换算成完整成本。真实比较要同时记录 uncached input、cached input、output、价格与成功质量 |
|
|
31
|
+
| Loop Specification 五要素与 50 个 loop | arXiv:2607.00038 的作者对公开配方进行人工编码。70%/74% 是验证层级与终态写法的样本比例,不是实测成功率或因果结果 |
|
|
32
|
+
| 27 步、约百万 token 的 DSH 案例 | 社区讨论提供的个案观察,可作为回归场景来源;不是所有 ReAct 的必然表现,也不是本轮复现结果 |
|
|
33
|
+
| 19 Sessions、72–88% uncached prefill 减少 | 社区作者的扩展实验报告,不能称 DSH 官方保证;公开可复现证据的局限见笔记 |
|
|
34
|
+
|
|
35
|
+
以下一般化结论需要收窄:
|
|
36
|
+
|
|
37
|
+
- **串行执行工具不意味着无法接收输入。** intake 可以在等待 Tool 时保存 steer、接收回答和发送取消信号;是否让模型同时规划下一步、是否让 Tool 返回 handle 后跨 Turn 运行,是另外的语义。
|
|
38
|
+
- **累计输入可能近似平方增长,账单并不必然如此。** 若初始输入为 B,每轮固定增加 d,n 次请求未经压缩的累计输入约为 nB+d·n(n−1)/2。实际费用还取决于前缀缓存、输出、不同工具结果长度和压缩;每次上下文容量也必须单独计算。
|
|
39
|
+
- **持久 Session 与常驻实体是不同层次。** Nika 的 Session/Trajectory 持久化和容器部署可以支持用户设备离线后的服务存续;后台服务自身故障后恢复哪些工作仍需协议,历史副作用仍不自动重放。
|
|
40
|
+
- **Run 结束、模型停止与业务成功分开。** 退出条件需解释停止原因及可核查结果;没有工具调用不是证明任务完成的充分条件。
|
|
41
|
+
- **独立任务并行与强耦合任务拆分分开。** 两个目标独立也可能竞争相同 workspace、登录态或桌面,仍需要资源所有权;单循环执行算法可以被多个 Session 使用,不能据此推导新 Router 的必要性。
|
|
42
|
+
|
|
43
|
+
## 3. 按综述分类对照 Nika
|
|
44
|
+
|
|
45
|
+
分类含义:**已有设计**=可沿用但待实现;**契约补齐**=在现有架构内明确接口/所有权/故障;**候选新增**=需场景和取舍决定;**不自动纳入**=与当前明确基线冲突或证据不足。
|
|
46
|
+
|
|
47
|
+
| 综述能力 | Nika 当前依据 | 归类与收敛动作 |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| ReAct + native tool calling | [AgentLoop §5](../design/agent-loop.md#5-tool-calls) 有 model → calls → results → model | **已有骨架 / 契约补齐**:补下节 G0。保持模型决策与 runtime 执行分工,不要求明文 Thought 标签或新增 Reasoner |
|
|
50
|
+
| Harness 规则由结构保证 | [内部结构](../design/agent-loop.md#12-internal-structure-and-module-interfaces) 已分 driver/input/model/tool-batch/finalization | **契约补齐**:工具 schema、权威身份、授权、资源、写入顺序与取消不能只靠 Prompt;不为此增加通用插件框架 |
|
|
51
|
+
| 可替换 Loop | Session 持久、Loop 按需创建,外部依赖分责 | **已有替换基础**:保持小接口和可独立验证即可;当前不需要动态 Loop 插件系统 |
|
|
52
|
+
| Inbox、中途插话 | Session-owned 单 steer buffer、控制输入绕行、WaitingRequest | **已有设计 / 契约补齐**:接纳、注入、重启积压与回答路由;独立任务 FIFO 或 send/followup/steer/inject 四入口不自动照搬 |
|
|
53
|
+
| 大输出 spill 与按需读取 | [内容访问](../design/context-builder.md#content-access-and-task-performance)、asset-before-reference | **已有设计 / 契约补齐**:全文必须可恢复,preview/分页/定位/引用寿命明确;不照搬 50KB 或按实验百分比承诺收益 |
|
|
54
|
+
| 外部知识与少量通用工具 | AgentWiki grep/read、Skill 按需加载、静态 Tool Catalog | **已有设计**:保留飞书/Browser/Computer 所需明确工具;工具数量由可用性与完整契约决定,不机械缩成只有 shell |
|
|
55
|
+
| 验证和停止 | System Prompt 验证规则、最终提交/投递、取消和未知结果 | **契约补齐**:任务验证如何形成证据,如何表达未完成、受阻、停止;不让万能 Verifier 仅凭模型文字判断成功 |
|
|
56
|
+
| 步数/时间/成本预算 | 当前调用数与时间为软预算,usage/preflight 为已有设计 | **已有设计 + 候选新增**:可补软成本观测与无进展提示。硬步数/时间/成本闸与当前选择不同,需明确变更才采用 |
|
|
57
|
+
| 外层 Loop Specification | 输入、用户目标、验证规则、取消、Trajectory/Wiki 已各有归属 | **可直接作为评审分类**:每场景检查 trigger/goal/verification/stopping/memory;持久自动重试/轮询外层 Loop 需另行决定 |
|
|
58
|
+
| Router/Worker、多 Agent | 一套原生 Loop;多 Session 资源隔离待设计 | **候选新增**:先量化并行独立任务和统一出口的收益;自动分派、worker 池、subagent 需授权继承、资源、汇总和取消协议,当前不加入 |
|
|
59
|
+
| 事件触发、代码过滤、observe-first | Feishu 事件输入已有;Proactive 价值已接受 | **Proactive 候选**:先定义允许的事件、规则和只记录候选动作的观察阶段;不能把 observe 记录自动升级为执行授权 |
|
|
60
|
+
| 跟进订阅直连 | 已有入口→Session 固定映射 | **部分已有 / 候选新增**:已知 Thread 的后续输入可沿原映射;任务结束后持久订阅并唤醒、新增 GitHub/邮件/CI 来源是新的生命周期。评论仍沿严格 @ 默认 |
|
|
61
|
+
| 长工具异步化 | 等待 Tool 时 intake/stop 应可响应,工具首版串行 | **响应性属契约补齐,后台 job 属候选新增**:先把取消、等待和进度做对;跨 Turn handle、完成事件、重启接管与 orphan 另定 |
|
|
62
|
+
| Ticket + immutable Mandate | Runtime 派生可信授权;Wiki 三种 scope | **借鉴授权留痕**:记录发起人、来源、范围、策略版本和有效期;扩权经新的可信输入追加。不可变目标、扩权必建 Ticket 及第二任务库不自动采用 |
|
|
63
|
+
| 外部 Watchdog | SessionManager 启动恢复、lease、进程监督待工程化 | **拆成两项**:存活/失联/孤儿资源检测属于 M6/M8;判断业务偏航、干预模型或重启任务的监督 Agent 是候选新增 |
|
|
64
|
+
| 人类注意力预算 | Proactive 减少上下文负担的目标已有 | **专题待设计**:什么值得通知、如何合并、哪些请求要阻塞、何时静默;用户主动问状态时仍返回真实状态 |
|
|
65
|
+
| 状态/计算/环境分离 | Session/Trajectory、按需 Loop、容器内执行资源 | **已有原则 / 契约补齐**:资源 owner、重启清理和可恢复事实;不扩大到远程设备或隐含跨机器任务恢复 |
|
|
66
|
+
| 链式召回、投机执行 | 稳定引用/按需检索有基础,投机副作用未设计 | **不自动纳入**:沿真实来源链接检索可复用;未确认前启动写入/外部动作需要独立授权与收益证据 |
|
|
67
|
+
|
|
68
|
+
<a id="react-execution-protocol-gap"></a>
|
|
69
|
+
|
|
70
|
+
## 4. G0:ReAct 执行协议记录
|
|
71
|
+
|
|
72
|
+
2026-11-02 用户指出此前 AgentLoop 没有单独讨论 ReAct;核查确认已有循环骨架,但模型输出到运行决策的协议未完整定义。此前“M4 Done”只适用于已有状态机/生命周期基线,不能代表此协议已关闭。该缺口应先于或结合 Tool Catalog 收敛。
|
|
73
|
+
|
|
74
|
+
2026-11-03 已确认:[正常结束前检查 pending steer](../design/agent-loop.md#normal-turn-completion)、[普通工具错误后的同批继续](../design/agent-loop.md#tool-batch-failure-policy),以及 [超时与结果未知的处理](../design/agent-loop.md#tool-timeout-outcomes)。已接纳、未注入的 steer 继续同 Turn/Run;final commit 后接纳的输入归下一 Turn。普通错误提交后继续同批调用;有结果或成功依赖的动作分两次模型调用。超时导致 unknown 则结束本批,提交后仅在 Runtime 允许时同 Turn 核查,否则收尾报告受阻,保留资源限制。具体事务、逐工具格式与资源机制及运行验证待实现;下表保留其余协议缺口。
|
|
75
|
+
|
|
76
|
+
同日进一步确认 [整批执行前校验](../design/agent-loop.md#tool-call-validation):任一名称/参数/Schema、身份或完整性错误都使本批全部未执行并报错。普通错误续批仅适用于通过校验后的运行错误;报错后的模型修正协议仍待收敛。
|
|
77
|
+
|
|
78
|
+
| 契约 | 必须覆盖 | 关闭产物 |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| 响应分类 | text、tool calls、混合输出、空响应、refusal、长度截断、流中断与 Provider 终止信号;哪些文字属于过程或最终交付 | Provider 原生响应 → 统一逻辑结果 → driver 动作表;不从自然语言“完成了”猜终态 |
|
|
81
|
+
| Action 可执行条件 | 整批执行前校验及错误即整批拒绝已定;逐 Provider 的完整性/身份映射、逐工具 schema、坏 JSON/截断等错误的合法反馈 | 执行前零副作用和整批拒绝的验证;错误如何进入模型修正请求仍待 T1/T2 定义 |
|
|
82
|
+
| Observation | 成功、失败、部分成功、未知、取消的逐工具字段/证据;Tool Call/Result 配对;大输出和多模态引用;已定超时/unknown 规则的 Provider 映射和资源准入 | 可回放为合法模型消息的观察样例;普通错误续调、同批继续及实时超时/unknown 行为已定,不能因映射丢失未知信息;持久化失败单独处理 |
|
|
83
|
+
| 继续与结束 | Tool Result 后续调、WaitingRequest、无输出/截断恢复、最终回复、显式停止、终止错误、无进展 | 决策表与失败路径;业务验收证据独立于模型 end_turn,保持软预算不强停 |
|
|
84
|
+
| 推理相关字段 | API 公开 summary、需原样回传的 opaque/signature 内容、普通正文;各 Provider 续调与压缩要求 | 只处理 Provider 合法提供的数据,不要求完整隐藏思维链,不混入用户回复或 WorkingContext |
|
|
85
|
+
|
|
86
|
+
建议落点为现有 model invocation 与 driver 的接口、Tool batch 的准入/结果契约、ContextBuilder 的投影。名称、数据类型和各错误分支仍是待审方案;本次记录不选定框架、不新增第二个执行循环。
|
|
87
|
+
|
|
88
|
+
## 5. 值得优先补齐的能力与关闭条件
|
|
89
|
+
|
|
90
|
+
以下均为 **state=proposed** 的收敛建议。除已有明确契约的同步外,不自动改变 runtime 基线。
|
|
91
|
+
|
|
92
|
+
| 候选 | 建议深度与所属模块 | 最小关闭条件 |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| P1 验证驱动的结果交付 | 为复杂任务明确目标、范围、验证方法、证据和未完成项,复用用户输入/Skill/Trajectory;Task 定义不另存一套权威状态。Loop 确保结果可回传,具体 Skill/Agent 选择任务相关的回归范围 | 能访问并执行足够的检查;测试范围由影响面决定,不固定每轮全跑。未跑/失败/环境受阻如实记录;业务成功有外部结果证据 |
|
|
95
|
+
| P2 无进展与成本观测 | 同类 Tool 调用、结果变化、等待类型、已花时间和 usage 形成可解释诊断;先提供软提醒。expected polling、合法长等待与真正重复探索分开 | 重复检索、长测试、等回答三种场景不混判;提醒不会自动取消或重放。成本缺价格/usage 时标 unknown,价格带来源版本 |
|
|
96
|
+
| P3 授权来源绑定 | M6 定义真实用户/事件来源、授权范围与策略版本,runtime 计算有效权限。目标可被 steer 改写,权限扩大仍要可信授权;所有版本追加留痕 | 用户中途改目标不会被旧 Ticket 锁死;文档/工具内容不能自授扩权;凭据使用路径不要求模型获得明文 |
|
|
97
|
+
| P4 主动性与注意力协议 | Proactive 采用具体触发场景和观察阶段候选,定义内部整理、用户交付、决策请求、异常通知。后台唤醒仍待选择 | 同一事件不重复通知;只记录阶段不执行;输出与真实进展相关;通知不形成新的动作授权 |
|
|
98
|
+
| P5 可响应的长操作与健康诊断 | ToolRuntime 在等待时保留取消/输入通道,记录进度证据;SessionManager/进程监督检查存活和资源归属 | 长工具期间可接收 steer/stop;停止结果区分已退出与未知;恢复不重放副作用。后台 job 和业务监督 Agent 不在此候选中隐式加入 |
|
|
99
|
+
|
|
100
|
+
采用新的硬预算、Router/Worker、持久订阅、跨 Turn 后台 job 或目标级 Watchdog,需要分别解释用户场景、共享资源、额外状态、成本和可验收收益。它们不能因为被列入综述而自动成为完整交付范围的一部分。
|
|
101
|
+
|
|
102
|
+
## 6. 用 Loop Specification 五要素关闭场景
|
|
103
|
+
|
|
104
|
+
把五要素作为审查表,足以发现跨层空缺;暂不新增可执行 DSL、自动循环引擎或持久 TaskSpec 数据库。
|
|
105
|
+
|
|
106
|
+
| 要素 | Nika 中需要说明的内容 | 当前归属 |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| Trigger | 入口、事件身份、去重、谁触发、是否已有授权、是否仅观察 | Feishu ingress;Proactive 专题 |
|
|
109
|
+
| Goal | 当前请求、完成标准、允许范围、steer 如何更新;扩权与改目标分开 | 用户输入、Session projection、Skill;授权由 Runtime |
|
|
110
|
+
| Verification | 用什么产物/检查证明结果,失败怎样反馈,哪些证据仍缺失 | 具体任务 Skill/Tool/Agent;Trajectory 保存实际结果 |
|
|
111
|
+
| Stopping rule | 何时输出结果、等待回答、取消或因故障停止;如何呈现部分完成 | ReAct 协议、driver、WaitingRequest、finalization |
|
|
112
|
+
| Memory | 恢复当前任务需要哪些 committed facts;什么可进长期 Wiki,谁授权 | Session events/assets、ContextBuilder、AgentWiki |
|
|
113
|
+
|
|
114
|
+
必须联合走查的例子:代码修改造成回归;重复搜索却无新证据;工具等待时用户改方向;提交结果前崩溃;发送成功但回执丢失;截图资产被 GC;事件触发超过授权;任务有结果但连续重复通知。每例明确 owner、事件、结果和异常,不能仅写一句“支持”。
|
|
115
|
+
|
|
116
|
+
<a id="closure-gap-index"></a>
|
|
117
|
+
|
|
118
|
+
## 7. 统一 gap 索引与讨论归属
|
|
119
|
+
|
|
120
|
+
此处登记对话已列出的 G0–G13,维持原 roadmap 所属阶段。用户随后要求按大 topic/部件归组,具体未定问题、跨模块接口与讨论顺序统一维护在 [roadmap 的 T1–T8](discussion-roadmap.md#discussion-topics);下表只作 gap→主 topic 映射,不另建排期。以下均为待收敛/待验证,非实现状态。
|
|
121
|
+
|
|
122
|
+
| ID | Gap | 主讨论 topic | 关闭条件与原阶段 |
|
|
123
|
+
|---|---|---|---|
|
|
124
|
+
| G0 | ReAct 执行协议 | [T1 执行控制](discussion-roadmap.md#topic-execution) | §4 的五项协议与完整场景表;M4 follow-up,衔接 M5 |
|
|
125
|
+
| G1 | Tool Catalog | [T3 工具/权限/资源](discussion-roadmap.md#topic-tools) | 每个工具 schema、description、错误/取消/大结果示例;M5 |
|
|
126
|
+
| G2 | Loop 内部接口与输入接纳 | [T1 执行控制](discussion-roadmap.md#topic-execution) | 唯一 writer 与提交责任,等待回答/steer/stop/积压输入可确定归属;M6–M8 |
|
|
127
|
+
| G3 | Context / Provider 实现契约 | [T2 模型/上下文](discussion-roadmap.md#topic-context) | 确定请求、部分输出、wire 映射、压缩自身容量与校验;M5/M8 |
|
|
128
|
+
| G4 | 操作者权限与执行凭据 | [T3 工具/权限/资源](discussion-roadmap.md#topic-tools) | 授权来源、作用域、失效与凭据访问、Wiki 写入不可绕过;M6 |
|
|
129
|
+
| G5 | 共享资源与 Browser/Computer | [T3 工具/权限/资源](discussion-roadmap.md#topic-tools) | workspace/profile/GUI/Wiki 的 owner、锁、取消、失联与未知;M6/M8 |
|
|
130
|
+
| G6 | 事件、持久化与恢复 | [T4 持久状态](discussion-roadmap.md#topic-state) | schema、事务、幂等、lease、投影/运行状态 fold、损坏处理;M7 |
|
|
131
|
+
| G7 | Wiki / Skills 写入与发布 | [T6 知识/行为资产](discussion-roadmap.md#topic-knowledge) | 授权→验证→写入→Git/Trajectory→发布/失败,动态 Skill 兼容;M6/M7 |
|
|
132
|
+
| G8 | 飞书输入、文档与评论 | [T5 渠道/交互](discussion-roadmap.md#topic-channels) | 每种入口的去重/延迟/编辑冲突/部分成功/回读协议;M7 |
|
|
133
|
+
| G9 | 投递与交互呈现 | [T5 渠道/交互](discussion-roadmap.md#topic-channels) | final_message_id、接管、delivery_unknown、过期回答、长文与状态;M7 |
|
|
134
|
+
| G10 | Assets、查询导出与数据生命周期 | [T4 持久状态](discussion-roadmap.md#topic-state) | 引用完整、导出完整性、版本化格式、一致备份、GC/磁盘满;M7/M8 |
|
|
135
|
+
| G11 | Proactive | [T7 主动性/注意力](discussion-roadmap.md#topic-proactive) | 触发、授权内行为、观察/执行、通知、去重与取消;独立专题 |
|
|
136
|
+
| G12 | 工程、部署与运行诊断 | [T8 工程/验收](discussion-roadmap.md#topic-engineering) | 语言/接口/依赖、进程管理、配置、升级迁移、健康与 CI;M8 |
|
|
137
|
+
| G13 | 全功能验收与实施分期 | [T8 工程/验收](discussion-roadmap.md#topic-engineering) | 每能力的正常/失败/并发/恢复场景、证据、退出条件与完整覆盖;M9 |
|
|
138
|
+
|
|
139
|
+
当前从 T1 的 G0 与 T3 的 G1 联合讨论开始,后续顺序见 roadmap。P1–P5 的主归属也统一登记在那里。已有 WorkingContext、缓存、usage fallback、压缩 Prompt 与软预算机制不重新选型;具体数据结构、接口和验证仍按归属补齐。实施分期保留全部已确认能力;候选新增能力须先经过明确选择。
|
|
140
|
+
|
|
141
|
+
## 8. 本轮记录与变更边界
|
|
142
|
+
|
|
143
|
+
- 保存用户综述原文与所有给出的链接,在 Work Wiki 登记来源和本分析入口;未将二手叙述直接提升为长期确定事实。
|
|
144
|
+
- 记录 ReAct 缺口,并让 roadmap/worklist 明确区分 M4 原状态机基线与新增协议关闭项。
|
|
145
|
+
- 按既有决定同步软预算、完整 preflight 条件、工具串行和已定 steer 边界等旧句子,保留本次分析前的版本基线可供追溯。
|
|
146
|
+
- 研究文件记录外部作者的证据,不声称本轮复现;能力建议保持 proposed。
|
|
147
|
+
- 变更范围为设计与研究文档;未创建 runtime、自动任务、订阅或后台监督。后续按模块讨论的入口统一维护在 roadmap,文档发布不表示候选能力已采纳或实现。
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# nextloop development and verification plan
|
|
2
|
+
|
|
3
|
+
Current stage: **0.2.0rc1 implementation complete; publication and consumer acceptance are separate**.
|
|
4
|
+
|
|
5
|
+
## Phase 0 — Contracts — Closed
|
|
6
|
+
|
|
7
|
+
The DSH-aligned domain model, four Adapter Protocols, event envelope, transaction groups, and ownership rules are closed.
|
|
8
|
+
|
|
9
|
+
References: [AgentLoop](../design/agent-loop.md), [ReAct](../design/react-protocol.md), [Loop interface](../design/loop-interface.md), [ADR-0002](../adr/0002-dsh-aligned-agent-loop.md), and [ADR-0003](../adr/0003-python-and-centralized-contracts.md).
|
|
10
|
+
|
|
11
|
+
## Phase 1 — Executable driver — Complete
|
|
12
|
+
|
|
13
|
+
Implemented:
|
|
14
|
+
|
|
15
|
+
- `contracts.py`, `loop.py`, and a thin Turn/Step `driver.py`;
|
|
16
|
+
- pure `events/` projection, response/outcome folds, and crash repair;
|
|
17
|
+
- `execute/` model retries, Tool registration/validation, and batch scheduling;
|
|
18
|
+
- in-memory and SQLite EventStores;
|
|
19
|
+
- OpenAI-compatible and Anthropic SSE Providers;
|
|
20
|
+
- a fake-Provider example completing model → Tool → Observation → model → delivery.
|
|
21
|
+
|
|
22
|
+
## Phase 2 — Failure and recovery matrix — Current evidence passes
|
|
23
|
+
|
|
24
|
+
The current suite contains 30 passing tests, with `ruff` and `mypy` also passing. It covers normal responses, malformed responses, parallel/exclusive ordering, steer, cancellation, Compaction, exact-byte retry, resource restrictions, real subprocess exits, SQLite recovery, delivery-only retry, and recorded Provider streams.
|
|
25
|
+
|
|
26
|
+
Wheel and sdist pass `twine check`. A clean virtual environment installs the wheel and completes the example.
|
|
27
|
+
|
|
28
|
+
See [verification matrix](../design/verification-matrix.md) for the release gate and current evidence.
|
|
29
|
+
|
|
30
|
+
## Phase 3 — Release candidate publication — In progress
|
|
31
|
+
|
|
32
|
+
- CI runs Python 3.11, 3.12, and 3.13.
|
|
33
|
+
- A `v0.2.0rc1` tag runs the release workflow.
|
|
34
|
+
- The workflow verifies the package, installs the built wheel in a clean environment, publishes to PyPI through Trusted Publishing, and creates a GitHub Pre-release.
|
|
35
|
+
|
|
36
|
+
PyPI project and GitHub Environment trusted-publisher setup are external prerequisites. A tag alone is not proof of publication.
|
|
37
|
+
|
|
38
|
+
## Phase 4 — Consumer and final release — Separate acceptance
|
|
39
|
+
|
|
40
|
+
Before `0.1.0` final:
|
|
41
|
+
|
|
42
|
+
- install the RC through a real consumer Adapter and run its smoke test;
|
|
43
|
+
- perform any chosen hosted-model smoke;
|
|
44
|
+
- record compatibility and remaining limitations in release notes;
|
|
45
|
+
- only then tag `v0.1.0`.
|
|
46
|
+
|
|
47
|
+
nika acceptance remains in nika and is not claimed by nextloop's core suite.
|