mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 12:24:28 +01:00
patch-template: a template that can raise needs the tool-reference fix, and the CI's two misses
The guard on "raise_exception(" missed a space before the parenthesis and an alias of the function (third code review, 2026-10-26): a template that never names raise_exception is the only one left as it is now. The full CI then found what the stricter guard does to the fixtures: the shared template of tests/test_lean_level.py (which tests/test_flash_local_stage.py reads) and the one of tests/test_patch_template_default_kept.py had the anchors of the four older fixes but not the fifth's, which every pinned template has, and the patcher refused them. They carry it now, defined and not called, so their renders do not change. And shellcheck read Ornith's TEMPLATE_FIXES line as an array written with commas: it is one argument, which patch-template.py takes comma-separated, and the line says so to shellcheck.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2178683be7
commit
4abb34aa99
5 files changed
+25
-7
No files matched your search
@@ -138,6 +138,7 @@ render_unit(){
|
||||
# of its own (the proxy gives it one through enable_thinking), so those are its only fixes. Written again at every install and every switch, and left
|
||||
# as it is, mtime included, when nothing changed.
|
||||
TEMPLATE="$CONFIG_DIR/chat-template-ornith-122b.jinja"
|
||||
# shellcheck disable=SC2054 # one argument: patch-template.py takes its fixes' names comma-separated
|
||||
TEMPLATE_FIXES=(--patches=system-reminder,tool-reference)
|
||||
lane_template(){ vlane_template "$TEMPLATE" "${TEMPLATE_FIXES[@]}"; }
|
||||
|
||||
|
||||
+6
-5
@@ -129,11 +129,12 @@ TOOL_REF_PATCHED = (
|
||||
" {{- raise_exception('Unexpected item type in content.') }}\n"
|
||||
)
|
||||
TOOL_REF_MARKER = "item.type == 'tool_reference'"
|
||||
# A template is left as it is only when it raises nothing at all: a guard on the name of the macro
|
||||
# skipped the fix for a template that raises in a renamed macro or inline, and one on the error's words
|
||||
# for a template that words it otherwise, and the install went on with every turn after a ToolSearch a
|
||||
# 500 again (code reviews, 2026-10-26). One that raises anywhere the fix cannot reach stops the install.
|
||||
TOOL_REF_RAISE = "raise_exception("
|
||||
# A template is left as it is only when it never names raise_exception: a guard on the name of the macro
|
||||
# skipped the fix for a template that raises in a renamed macro or inline, one on the error's words for a
|
||||
# template that words it otherwise, and one on "raise_exception(" for a space before the parenthesis or an
|
||||
# alias of the function, and the install went on with every turn after a ToolSearch a 500 again (code
|
||||
# reviews, 2026-10-26). One that can raise anywhere the fix cannot reach stops the install.
|
||||
TOOL_REF_RAISE = "raise_exception"
|
||||
|
||||
|
||||
# The five fixes by name, in the order they are applied (--patches picks among them).
|
||||
|
||||
@@ -62,6 +62,17 @@ STOCK = (
|
||||
"{%- elif reasoning_instructions %}\n"
|
||||
"{{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n"
|
||||
"{%- endif %}\n"
|
||||
# the content loop the tool-reference fix anchors on, as the 27B's template has it: a template
|
||||
# that raises where that fix cannot reach stops the install (code reviews, 2026-10-26). Defined
|
||||
# and not called, it renders nothing.
|
||||
"{%- macro render_content(content) %}\n"
|
||||
" {%- for item in content %}\n"
|
||||
" {%- if 'image' in item %}\n"
|
||||
" {{- '<image>' }}\n"
|
||||
+ pt.TOOL_REF_ANCHOR
|
||||
+ " {%- endif %}\n"
|
||||
" {%- endfor %}\n"
|
||||
"{%- endmacro %}\n"
|
||||
# SYSTEM_ANCHOR opens an if inside the message loop; the fixture closes both
|
||||
# so the result is a template jinja2 can actually compile and render.
|
||||
"{%- for message in messages %}\n"
|
||||
|
||||
@@ -176,8 +176,12 @@ def main() -> None:
|
||||
"{{ raise_exception('Unexpected item type in content.') }}{%- endif %}{%- endfor %}", False),
|
||||
("{%- for item in content %}{%- if item.type == 'text' %}{{ item.text }}{%- else %}"
|
||||
"{{ raise_exception('Unexpected content item type: ' ~ item.type) }}{%- endif %}{%- endfor %}", False),
|
||||
("{%- for item in content %}{%- if item.type == 'text' %}{{ item.text }}{%- else %}"
|
||||
"{{ raise_exception ('Unknown item') }}{%- endif %}{%- endfor %}", False),
|
||||
("{%- set fail = raise_exception %}{%- for item in content %}{%- if item.type == 'text' %}"
|
||||
"{{ item.text }}{%- else %}{{ fail('Unknown item') }}{%- endif %}{%- endfor %}", False),
|
||||
("{%- for item in content %}{{ item.text }}{%- endfor %}", True))):
|
||||
other_repo, other_sha = "org/next-checkpoint", "abf"[n] * 40
|
||||
other_repo, other_sha = "org/next-checkpoint", "abcdf"[n] * 40
|
||||
make_fixture(base, other_repo, other_sha, body)
|
||||
other_out = os.path.join(base, f"next-{n}.jinja")
|
||||
r = subprocess.run([sys.executable, SCRIPT, "--patches=tool-reference", base, other_out, other_sha,
|
||||
|
||||
@@ -34,7 +34,8 @@ class TheDefaultIsKept(unittest.TestCase):
|
||||
snap = self.base / "hub" / "models--org--model" / "snapshots" / SHA
|
||||
snap.mkdir(parents=True)
|
||||
(snap / "chat_template.jinja").write_text(
|
||||
"HEAD\n" + pt.EFFORT_ANCHOR + "\n" + pt.MSG_ANCHOR + "\nMID\n" + pt.LEAN_ANCHOR + pt.SYSTEM_ANCHOR + "\nTAIL\n")
|
||||
"HEAD\n" + pt.EFFORT_ANCHOR + "\n" + pt.MSG_ANCHOR + "\nMID\n" + pt.LEAN_ANCHOR + pt.SYSTEM_ANCHOR
|
||||
+ "\n" + pt.TOOL_REF_ANCHOR + "\nTAIL\n") # the five anchors, as the 27B's template has them
|
||||
self.out = self.base / "out.jinja"
|
||||
|
||||
def run_patch(self, lean_default=None):
|
||||
|
||||
Reference in new issue
Block a user