Skip to content

Pr/74 - #91

Merged
AmanCode22 merged 6 commits into
AmanCode22:mainfrom
merfiDEV:pr/74
Nov 6, 2026
Merged

AmanCode22 merged 6 commits into
AmanCode22:mainfrom
merfiDEV:pr/74

Conversation

@merfiDEV

Copy link
Copy Markdown
Contributor

its a pr #74 but ruff fixed

ItszFinn and others added 4 commits October 25, 2026 11:08
The web model occasionally degenerates and emits DSML tool-call markers with a
stray character between the fullwidth bars, e.g. "<|触|DSML|| calls>", or
floods bare "</||DSML||>" closers. These variants don't match the structured
DSML regexes (which expect clean ||DSML), so they leak into the reply text
(seen live via a chat client).

Add a catch-all `_FULLWIDTH_PIPE_TAG_RE` that strips any `<...>` token containing
a fullwidth pipe U+FF5C — which never appears in legitimate prose — in the
prose/leftover paths (`_strip_stray_markers`, `_strip_wrapper_tags`), i.e. after
tool extraction. ASCII '|' is deliberately left untouched (tables, code). The
streaming holdback in `StreamToolParser.feed` also keeps an unclosed '<' tail
that already contains a U+FF5C, so a split corrupted marker is never emitted as
prose before the catch-all can strip it.

Tests cover the prose, streaming, split-across-chunks, and ASCII-pipe-preserved
cases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The catch-all cleaned leaked DSML markers from reply prose, but corrupted
markers also land INSIDE tool-call argument values — e.g. a path parsed as
"shell/core/Theme.qml</||DSML|| >" — which makes the tool call fail (file not
found). Sanitize every string argument in `normalize_tool_call` (all tool calls
route through it) with the same fullwidth-pipe catch-all. Only strings that
actually contain U+FF5C are touched (recurses into dicts/lists), so normal
arguments and ASCII '|' are untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e text

The model occasionally emitted a raw shell command or script as its normal
message content (shown to the user but never executed) instead of a tool call —
e.g. a bare "cd … && python3 - <<'EOF' … EOF" delivered straight to the chat.
The DSML format block alone did not rule this out. Add an explicit directive:
to run a shell command, Python or any code the model MUST use a tool call, and
must never write a command/script/code block as message text. Prompt-level, so
it also helps the streaming path (changes what the model emits, not parsing).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Group the `functions` imports consistently in `app.py` and place the test helper import before `functions` in the incomplete-status tests.
@AmanCode22

Copy link
Copy Markdown
Owner

@merfiDEV kindly resolve merge conflict

@AmanCode22

Copy link
Copy Markdown
Owner

And kindly ensure while fixing conflicts you don't break any ruff check for cleaner codebase

@AmanCode22

Copy link
Copy Markdown
Owner

@merfiDEV kindly fix conflicts

- Resolved conflicts in app.py (added reply_id import)
- Resolved conflicts in tests/test_dsml_leaks.py (kept both test sets)
- Includes upstream hardening fixes (PR AmanCode22#94)
- All tests passing (26 tests in test_dsml_leaks.py)
- All ruff checks passing
@AmanCode22
AmanCode22 merged commit 9d691fb into AmanCode22:main Nov 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants