@yahyahammad/venastine 0.3.13 → 0.3.15
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 +12 -12
- package/config.py +3 -1
- package/core/client.py +21 -2
- package/core/compaction.py +11 -5
- package/core/config_loader.py +1 -1
- package/core/interaction.py +1 -1
- package/core/loop.py +104 -4
- package/core/memory.py +4 -1
- package/core/pipeline_models.py +10 -10
- package/core/reasoning/json_retry.py +15 -0
- package/core/reasoning/orchestrator.py +14 -5
- package/core/reasoning/review.py +1 -1
- package/core/reasoning/source_scoring.py +1 -1
- package/logging_setup.py +1 -1
- package/main.py +39 -12
- package/mcp_client/client.py +1 -1
- package/memories/manager.py +1 -1
- package/package.json +1 -1
- package/project_init/config_files.py +4 -4
- package/pyproject.toml +1 -1
- package/security/posture.py +14 -13
- package/security/sandbox.py +1 -1
- package/storage.py +42 -5
- package/tools/builtin/file_ops.py +1 -1
- package/tools/builtin/shell.py +5 -5
- package/tools/builtin/shell_sessions.py +1 -1
- package/tui/app.py +15 -6
- package/tui/themes.py +129 -8
- package/tui/widgets.py +1 -1
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))
|
|
@@ -368,7 +395,7 @@ def _announce_posture() -> None:
|
|
|
368
395
|
app.log and, on the CLI, to stderr through the root handler -- it is
|
|
369
396
|
the record a bug report is triaged against. The stderr banner is for
|
|
370
397
|
the human at the terminal, who may have set one of these months ago
|
|
371
|
-
and forgotten, or may have inherited a config.
|
|
398
|
+
and forgotten, or may have inherited a config.yaml from somewhere.
|
|
372
399
|
|
|
373
400
|
Silent when the posture is shipped, so this costs nothing in the case
|
|
374
401
|
that needs nothing said. That is also why it reads `unsafe_reasons()`
|
|
@@ -381,7 +408,7 @@ def _announce_posture() -> None:
|
|
|
381
408
|
if not reasons:
|
|
382
409
|
return
|
|
383
410
|
print("", file=sys.stderr)
|
|
384
|
-
print(" !! REDUCED SECURITY POSTURE -- set in config.
|
|
411
|
+
print(" !! REDUCED SECURITY POSTURE -- set in config.yaml", file=sys.stderr)
|
|
385
412
|
for _label, detail in reasons:
|
|
386
413
|
logger.warning("Reduced security posture: %s", detail)
|
|
387
414
|
print(f" - {detail}", file=sys.stderr)
|
|
@@ -2206,7 +2233,7 @@ def run_research(
|
|
|
2206
2233
|
"""Run the full deep-research pipeline, write artifacts to disk,
|
|
2207
2234
|
and print the results. ensemble_mode/ensemble_n come from
|
|
2208
2235
|
settings.json (§14); None means the pipeline falls back to the
|
|
2209
|
-
config.
|
|
2236
|
+
config.yaml defaults. authorization (§25) comes from
|
|
2210
2237
|
build_research_authorization(); None means no gated tool is reachable,
|
|
2211
2238
|
which is the behaviour every research run had before §25.
|
|
2212
2239
|
|
|
@@ -2367,7 +2394,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
2367
2394
|
)
|
|
2368
2395
|
# Defaults are None so that after parsing we can tell an explicit
|
|
2369
2396
|
# CLI choice from argparse fill-in; resolution happens in main via
|
|
2370
|
-
# resolve_runtime_defaults (CLI > settings.json > config.
|
|
2397
|
+
# resolve_runtime_defaults (CLI > settings.json > config.yaml).
|
|
2371
2398
|
parser.add_argument(
|
|
2372
2399
|
"--provider",
|
|
2373
2400
|
default=None,
|
|
@@ -2393,7 +2420,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
2393
2420
|
metavar="LEVEL",
|
|
2394
2421
|
help="Reasoning effort for chat AND research (typically "
|
|
2395
2422
|
"low|medium|high; 'auto' sends none). Default: settings.json "
|
|
2396
|
-
"'effort' key, else config.
|
|
2423
|
+
"'effort' key, else default_effort in config.yaml.",
|
|
2397
2424
|
)
|
|
2398
2425
|
# ROADMAP_v2 §25. TWO flags onto ONE dest, in a mutually exclusive
|
|
2399
2426
|
# group, rather than a single nargs="?" flag with an optional value.
|
|
@@ -2430,7 +2457,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
2430
2457
|
"Never persisted.",
|
|
2431
2458
|
)
|
|
2432
2459
|
# R9/R12. Default None so settings.json can supply it and an explicit
|
|
2433
|
-
# flag still wins (§14's CLI > settings.json > config.
|
|
2460
|
+
# flag still wins (§14's CLI > settings.json > config.yaml precedence,
|
|
2434
2461
|
# which only works because argparse defaults stay None).
|
|
2435
2462
|
#
|
|
2436
2463
|
# The MODE is persistable where the grant list is not, and the
|
|
@@ -2469,7 +2496,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
2469
2496
|
action="store_const",
|
|
2470
2497
|
const=False,
|
|
2471
2498
|
help="Research mode: skip the post-pipeline review even if "
|
|
2472
|
-
"settings.json or config.
|
|
2499
|
+
"settings.json or config.yaml turns it on.",
|
|
2473
2500
|
)
|
|
2474
2501
|
parser.add_argument(
|
|
2475
2502
|
"--tui",
|
|
@@ -2519,7 +2546,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
2519
2546
|
metavar="THREAD",
|
|
2520
2547
|
action="append",
|
|
2521
2548
|
help="Attach another thread's summary to this session as context. "
|
|
2522
|
-
"Repeatable, up to config.
|
|
2549
|
+
"Repeatable, up to max_injected_refs in config.yaml.",
|
|
2523
2550
|
)
|
|
2524
2551
|
# ROADMAP_v2 §24. A flag for M21's reason, and the two kind flags exist
|
|
2525
2552
|
# so a piped run can skip the question rather than being refused.
|
|
@@ -2557,7 +2584,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
2557
2584
|
def resolve_runtime_defaults(args, settings: dict) -> tuple[str, str]:
|
|
2558
2585
|
"""Provider/model precedence: explicit CLI flag > settings.json
|
|
2559
2586
|
(trusted project tier already beat user tier inside the loader) >
|
|
2560
|
-
config.
|
|
2587
|
+
config.yaml's values."""
|
|
2561
2588
|
provider = args.provider or settings.get("default_provider") or DEFAULT_PROVIDER
|
|
2562
2589
|
model = args.model or settings.get("default_model") or config.MODEL_NAME
|
|
2563
2590
|
return provider, model
|
package/mcp_client/client.py
CHANGED
|
@@ -70,7 +70,7 @@ SHUTDOWN_TIMEOUT_S = 15.0
|
|
|
70
70
|
# F6 (#64): the WHOLE teardown -- polite close, force-cancel, loop-thread
|
|
71
71
|
# join -- shares this one wall-clock budget, instead of three sequential
|
|
72
72
|
# SHUTDOWN_TIMEOUT_S waits whose worst case hung a quitting harness ~45s.
|
|
73
|
-
# Master value lives in config.
|
|
73
|
+
# Master value lives in config.yaml beside the other harness bounds; the
|
|
74
74
|
# re-export here keeps it beside its sibling timeouts and gives tests a
|
|
75
75
|
# single name to shrink.
|
|
76
76
|
TEARDOWN_BUDGET_S = _harness_config.TEARDOWN_BUDGET_S
|
package/memories/manager.py
CHANGED
|
@@ -131,7 +131,7 @@ class MemoryManager:
|
|
|
131
131
|
if total > cap:
|
|
132
132
|
logger.warning(
|
|
133
133
|
"Injecting %s of %s memories; the oldest %s are not in this "
|
|
134
|
-
"prompt. Raise config.
|
|
134
|
+
"prompt. Raise max_injected_memories in config.yaml or prune with "
|
|
135
135
|
"/forget.", cap, total, total - cap)
|
|
136
136
|
header = (f"{header}\n\nShowing the {cap} most recent of {total}. "
|
|
137
137
|
f"Older ones exist and are not listed here.")
|
package/package.json
CHANGED
|
@@ -106,9 +106,9 @@ OMITTED = {
|
|
|
106
106
|
"disagreement routes a claim to be checked and subtracts nothing, "
|
|
107
107
|
"and the loader warns when this is set",
|
|
108
108
|
"ensemble_mode":
|
|
109
|
-
"
|
|
110
|
-
"`false` is not a restatement of the default but a
|
|
111
|
-
"outrank whatever config.
|
|
109
|
+
"an unset value defers to config.yaml's own ensemble_mode, so "
|
|
110
|
+
"writing `false` is not a restatement of the default but a "
|
|
111
|
+
"decision to outrank whatever config.yaml says later",
|
|
112
112
|
"compaction.trigger_tokens":
|
|
113
113
|
"_trigger_is_configured() is a PRESENCE test: the window-derived "
|
|
114
114
|
"trigger only applies while no human has named a number. Writing "
|
|
@@ -117,7 +117,7 @@ OMITTED = {
|
|
|
117
117
|
"much earlier fold with nothing on screen to explain it",
|
|
118
118
|
"research.subagent_review":
|
|
119
119
|
"same `is not None` shape as ensemble_mode: an explicit false "
|
|
120
|
-
"beats config.
|
|
120
|
+
"beats config.yaml's subagent_review rather than deferring to it",
|
|
121
121
|
"tui.theme":
|
|
122
122
|
"no shipped default to write -- absent, _startup_theme() resolves "
|
|
123
123
|
"one -- and an invented value would outrank a theme the user "
|
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.15"
|
|
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/security/posture.py
CHANGED
|
@@ -19,9 +19,10 @@ the precedent: `tools/builtin/_math_common.py` exists because "an
|
|
|
19
19
|
expression string is code", and its docstring lists the escapes that were
|
|
20
20
|
found before the AST allowlist went in.
|
|
21
21
|
|
|
22
|
-
So the posture is bound once and frozen (UN1).
|
|
23
|
-
|
|
24
|
-
read at the moment a decision is
|
|
22
|
+
So the posture is bound once and frozen (UN1). `config.yaml` is still
|
|
23
|
+
where a HUMAN writes the value, and the `config.py` constants that
|
|
24
|
+
publish it simply stop being what is read at the moment a decision is
|
|
25
|
+
made.
|
|
25
26
|
|
|
26
27
|
WHAT THE GUARANTEE IS, AND IS NOT
|
|
27
28
|
---------------------------------
|
|
@@ -254,7 +255,7 @@ class Posture:
|
|
|
254
255
|
if self.shell_approval_mode == "never":
|
|
255
256
|
reasons.append((
|
|
256
257
|
"shell: never ask",
|
|
257
|
-
"
|
|
258
|
+
"shell_approval_mode is 'never' -- no shell command is "
|
|
258
259
|
"ever asked about, including one that reads outside the "
|
|
259
260
|
"workspace on the host"))
|
|
260
261
|
elif self.shell_approval_mode == "contained":
|
|
@@ -264,7 +265,7 @@ class Posture:
|
|
|
264
265
|
# holds a `.venastine/` that code can read it.
|
|
265
266
|
reasons.append((
|
|
266
267
|
"shell: contained",
|
|
267
|
-
"
|
|
268
|
+
"shell_approval_mode is 'contained' -- a command that runs "
|
|
268
269
|
"in the container without network runs without asking, "
|
|
269
270
|
"including code the agent wrote itself; host reads and "
|
|
270
271
|
"network commands still ask"))
|
|
@@ -279,7 +280,7 @@ class Posture:
|
|
|
279
280
|
"asks, as under tiered")
|
|
280
281
|
reasons.append((
|
|
281
282
|
"shell: classified",
|
|
282
|
-
"
|
|
283
|
+
"shell_approval_mode is 'classified' -- a decision model "
|
|
283
284
|
f"({who}) decides whether a single command that runs in the "
|
|
284
285
|
"container, and that tiered would ask about, runs without "
|
|
285
286
|
"asking; compound commands, host reads, the host fallback, "
|
|
@@ -293,14 +294,14 @@ class Posture:
|
|
|
293
294
|
and self.shell_approval_mode != "always"):
|
|
294
295
|
reasons.append((
|
|
295
296
|
"host shell, no ask",
|
|
296
|
-
"
|
|
297
|
-
"
|
|
297
|
+
"allow_insecure_sandbox_fallback and "
|
|
298
|
+
"auto_approve_sandbox_fallback are both on -- unprompted "
|
|
298
299
|
"arbitrary code on the host, with your own file access, "
|
|
299
300
|
"including writes into this harness's own source"))
|
|
300
301
|
elif self.allow_insecure_fallback:
|
|
301
302
|
reasons.append((
|
|
302
303
|
"host shell fallback",
|
|
303
|
-
"
|
|
304
|
+
"allow_insecure_sandbox_fallback is on -- if no container "
|
|
304
305
|
"runtime (Docker or Podman) can run the sandbox, commands "
|
|
305
306
|
"run on the host with no filesystem or network isolation"))
|
|
306
307
|
# ROADMAP_v3 §49 slice 3 (SS41). Reported when it is ENABLED rather
|
|
@@ -321,7 +322,7 @@ class Posture:
|
|
|
321
322
|
# this is §48 (CE6)'s correction applied to a second pair.
|
|
322
323
|
if (self.auto_approve_fallback
|
|
323
324
|
and self.shell_approval_mode not in ("always", "never")):
|
|
324
|
-
asking = ("
|
|
325
|
+
asking = ("auto_approve_sandbox_fallback is on as well, so "
|
|
325
326
|
"NOTHING there asks first -- that opt-in answers "
|
|
326
327
|
"for the whole backend, not only for the host "
|
|
327
328
|
"fallback it is named after. Running as root is "
|
|
@@ -332,7 +333,7 @@ class Posture:
|
|
|
332
333
|
"runs as root always asks")
|
|
333
334
|
reasons.append((
|
|
334
335
|
"wsl backend",
|
|
335
|
-
"
|
|
336
|
+
"allow_wsl_backend is on -- the agent can ask for a command "
|
|
336
337
|
"to run in WSL, which is not a sandbox: it reaches this "
|
|
337
338
|
"harness's own config and authority files, has no memory or "
|
|
338
339
|
"process limits, and can start Windows programs with your "
|
|
@@ -345,7 +346,7 @@ class Posture:
|
|
|
345
346
|
if self.allow_ssh_backend:
|
|
346
347
|
reasons.append((
|
|
347
348
|
"ssh backend",
|
|
348
|
-
"
|
|
349
|
+
"allow_ssh_backend is on -- the agent can ask for a command "
|
|
349
350
|
"to run on the configured remote host, which this harness "
|
|
350
351
|
"cannot inspect: no isolation, no memory or process limits, "
|
|
351
352
|
"and credentials it did not issue. Nothing runs there "
|
|
@@ -355,7 +356,7 @@ class Posture:
|
|
|
355
356
|
if not self.redact_tool_outputs:
|
|
356
357
|
reasons.append((
|
|
357
358
|
"no redaction",
|
|
358
|
-
"
|
|
359
|
+
"redact_tool_outputs is off -- credential-shaped strings "
|
|
359
360
|
"in tool results are passed through unredacted"))
|
|
360
361
|
elif self.redact_off_env:
|
|
361
362
|
reasons.append((
|
package/security/sandbox.py
CHANGED
|
@@ -3365,7 +3365,7 @@ def _unavailable_message(backend: str = BACKEND_CONTAINER) -> str:
|
|
|
3365
3365
|
return (
|
|
3366
3366
|
"No container runtime can run the sandbox"
|
|
3367
3367
|
+ (f" ({reason})" if reason else "")
|
|
3368
|
-
+ " and
|
|
3368
|
+
+ " and allow_insecure_sandbox_fallback is false. Install Docker or "
|
|
3369
3369
|
"Podman for strong isolation, or set "
|
|
3370
3370
|
"allow_insecure_sandbox_fallback: true in config.yaml to use the "
|
|
3371
3371
|
"weaker subprocess fallback (no filesystem isolation, no network "
|
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
|
|
@@ -281,7 +281,7 @@ def _read_rich(resolved_path: str) -> str:
|
|
|
281
281
|
consumer, it sits behind `read`, and `read` is globally denied and
|
|
282
282
|
cannot be re-enabled at runtime -- so a default install carries neither
|
|
283
283
|
it nor its eleven transitive distributions. Anyone who reaches here has
|
|
284
|
-
enabled `read` in config.
|
|
284
|
+
enabled `read` in config.yaml, and the bare ModuleNotFoundError would name
|
|
285
285
|
a package they never asked for and cannot place.
|
|
286
286
|
"""
|
|
287
287
|
try:
|
package/tools/builtin/shell.py
CHANGED
|
@@ -144,7 +144,7 @@ logger = logging.getLogger(__name__)
|
|
|
144
144
|
# read the posture at import time**, pinned by
|
|
145
145
|
# test_posture.py::test_no_module_reads_the_posture_at_import.
|
|
146
146
|
capability.validate_mode(config.SHELL_APPROVAL_MODE,
|
|
147
|
-
"config.
|
|
147
|
+
"shell_approval_mode in config.yaml")
|
|
148
148
|
|
|
149
149
|
# Compute the shell name once at import time to avoid blocking on
|
|
150
150
|
# subprocess probes every time the schema is accessed. On Windows this
|
|
@@ -625,7 +625,7 @@ def _shell_approval_check(tool_name: str, params: dict) -> bool:
|
|
|
625
625
|
"""
|
|
626
626
|
active = posture.current()
|
|
627
627
|
mode = capability.validate_mode(active.shell_approval_mode,
|
|
628
|
-
"config.
|
|
628
|
+
"shell_approval_mode in config.yaml")
|
|
629
629
|
if mode == capability.ALWAYS:
|
|
630
630
|
return True
|
|
631
631
|
if mode == capability.NEVER:
|
|
@@ -878,7 +878,7 @@ def _interactive_approval_check(tool_name: str, params: dict) -> bool:
|
|
|
878
878
|
"""
|
|
879
879
|
active = posture.current()
|
|
880
880
|
mode = capability.validate_mode(active.shell_approval_mode,
|
|
881
|
-
"config.
|
|
881
|
+
"shell_approval_mode in config.yaml")
|
|
882
882
|
if mode == capability.ALWAYS:
|
|
883
883
|
return True
|
|
884
884
|
if mode == capability.NEVER:
|
|
@@ -1055,8 +1055,8 @@ def fallback_changed_refusal(command: str, docker_up: bool) -> str | None:
|
|
|
1055
1055
|
if active.allow_insecure_fallback and not active.auto_approve_fallback:
|
|
1056
1056
|
return ("Docker became unavailable after the approval check. "
|
|
1057
1057
|
"The insecure subprocess fallback requires explicit "
|
|
1058
|
-
"per-run approval (
|
|
1059
|
-
"
|
|
1058
|
+
"per-run approval (auto_approve_sandbox_fallback is "
|
|
1059
|
+
"false in config.yaml). Please retry — the approval prompt will "
|
|
1060
1060
|
"appear this time.")
|
|
1061
1061
|
return None
|
|
1062
1062
|
|
|
@@ -455,7 +455,7 @@ def input_approval_check(tool_name: str, params: dict) -> bool:
|
|
|
455
455
|
return False
|
|
456
456
|
active = posture.current()
|
|
457
457
|
mode = capability.validate_mode(active.shell_approval_mode,
|
|
458
|
-
"config.
|
|
458
|
+
"shell_approval_mode in config.yaml")
|
|
459
459
|
if mode == capability.ALWAYS:
|
|
460
460
|
return True
|
|
461
461
|
if mode == capability.NEVER:
|
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,
|
|
@@ -943,7 +944,7 @@ class VenastineApp(App):
|
|
|
943
944
|
self._animations = tui_settings.get("animations", True)
|
|
944
945
|
# §38 (O6). Render a turn's reasoning inline, or collapse it to the
|
|
945
946
|
# animated one-line indicator. Defaulted HERE rather than in
|
|
946
|
-
# config.
|
|
947
|
+
# config.yaml, following `animations` immediately above: config.yaml
|
|
947
948
|
# holds no TUI values and is plain-values-only. /thinking flips it
|
|
948
949
|
# for the session and persists nothing, matching /effort.
|
|
949
950
|
self._show_thinking = tui_settings.get("show_thinking", True)
|
|
@@ -1543,7 +1544,7 @@ class VenastineApp(App):
|
|
|
1543
1544
|
from the trace.
|
|
1544
1545
|
|
|
1545
1546
|
"(remembered)" marks a pair restored from the preference store
|
|
1546
|
-
rather than resolved from settings.json or config.
|
|
1547
|
+
rather than resolved from settings.json or config.yaml (§43, RM3).
|
|
1547
1548
|
#138's rule: a launch should not have to be guessed at, and a
|
|
1548
1549
|
session silently coming up on a model no config file names is
|
|
1549
1550
|
exactly the confusion this feature would otherwise trade for the
|
|
@@ -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
|
|
|
@@ -6120,7 +6128,7 @@ def _cmd_window(app: VenastineApp, args: str) -> None:
|
|
|
6120
6128
|
# the best reason to have this command -- a gateway or a self-hosted
|
|
6121
6129
|
# endpoint can report its own default rather than the deployment's
|
|
6122
6130
|
# real window -- so refusing would block precisely the case it exists
|
|
6123
|
-
# for. The risk is named in the same terms config.
|
|
6131
|
+
# for. The risk is named in the same terms config.yaml uses for the qwen
|
|
6124
6132
|
# entry: erring high means a hard context-limit error mid-run.
|
|
6125
6133
|
reported = _reported_window(app)
|
|
6126
6134
|
if reported and tokens > reported:
|
|
@@ -6289,9 +6297,10 @@ def _report_override(app: VenastineApp, key: str) -> None:
|
|
|
6289
6297
|
elif _reported_window(app) is not None:
|
|
6290
6298
|
source = f"reported by {app.provider_name}"
|
|
6291
6299
|
elif compaction._normalized(app.model) in config.MODEL_CONTEXT_WINDOWS:
|
|
6292
|
-
source = "config.
|
|
6300
|
+
source = "model_context_windows in config.yaml"
|
|
6293
6301
|
else:
|
|
6294
|
-
source = "config.
|
|
6302
|
+
source = ("default_context_window in config.yaml "
|
|
6303
|
+
"(no entry for this model)")
|
|
6295
6304
|
app._transcript.write_system(
|
|
6296
6305
|
f"Context window: {effective:,} — {source}.")
|
|
6297
6306
|
app._transcript.write_system(
|
|
@@ -6646,7 +6655,7 @@ def _clear_pipeline_role(app: VenastineApp, role: str, label: str) -> None:
|
|
|
6646
6655
|
remaining = pipeline_models.resolve(role)
|
|
6647
6656
|
if remaining:
|
|
6648
6657
|
app._transcript.write_system(
|
|
6649
|
-
f"config.
|
|
6658
|
+
f"config.yaml still sets {label}: {remaining['provider_name']} | "
|
|
6650
6659
|
f"{remaining['model']}.")
|
|
6651
6660
|
|
|
6652
6661
|
|