The chat loop replays the workspace note as the "workspace" runtime
snapshot, which lives inside the cached prompt prefix. The note embedded
workspace.logical_output_dir — outputs/chat/<session>/<turn>/ — so its
bytes changed on every turn: the snapshot-replace logic cut the old copy
out of the middle of the rebuilt history and appended a fresh one,
invalidating the provider prompt cache on every multi-turn request
(cached-token hit rate <1%; single-turn tool loops were unaffected).
- workspace_system_note(state_turn_path=False) keeps the replayed chat
snapshot byte-identical for the whole session and points at the current
user message for the exact path instead.
- new workspace_turn_note() delivers the per-turn output folder in the
trailing user message — fresh bytes each turn, so cache-safe by
construction.
- phase-built prompts (question/research pipelines) keep embedding the
exact path via the default state_turn_path=True; their behavior is
unchanged.
- model-history reconstruction keeps an exact prefix once snapshots are
stable; new multi-turn replay tests assert byte-level prefix extension
across three consecutive turns, plus the second factor named in the
issue turns out to be a consequence of the turn-scoped snapshot and
needs no separate change.
Verified: tests/agents/chat 273 passed; tests/capabilities 739 passed;
tests/services/workspace+session 709 passed (8 failures pre-exist on the
clean tree and are unrelated); remaining tests/agents failures pre-exist.
Ship a content workspace you choose, one exec tool for every language,
Mastery Path modes that gate its tools, and Settings that grades
readiness instead of listing faults.
Release notes: assets/releases/ver1-6-5.md
* fix(sandbox): support Windows code execution
* refactor(sandbox): vary only the shell clause in the workspace note
The Windows branch duplicated the whole workspace paragraph, so the note
existed in four near-identical copies (zh/en x posix/windows) that would drift
apart on the next edit. Only the "how do I get a script into a file" clause
actually depends on the host shell, so vary that clause and keep one template
per language.
Also prefer `pwsh` (PowerShell 7+) when it is on PATH — it defaults to UTF-8
and is the version still receiving updates; the generated commands are written
in 5.1-compatible syntax, which 7 accepts too. And hoist `import sys` to module
scope now that two methods need it.
Adds the tests this note never had: each host gets the syntax that works there
(a Bash heredoc is a syntax error in PowerShell, and the model would silently
produce no file), and the host-independent half stays byte-identical.
---------
Co-authored-by: Frank <bingxizhao@novix.science>