Skip to content

fix(agent): accept emoji sign-offs as natural endings#14574

Open
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/ollama-glm-emoji-ending-14572
Open

fix(agent): accept emoji sign-offs as natural endings#14574
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/ollama-glm-emoji-ending-14572

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

Summary

  • treat emoji sign-offs as natural response endings for the Ollama/GLM stop-to-length heuristic
  • ignore trailing emoji joiners and modifiers before checking the terminal visible character
  • add a regression test covering a tool-using GLM reply that ends with 💛

Testing

  • python3 -m pytest -o addopts='' tests/run_agent/test_run_agent.py -q -k 'ollama_glm_stop or non_ollama_stop_without_terminal_boundary'

Closes #14572

@aj-nt

aj-nt commented May 14, 2026

Copy link
Copy Markdown

Nice fix! A couple of suggestions from our implementation (#25991, closed in favor of this one) that proved important in testing:

1. 500-character minimum gate

Most false positives come from short conversational replies ("Based on the results, the best next" — 39 chars), not just emoji. These short responses can't possibly hit token limits, so they're almost certainly complete. Adding a length gate eliminates the vast majority of false positives before we even check the ending character.

In _should_treat_stop_as_truncated(), after the existing 20-char guard:

if len(visible_text) < 500:
    return False

2. Config opt-out

Some users may want to disable the heuristic entirely. A config flag with default true (current behavior) lets them opt out. Read in __init__ from agent.glm_truncation_heuristic, checked at the top of _should_treat_stop_as_truncated().

Your _get_terminal_response_char helper is solid — we used unicodedata.category() to strip Mn/Me/Cf which covers the same ZWJ/VS16/skin-tone cases plus any future combining marks. Functional equivalent though.

Happy to help with either addition if useful.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Superseded by #28324 (merged), which is a salvage of #28168 and covers emoji + caret as natural response endings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ollama/GLM stop-to-length heuristic false-triggers on responses ending with emoji sign-offs

3 participants