@yahyahammad/venastine 0.3.13 → 0.3.14
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.
- package/README.md +2 -2
- package/core/client.py +19 -0
- package/core/compaction.py +10 -4
- package/core/loop.py +101 -1
- package/core/memory.py +4 -1
- package/core/reasoning/json_retry.py +15 -0
- package/core/reasoning/orchestrator.py +11 -2
- package/main.py +30 -3
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/storage.py +42 -5
- package/tui/app.py +8 -0
package/README.md
CHANGED
|
@@ -1058,7 +1058,7 @@ Deliberately not settings.json keys: editing these means editing the harness's o
|
|
|
1058
1058
|
|
|
1059
1059
|
**Built:** ROADMAP.md §1–§12 (§10's ensemble mode rebuilt by its revisit — diversity now comes from a roster of different models) and ROADMAP_v2.md §13 (streaming loop), §14 (config loader + workspace trust), §15 (permissions), §16 (TUI), §17 (MCP), §18 (agents), §19 (skills), §20 (post-pipeline review), §21a (compaction + `pin`), §21b (durable memory), §22 (live pipeline progress), §25 (authorised tool use in the pipeline), §26 (research legibility: per-pass tool calls, code-stage announcements, the claims view, role colour, `/copy`), §27 (thread legibility: transcript replay on resume, a conversations-only thread picker), §21c (session summaries and cross-thread referencing — §21 is now complete), §24 (`/init`), §23 (interactive tools: the response channel, per-tool subagent sign-off, `ask_user`, and the todo list), §28 (the shell capability classifier).
|
|
1060
1060
|
|
|
1061
|
-
**Remaining:** nothing in `ROADMAP.md` or `ROADMAP_v2.md`, and §10's revisit is now closed. `ROADMAP_v3.md` §49–§59
|
|
1061
|
+
**Remaining:** nothing in `ROADMAP.md` or `ROADMAP_v2.md`, and §10's revisit is now closed. `ROADMAP_v3.md` §49–§59, §61–§93 and §95 are built. The section still to build is §60 (Unified Harness Protocol compliance), specified and awaiting detailed design. §56 lets a decision model approve a single contained shell command under the opt-in `classified` mode; §54 completes project file/folder mentions without loading contents; §58 supplies a short harness identity that follows the current model; §83's final live checks are confirmed, and the ChatGPT header distinguishes a selected provider from an active sign-in. `TECHNICAL_DEBT.md` items 14, 17, 18, 21, 102 and 116 are open, and so is the secrets half of item 97. The two checks recorded against §10 are answered from the providers' documentation in `ROADMAP_v3.md` §87: the default `temperature` on OpenAI and Google is 1.0, and OpenAI's reasoning models refuse one whenever reasoning effort is not `none`, which the guard now follows.
|
|
1062
1062
|
|
|
1063
1063
|
**And both audits are closed.** Both roadmaps being built is not the same as the code
|
|
1064
1064
|
being clean, and saying only the first would be the "built and runs are different claims"
|
|
@@ -1077,7 +1077,7 @@ note that shell approval is governed solely by `shell_approval_mode` -- `tool_ap
|
|
|
1077
1077
|
deliberately has no `shell` key, so an old file carrying one is refused at startup
|
|
1078
1078
|
naming the key — see `tests/BREAKING_CHANGES.md` §24.
|
|
1079
1079
|
|
|
1080
|
-
Run the test suite with `pytest` —
|
|
1080
|
+
Run the test suite with `pytest` — 9358 tests, fully offline, no API keys needed. Since batch 243 the suite holds itself to that: a test that asks DNS for a name, or writes into your home folder, fails by name, and every test process runs with HOME pointing at a throwaway folder of its own. The suite's own packages are `requirements-test.txt`, separate from `requirements.txt` since batch 136: they used to be in the shipped dependency list, so installing the harness also installed a test runner. It runs in parallel by default (`pytest-xdist`, 70% of your cores): **1:26 on a 16-core machine, against 9:06 single-process.** `pytest -n0` forces the old serial run, which is what you want under a debugger or when something is parsing the output. Eight further tests are marked `integration` and excluded by default: three spawn a real stdio MCP server, one runs an external program through the host fallback shell, one builds the hosted bundle's Docker image, and three run the installers' uv path against a real uv (`pytest -m integration`).
|
|
1081
1081
|
|
|
1082
1082
|
## Documentation
|
|
1083
1083
|
|
package/core/client.py
CHANGED
|
@@ -198,6 +198,25 @@ def accepts_images(provider_name: str) -> bool:
|
|
|
198
198
|
return isinstance(entry, dict) and entry.get("accepts_images") is True
|
|
199
199
|
|
|
200
200
|
|
|
201
|
+
def reasoning_not_echoed(provider_name: str) -> bool:
|
|
202
|
+
"""ROADMAP_v3 §95 (RO7). Whether this is an OpenAI-compatible provider
|
|
203
|
+
whose reasoning does NOT go back to it on the next request.
|
|
204
|
+
|
|
205
|
+
The question a reasoning-only reply raises: on that wire `echoes_reasoning`
|
|
206
|
+
is opt-in (§44 WS4), and measured on one provider, a model that never saw
|
|
207
|
+
its earlier reasoning wrote its tool call inside its reasoning on 8 of 23
|
|
208
|
+
replays of a tool-loop step, against 0 of 23 with the reasoning sent back.
|
|
209
|
+
Read with the same truthiness `call_model_stream` gives both flags, so
|
|
210
|
+
this answers what the request will actually do, not what the file
|
|
211
|
+
should have said. Every other provider sends its own reasoning back by
|
|
212
|
+
its own route, and answers False.
|
|
213
|
+
"""
|
|
214
|
+
entry = load_provider_data().get(provider_name, {})
|
|
215
|
+
return (isinstance(entry, dict)
|
|
216
|
+
and bool(entry.get("is_v1_compatible", False))
|
|
217
|
+
and not entry.get("echoes_reasoning", False))
|
|
218
|
+
|
|
219
|
+
|
|
201
220
|
# ============================================================================
|
|
202
221
|
# ---- Normalized response shape ---------------------------------------------
|
|
203
222
|
# ============================================================================
|
package/core/compaction.py
CHANGED
|
@@ -833,11 +833,15 @@ def compactable_span(memory, current_turn_start: Optional[int] = None,
|
|
|
833
833
|
Reading everything from `rows` makes the mismatch unrepresentable
|
|
834
834
|
rather than merely fixed.
|
|
835
835
|
"""
|
|
836
|
-
from storage import _ordered_rows
|
|
836
|
+
from storage import _ordered_rows, starts_turn
|
|
837
837
|
|
|
838
838
|
settings = config_loader.effective_compaction(overrides)
|
|
839
839
|
rows = _ordered_rows(memory.thread_id)
|
|
840
|
-
|
|
840
|
+
# `starts_turn`, not `role == "user"` (ROADMAP_v3 §95, RO3): a harness
|
|
841
|
+
# row the loop wrote inside a turn would otherwise be a fold boundary,
|
|
842
|
+
# and `completed_turns()` -- which this list must agree with -- does
|
|
843
|
+
# not count it.
|
|
844
|
+
starts = [i for i, row in enumerate(rows) if starts_turn(row)]
|
|
841
845
|
if not starts:
|
|
842
846
|
return None
|
|
843
847
|
|
|
@@ -1084,7 +1088,7 @@ def pin_measurements(thread_id, last_n: int, model: Optional[str] = None,
|
|
|
1084
1088
|
calls this from outside a run moves.
|
|
1085
1089
|
"""
|
|
1086
1090
|
from core import config_loader
|
|
1087
|
-
from storage import _ordered_rows
|
|
1091
|
+
from storage import _ordered_rows, starts_turn
|
|
1088
1092
|
|
|
1089
1093
|
settings = config_loader.effective_compaction()
|
|
1090
1094
|
# THE MINIMUM, and the min() is load-bearing rather than defensive.
|
|
@@ -1114,7 +1118,9 @@ def pin_measurements(thread_id, last_n: int, model: Optional[str] = None,
|
|
|
1114
1118
|
max_tokens = int(config.PIN_MAX_TRIGGER_FRACTION * trigger)
|
|
1115
1119
|
|
|
1116
1120
|
rows = _ordered_rows(thread_id)
|
|
1117
|
-
|
|
1121
|
+
# The turns `pin_last` counts, so the cap measures what the pin will
|
|
1122
|
+
# flag (ROADMAP_v3 §95, RO3).
|
|
1123
|
+
starts = [i for i, row in enumerate(rows) if starts_turn(row)]
|
|
1118
1124
|
bounds = starts + [len(rows)]
|
|
1119
1125
|
|
|
1120
1126
|
def _tokens(lo: int) -> int:
|
package/core/loop.py
CHANGED
|
@@ -53,9 +53,11 @@ from core.client import (
|
|
|
53
53
|
call_model_stream,
|
|
54
54
|
context_window_for,
|
|
55
55
|
effort_for,
|
|
56
|
+
reasoning_not_echoed,
|
|
56
57
|
)
|
|
57
58
|
from core.events import LoopEvent
|
|
58
59
|
from core.memory import ConversationMemory
|
|
60
|
+
from core.replay import reasoning_text
|
|
59
61
|
from safety.policy_enforcement import redact_diagnostic_text
|
|
60
62
|
|
|
61
63
|
# §27 (T1). The loop is where a thread's kind is DECIDED -- it knows which
|
|
@@ -668,6 +670,87 @@ def _already_said(notices, kind: str) -> bool:
|
|
|
668
670
|
n["kind"] == kind for n in notices)
|
|
669
671
|
|
|
670
672
|
|
|
673
|
+
# ROADMAP_v3 §95. A REASONING-ONLY reply: the step returned readable
|
|
674
|
+
# reasoning and neither text nor a tool call. Measured on an
|
|
675
|
+
# OpenAI-compatible provider, 33 of its 316 turns came back this way, every
|
|
676
|
+
# one right after a tool result, with the model's tool call written out in
|
|
677
|
+
# its own markup INSIDE the reasoning -- the server only turns markup into a
|
|
678
|
+
# call when it appears after the model's end-of-reasoning delimiter, and
|
|
679
|
+
# reasoning is all this loop received. Before §95 such a step ended the turn
|
|
680
|
+
# as `complete` and said nothing, to the person or to the model.
|
|
681
|
+
#
|
|
682
|
+
# RO2: the loop asks ONCE per run, through a harness row, and a second
|
|
683
|
+
# reasoning-only reply ends the turn with a notice. The row's first line is
|
|
684
|
+
# also the live notice's text, so the line a person sees while the turn
|
|
685
|
+
# runs is the line its replay draws (RO5).
|
|
686
|
+
HARNESS_REASONING_ONLY = "reasoning_only"
|
|
687
|
+
REASONING_ONLY_END = "reasoning_only_end"
|
|
688
|
+
REASONING_ONLY_HEADER = (
|
|
689
|
+
"[harness] The last reply was reasoning only: no answer and no tool "
|
|
690
|
+
"call reached the harness, so nothing ran.")
|
|
691
|
+
_REASONING_ONLY_NUDGE = (
|
|
692
|
+
REASONING_ONLY_HEADER + "\n"
|
|
693
|
+
"A tool call written inside reasoning is not run. Make the call through "
|
|
694
|
+
"the tool-calling interface, or write the answer as the reply itself.")
|
|
695
|
+
_REASONING_ONLY_AGAIN = (
|
|
696
|
+
"The model replied with reasoning only again after the harness asked, "
|
|
697
|
+
"so this turn ends without an answer.")
|
|
698
|
+
_REASONING_ONLY_LAST_STEP = (
|
|
699
|
+
"The model replied with reasoning only on the last step this turn "
|
|
700
|
+
"allows, so it ends without an answer.")
|
|
701
|
+
# (provider, model) pairs whose echo hint was logged this process (RO7).
|
|
702
|
+
# Keyed like context_limit()'s warn-once set and for its reason: a session
|
|
703
|
+
# that switches model must still hear about the second one.
|
|
704
|
+
_reasoning_only_warned: set = set()
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
def _reasoning_only(response) -> bool:
|
|
708
|
+
"""RO1. Readable reasoning, no text and no tool call.
|
|
709
|
+
|
|
710
|
+
READABLE reasoning, through the replay's own reader: a Google signature
|
|
711
|
+
block or Anthropic's `redacted_thinking` carries no prose, and a step
|
|
712
|
+
that held only those had nothing in it to have gone missing. Text that
|
|
713
|
+
is only whitespace counts as none, because none of it reaches a person.
|
|
714
|
+
"""
|
|
715
|
+
return (not response.tool_calls
|
|
716
|
+
and not (response.text or "").strip()
|
|
717
|
+
and bool(reasoning_text(response.thinking)))
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
def _reasoning_only_reply(memory, provider_name, model, notices, *,
|
|
721
|
+
nudge: bool, again: bool):
|
|
722
|
+
"""RO2/RO5. Ask the model once more, or say why the turn ends here.
|
|
723
|
+
|
|
724
|
+
Persist before emit (#42): the harness row is written before the
|
|
725
|
+
notice that describes it is yielded. The row is a user-role entry
|
|
726
|
+
because that is the only shape the model can be handed between two
|
|
727
|
+
steps on every wire, and `mid_turn` keeps it from opening a turn (RO3):
|
|
728
|
+
the compaction floor and the reopening request both read a user row as
|
|
729
|
+
the start of one.
|
|
730
|
+
"""
|
|
731
|
+
key = (provider_name, model)
|
|
732
|
+
if key not in _reasoning_only_warned and reasoning_not_echoed(
|
|
733
|
+
provider_name):
|
|
734
|
+
_reasoning_only_warned.add(key)
|
|
735
|
+
logger.warning(
|
|
736
|
+
"%s/%s replied with reasoning only: no text and no tool call. "
|
|
737
|
+
"Some models expect their earlier reasoning back during a tool "
|
|
738
|
+
"loop; if this one does, set \"echoes_reasoning\": true for %s "
|
|
739
|
+
"in providers.json.", provider_name, model, provider_name)
|
|
740
|
+
if nudge:
|
|
741
|
+
memory.add_harness_message(
|
|
742
|
+
_REASONING_ONLY_NUDGE,
|
|
743
|
+
{"kind": HARNESS_REASONING_ONLY, "mid_turn": True})
|
|
744
|
+
notice = {"kind": HARNESS_REASONING_ONLY,
|
|
745
|
+
"text": REASONING_ONLY_HEADER}
|
|
746
|
+
else:
|
|
747
|
+
notice = {"kind": REASONING_ONLY_END,
|
|
748
|
+
"text": (_REASONING_ONLY_AGAIN if again
|
|
749
|
+
else _REASONING_ONLY_LAST_STEP)}
|
|
750
|
+
notices.append(notice)
|
|
751
|
+
yield LoopEvent(notice=notice)
|
|
752
|
+
|
|
753
|
+
|
|
671
754
|
def _compactor_depth(context) -> int:
|
|
672
755
|
"""Where a compaction started from THIS loop sits in the agent stack.
|
|
673
756
|
|
|
@@ -1894,7 +1977,12 @@ class RunAgentLoop:
|
|
|
1894
1977
|
activity=activity, depth=_compactor_depth(context))
|
|
1895
1978
|
|
|
1896
1979
|
response = None
|
|
1897
|
-
|
|
1980
|
+
# ROADMAP_v3 §95 (RO2). Whether this run has already asked the model
|
|
1981
|
+
# to follow a reasoning-only reply. ONE ask per run: a model that
|
|
1982
|
+
# answers the ask with reasoning only again is not going to be
|
|
1983
|
+
# talked out of it by a second, and every ask is a billed step.
|
|
1984
|
+
nudged = False
|
|
1985
|
+
for step in range(max_steps):
|
|
1898
1986
|
# §61 CN2, the step boundary -- and ABOVE the reset below,
|
|
1899
1987
|
# which is the whole reason it sits here rather than at the
|
|
1900
1988
|
# foot of the body. The response it reads is the PREVIOUS
|
|
@@ -2065,6 +2153,18 @@ class RunAgentLoop:
|
|
|
2065
2153
|
return
|
|
2066
2154
|
|
|
2067
2155
|
if not response.tool_calls:
|
|
2156
|
+
# ROADMAP_v3 §95. Below D20 and the budget stop, so the
|
|
2157
|
+
# reasoning-only step is persisted and paid for exactly
|
|
2158
|
+
# like any other, and a turn already over budget stops
|
|
2159
|
+
# rather than spending a step on the ask.
|
|
2160
|
+
if _reasoning_only(response):
|
|
2161
|
+
ask = not nudged and step < max_steps - 1
|
|
2162
|
+
yield from _reasoning_only_reply(
|
|
2163
|
+
memory, provider_name, model, notices,
|
|
2164
|
+
nudge=ask, again=nudged)
|
|
2165
|
+
if ask:
|
|
2166
|
+
nudged = True
|
|
2167
|
+
continue
|
|
2068
2168
|
response.stop_reason = "complete"
|
|
2069
2169
|
yield LoopEvent(
|
|
2070
2170
|
final_response=response, stop_reason=response.stop_reason,
|
package/core/memory.py
CHANGED
|
@@ -57,6 +57,7 @@ from storage import (
|
|
|
57
57
|
pinned_through,
|
|
58
58
|
save_message,
|
|
59
59
|
set_pinned,
|
|
60
|
+
starts_turn,
|
|
60
61
|
turn_start_ids,
|
|
61
62
|
update_thread_extra,
|
|
62
63
|
)
|
|
@@ -366,7 +367,9 @@ class ConversationMemory:
|
|
|
366
367
|
"""
|
|
367
368
|
mark_turn_failed(self.thread_id, error)
|
|
368
369
|
for entry in reversed(self._messages):
|
|
369
|
-
|
|
370
|
+
# The row storage chose (ROADMAP_v3 §95, RO3): a harness row
|
|
371
|
+
# the loop wrote inside the run did not start it.
|
|
372
|
+
if starts_turn(entry):
|
|
370
373
|
entry["error"] = error
|
|
371
374
|
break
|
|
372
375
|
|
|
@@ -204,6 +204,21 @@ def _check(raw_text: str, validate: Optional[Callable]) -> None:
|
|
|
204
204
|
|
|
205
205
|
|
|
206
206
|
def _parse_corrective(error: ValueError, raw_text: str) -> str:
|
|
207
|
+
if not raw_text.strip():
|
|
208
|
+
# ROADMAP_v3 §95 (RO6). Nothing to quote, and quoting nothing under
|
|
209
|
+
# "Start of your failed output" was measured to mislead: a model
|
|
210
|
+
# whose whole reply had arrived as reasoning read the empty quote
|
|
211
|
+
# as its reasoning being the invalid output, and resolved to stop
|
|
212
|
+
# reasoning. Say what the harness actually received.
|
|
213
|
+
return (
|
|
214
|
+
"Your last response contained no text at all, so there was no "
|
|
215
|
+
"JSON to parse. Anything written only in your reasoning is not "
|
|
216
|
+
"part of the response, and a tool call written there is not "
|
|
217
|
+
"run.\n\n"
|
|
218
|
+
"Respond again with ONLY valid JSON -- no preamble, no prose, "
|
|
219
|
+
"no code fence, just the JSON your original instructions "
|
|
220
|
+
"asked for."
|
|
221
|
+
)
|
|
207
222
|
return (
|
|
208
223
|
f"Your last response did not parse as valid JSON.\n\n"
|
|
209
224
|
f"Parse error:\n{error}\n\n"
|
|
@@ -225,7 +225,10 @@ def _translate(pass_id: str, stream, corpus=None):
|
|
|
225
225
|
second rendering of a question already on
|
|
226
226
|
screen is not observability.
|
|
227
227
|
notice a pass's compaction notices, forwarded as
|
|
228
|
-
trace LINES
|
|
228
|
+
trace LINES -- and since §95 its
|
|
229
|
+
reasoning-only notices, labelled `notice`
|
|
230
|
+
rather than `compaction` (RO8). M6 makes
|
|
231
|
+
the compaction ones backstop-only,
|
|
229
232
|
but "rare" is not "silent" -- §21's rule
|
|
230
233
|
has no exception for the pipeline, and a
|
|
231
234
|
backstop fold rewrites what the REST of
|
|
@@ -266,9 +269,15 @@ def _translate(pass_id: str, stream, corpus=None):
|
|
|
266
269
|
yield PipelineEvent(kind="pass_activity", pass_id=pass_id,
|
|
267
270
|
chars=streamed)
|
|
268
271
|
if event.notice:
|
|
272
|
+
# ROADMAP_v3 §95 (RO8). Labelled by what the notice IS: the loop
|
|
273
|
+
# emits a reasoning-only notice inside a pass too, and the trace
|
|
274
|
+
# called every notice a compaction.
|
|
275
|
+
what = ("compaction"
|
|
276
|
+
if str(event.notice.get("kind", "")).startswith(
|
|
277
|
+
"compaction") else "notice")
|
|
269
278
|
yield PipelineEvent(
|
|
270
279
|
kind="trace_line",
|
|
271
|
-
text=f"
|
|
280
|
+
text=f"{what} during {pass_id}: {event.notice['text']}")
|
|
272
281
|
if event.tool_call_start:
|
|
273
282
|
name = event.tool_call_start.get("name")
|
|
274
283
|
names[event.tool_call_start.get("id")] = name
|
package/main.py
CHANGED
|
@@ -57,6 +57,8 @@ from core import ansi, config_loader, shell_sessions, workspace_trust
|
|
|
57
57
|
from core.cancel import CancelToken
|
|
58
58
|
from core.loop import (
|
|
59
59
|
DEFAULT_PROVIDER,
|
|
60
|
+
HARNESS_REASONING_ONLY,
|
|
61
|
+
REASONING_ONLY_END,
|
|
60
62
|
RunAgentLoop,
|
|
61
63
|
advertisement_facts,
|
|
62
64
|
agent_turn,
|
|
@@ -245,6 +247,10 @@ class _LiveTurn:
|
|
|
245
247
|
# is popped out of its result and referenced by nothing else, so
|
|
246
248
|
# its id could be reused by a later one.
|
|
247
249
|
self._noticed: list = []
|
|
250
|
+
# ROADMAP_v3 §95 (RO5). The turn's last step already printed, ahead
|
|
251
|
+
# of the notice saying it ended the turn; `finish` then has only
|
|
252
|
+
# the notices left to print.
|
|
253
|
+
self._final_printed = False
|
|
248
254
|
|
|
249
255
|
def __call__(self, event) -> None:
|
|
250
256
|
try:
|
|
@@ -282,7 +288,25 @@ class _LiveTurn:
|
|
|
282
288
|
return
|
|
283
289
|
self._noticed.append(notice)
|
|
284
290
|
text = notice.get("text") if isinstance(notice, dict) else None
|
|
285
|
-
if
|
|
291
|
+
kind = notice.get("kind") if isinstance(notice, dict) else None
|
|
292
|
+
if kind in (HARNESS_REASONING_ONLY, REASONING_ONLY_END):
|
|
293
|
+
# ROADMAP_v3 §95 (RO5). Both describe the step that just
|
|
294
|
+
# FINISHED with no tool call, so nothing else will print it:
|
|
295
|
+
# print it first, in the order a replay draws it. Only what
|
|
296
|
+
# streamed -- a turn nobody watched has nothing held, and its
|
|
297
|
+
# last step still prints at `finish`.
|
|
298
|
+
reasoning = "".join(self._reasoning).strip()
|
|
299
|
+
held_text = "".join(self._text)
|
|
300
|
+
if reasoning or held_text:
|
|
301
|
+
self._step(reasoning, held_text, [])
|
|
302
|
+
self._final_printed = kind == REASONING_ONLY_END
|
|
303
|
+
if not text:
|
|
304
|
+
return
|
|
305
|
+
if kind == HARNESS_REASONING_ONLY:
|
|
306
|
+
# The first line of the row the harness wrote, which a replay
|
|
307
|
+
# prints in this role.
|
|
308
|
+
_print_entry("wake", text)
|
|
309
|
+
else:
|
|
286
310
|
print(f"— {ansi.for_display(text)} —")
|
|
287
311
|
|
|
288
312
|
def finish(self, response) -> None:
|
|
@@ -295,10 +319,13 @@ class _LiveTurn:
|
|
|
295
319
|
self._notice(notice)
|
|
296
320
|
calls = [{"id": c.id, "name": c.name, "input": c.input}
|
|
297
321
|
for c in getattr(response, "tool_calls", None) or ()]
|
|
298
|
-
if any(c["id"] in self._announced
|
|
322
|
+
if self._final_printed or any(c["id"] in self._announced
|
|
323
|
+
for c in calls):
|
|
299
324
|
# This step's reasoning and text printed with its first tool
|
|
300
325
|
# line: the turn ran out of steps or was stopped between its
|
|
301
|
-
# tool calls, after the step itself had finished.
|
|
326
|
+
# tool calls, after the step itself had finished. Or, since
|
|
327
|
+
# §95, ahead of the notice that its reasoning-only reply ended
|
|
328
|
+
# the turn.
|
|
302
329
|
reasoning, text = "", ""
|
|
303
330
|
else:
|
|
304
331
|
reasoning = reasoning_text(getattr(response, "thinking", None))
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -18,7 +18,7 @@ build-backend = "setuptools.build_meta"
|
|
|
18
18
|
|
|
19
19
|
[project]
|
|
20
20
|
name = "venastine-research-harness"
|
|
21
|
-
version = "0.3.
|
|
21
|
+
version = "0.3.14"
|
|
22
22
|
description = "A from-scratch agentic harness: tool-using chat plus a ten-pass self-critiquing research pipeline."
|
|
23
23
|
readme = "README.md"
|
|
24
24
|
# The same words as package.json's `keywords`, in the same order: what a
|
package/storage.py
CHANGED
|
@@ -660,6 +660,36 @@ def _decode_harness(raw):
|
|
|
660
660
|
return value if isinstance(value, dict) and value.get("kind") else None
|
|
661
661
|
|
|
662
662
|
|
|
663
|
+
def starts_turn(row: dict) -> bool:
|
|
664
|
+
"""Whether this row OPENS a turn: a user row, unless the harness wrote it
|
|
665
|
+
inside one (ROADMAP_v3 §95, RO3).
|
|
666
|
+
|
|
667
|
+
A turn starts at a user message -- the wrapper adds one, then the loop
|
|
668
|
+
appends assistant and tool rows until it stops -- and six readers were
|
|
669
|
+
written on that rule: the turn list behind `completed_turns`, the fold
|
|
670
|
+
boundaries and the pin cap in core/compaction.py, the request a
|
|
671
|
+
mid-turn watermark re-adds, and the row a failure is recorded on, here
|
|
672
|
+
and in core/memory.py. Since §95 the loop can write a user row
|
|
673
|
+
INSIDE a turn, to ask the model to follow a reasoning-only reply, and
|
|
674
|
+
such a row carries `mid_turn: true` in its harness record. Read as a
|
|
675
|
+
turn start, it would move the current-turn floor past the turn's own
|
|
676
|
+
earlier steps while the turn is still running -- the floor the mid-turn
|
|
677
|
+
compaction valve calls safe by construction -- and a mid-turn
|
|
678
|
+
watermark would re-add it in place of the person's request.
|
|
679
|
+
|
|
680
|
+
Takes either shape: an `_ordered_rows` dict, whose `harness` is the
|
|
681
|
+
stored JSON string, or a neutral message, whose `harness` is decoded.
|
|
682
|
+
`is True`, A29's rule: a record carrying a quoted "true" still opens a
|
|
683
|
+
turn, as every harness row did before §95.
|
|
684
|
+
"""
|
|
685
|
+
if row.get("role") != "user":
|
|
686
|
+
return False
|
|
687
|
+
harness = row.get("harness")
|
|
688
|
+
if isinstance(harness, str):
|
|
689
|
+
harness = _decode_harness(harness)
|
|
690
|
+
return not (isinstance(harness, dict) and harness.get("mid_turn") is True)
|
|
691
|
+
|
|
692
|
+
|
|
663
693
|
def _decode_images(raw):
|
|
664
694
|
"""A tool row's stored images (ROADMAP_v3 §81, IM2), or None.
|
|
665
695
|
|
|
@@ -874,10 +904,10 @@ def _turn_opener_index(rows: list[dict], span: list[dict]) -> list[int]:
|
|
|
874
904
|
"""
|
|
875
905
|
if not span or len(span) >= len(rows):
|
|
876
906
|
return []
|
|
877
|
-
if rows[len(span)]
|
|
907
|
+
if starts_turn(rows[len(span)]):
|
|
878
908
|
return []
|
|
879
909
|
for index in range(len(span) - 1, -1, -1):
|
|
880
|
-
if span[index]
|
|
910
|
+
if starts_turn(span[index]):
|
|
881
911
|
return [index]
|
|
882
912
|
return []
|
|
883
913
|
|
|
@@ -995,13 +1025,14 @@ def turn_start_ids(thread_id: UUID) -> list[UUID]:
|
|
|
995
1025
|
"""Ids of the rows that BEGIN each turn, oldest first.
|
|
996
1026
|
|
|
997
1027
|
A turn starts at a user message: the wrapper adds one, then the loop
|
|
998
|
-
appends assistant and tool rows until it stops.
|
|
1028
|
+
appends assistant and tool rows until it stops. `starts_turn` says
|
|
1029
|
+
which user rows, since §95 wrote one inside a turn. §21's M4 needs this
|
|
999
1030
|
because a fold boundary that lands anywhere else can separate an
|
|
1000
1031
|
assistant message from its tool results, and a tool_result with no
|
|
1001
1032
|
preceding tool_use is an HTTP 400 on Anthropic -- a hard wire error,
|
|
1002
1033
|
not a degraded answer. M5's "keep the last N turns" needs it too.
|
|
1003
1034
|
"""
|
|
1004
|
-
return [m["id"] for m in _ordered_rows(thread_id) if m
|
|
1035
|
+
return [m["id"] for m in _ordered_rows(thread_id) if starts_turn(m)]
|
|
1005
1036
|
|
|
1006
1037
|
|
|
1007
1038
|
def message_ids_from(thread_id: UUID, message_id: UUID) -> list[UUID]:
|
|
@@ -1047,6 +1078,10 @@ def mark_turn_failed(thread_id: UUID, error: str) -> bool:
|
|
|
1047
1078
|
|
|
1048
1079
|
Returns False for a thread with no user row. Does not stamp
|
|
1049
1080
|
last_activity_at the way save_message does: a failure is not a message.
|
|
1081
|
+
|
|
1082
|
+
The newest row that STARTS a turn (ROADMAP_v3 §95, RO3), which skips a
|
|
1083
|
+
harness row the loop wrote inside the run -- the run did not start
|
|
1084
|
+
there, and replay draws the failure under the request that did.
|
|
1050
1085
|
"""
|
|
1051
1086
|
with Session(engine) as session:
|
|
1052
1087
|
statement = (
|
|
@@ -1055,7 +1090,9 @@ def mark_turn_failed(thread_id: UUID, error: str) -> bool:
|
|
|
1055
1090
|
.where(MessageLog.role == "user")
|
|
1056
1091
|
.order_by(MessageLog.created_at.desc(), MessageLog.id.desc())
|
|
1057
1092
|
)
|
|
1058
|
-
row = session.exec(statement)
|
|
1093
|
+
row = next((candidate for candidate in session.exec(statement)
|
|
1094
|
+
if starts_turn({"role": candidate.role,
|
|
1095
|
+
"harness": candidate.harness})), None)
|
|
1059
1096
|
if row is None:
|
|
1060
1097
|
return False
|
|
1061
1098
|
row.error = error
|
package/tui/app.py
CHANGED
|
@@ -71,6 +71,7 @@ from core.file_mentions import FileIndex, active_mention
|
|
|
71
71
|
from core.loop import (
|
|
72
72
|
DEFAULT_PROVIDER,
|
|
73
73
|
DEFAULT_SYSTEM_PROMPT,
|
|
74
|
+
HARNESS_REASONING_ONLY,
|
|
74
75
|
RunAgentLoop,
|
|
75
76
|
advertisement_facts,
|
|
76
77
|
agent_turn,
|
|
@@ -3522,6 +3523,13 @@ class VenastineApp(App):
|
|
|
3522
3523
|
elif notice["kind"] in ("compaction_failed",
|
|
3523
3524
|
"compaction_blocked"):
|
|
3524
3525
|
transcript.write_error(f"— {notice['text']} —")
|
|
3526
|
+
elif notice["kind"] == HARNESS_REASONING_ONLY:
|
|
3527
|
+
# ROADMAP_v3 §95 (RO5). The harness wrote a row asking the
|
|
3528
|
+
# model to follow its reasoning-only reply, and this notice's
|
|
3529
|
+
# text IS that row's first line -- so it is drawn the way
|
|
3530
|
+
# replay draws the row, and a resumed thread shows the line
|
|
3531
|
+
# the live turn showed, in the same role.
|
|
3532
|
+
transcript.write_role("wake", notice["text"])
|
|
3525
3533
|
else:
|
|
3526
3534
|
transcript.write_system(f"— {notice['text']} —")
|
|
3527
3535
|
|