mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-06 05:17:15 +00:00
refactor(agent): share the marker count fragment and retarget the old regex comment
The dispatch guard now uses _COMPRESSION_MARKER_ARTIFACT_RE, so the comment on _COMPRESSION_MARKER_RE no longer describes its job: only renderer tests use it to assert a complete first sentence. Say that, and keep the editability reasoning on the artifact regex alone. The count fragment was typed three times; a single _MARKER_COUNT_RE keeps the matchers derived rather than re-typed, as the module docstring promises. No behaviour change.
This commit is contained in:
1 parent
e50d585b22
commit
0e805041d5
1 file changed
+8
-5
@@ -24,12 +24,15 @@ _COMPRESSION_MARKER_TEMPLATE = (
|
||||
"output — always write full, untruncated content.⟫"
|
||||
)
|
||||
|
||||
# A minted marker (prefix + rendered counts through the first sentence). The prefix alone
|
||||
# does not match, so source/docs that mention the constant can still be edited.
|
||||
# A rendered omitted/total count inside a minted marker.
|
||||
_MARKER_COUNT_RE = r"\d[\d,]*"
|
||||
|
||||
# Full rendered first sentence of a minted marker; renderer tests assert this shape
|
||||
# (the dispatch guard uses _COMPRESSION_MARKER_ARTIFACT_RE below).
|
||||
_COMPRESSION_MARKER_RE = re.compile(
|
||||
re.escape(_COMPRESSION_MARKER_TEMPLATE.split(". ", 1)[0] + ".")
|
||||
.replace(re.escape("{omitted:,}"), r"\d[\d,]*")
|
||||
.replace(re.escape("{total:,}"), r"\d[\d,]*")
|
||||
.replace(re.escape("{omitted:,}"), _MARKER_COUNT_RE)
|
||||
.replace(re.escape("{total:,}"), _MARKER_COUNT_RE)
|
||||
)
|
||||
|
||||
# A marker cut by a later boundary may never reach the fixed sentence above. The
|
||||
@@ -37,7 +40,7 @@ _COMPRESSION_MARKER_RE = re.compile(
|
||||
# count is present. Requiring that rendered count keeps the bare prefix/template
|
||||
# editable in source and documentation.
|
||||
_COMPRESSION_MARKER_ARTIFACT_RE = re.compile(
|
||||
re.escape(_COMPRESSION_MARKER_PREFIX) + r"\s+\d[\d,]*"
|
||||
re.escape(_COMPRESSION_MARKER_PREFIX) + r"\s+" + _MARKER_COUNT_RE
|
||||
)
|
||||
|
||||
# #121548 — every OTHER model-visible elision (turn text, summaries, skill bodies, diagnostics)
|
||||
|
||||
Reference in new issue
Block a user