Skip to content

Studio: keep lone asterisks and backticks in finished chat replies - #14391

Merged
danielhanchen merged 13 commits into
unslothai:mainfrom
NilayYadav:settled-reply-lone-markers
Oct 21, 2026
Merged

danielhanchen merged 13 commits into
unslothai:mainfrom
NilayYadav:settled-reply-lone-markers

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Once a chat reply finished, a lone asterisk, double asterisk or backtick in ordinary text was deleted and the rest of the sentence was restyled: "Add .pyc to .gitignore." showed as "Add .pyc to .gitignore." in italics, and "Press the ` key" turned the rest of the line into code. When the reply ended with a line break, a stray "" or "**" was added at the end instead: "Use **kwargs to forward them." showed as "Use **kwargs to forward them. **". It stayed that way after reopening the chat, while Copy still gave the original text.

The repair that closes half-written Markdown now runs only on a reply that was cut short (Stop, the Max Tokens limit, or an error), right away and after a reload. A reply that finished normally is shown exactly as written.

Known limits, unchanged from before: a cut reply can still restyle a lone marker earlier in it, and thinking text over about 16,000 characters is still repaired piece by piece.

Before / after

Five finished replies, one lone marker each, the same bytes sent to a Studio built from the merge base (left) and from this branch (right). Before: **kwargs turns bold, ***args turns bold-italic, the line after a lone backtick becomes code, and ~~ is appended to ~~ 5 dollars. After: every reply reads exactly as sent.

Finished replies with lone markers, before and after

@NilayYadav NilayYadav self-assigned this Oct 20, 2026
[skip ci]
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-21T11:07:18.803291Z
We couldn’t complete this review. Comment @codex review to try again.
9ade021 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 269b572bf6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: d51952aad8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

NilayYadav added a commit to NilayYadav/unsloth-staging that referenced this pull request Oct 20, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: a9adca1fd5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@NilayYadav

NilayYadav commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

Review + reproduction evidence

Pinned review: 25bbd7047. Two findings, fixed in d51952aad and a9adca1fd; 25bbd7047 brings the change inside the startup bundle budget; no open findings.

I reproduced a normal chat with a connected OpenAI-compatible model on the merge base a6c1e06 (Linux, Chromium, 1280x1600): six prompts typed in the composer, then the thread reopened.

  • Before: Add *.pyc to your .gitignore file. shows as Add .pyc to your .gitignore file. in italics, Press the ` key to open the console. turns the rest of the line into inline code, and Use **kwargs to forward them. gets a stray ** appended. Same after reopening.
  • PR head: all three read exactly as written (no em, strong or code). A Max Tokens reply Then **bol and a reply stopped during a tool call still show bold bol, live and after reopening, same as before.

PR 14391 before/after

  • Fixed during review: finished replies had stopped escaping - >= 16 GB of RAM (rendered as a quote showing = 16 GB of RAM) and 5~10 minutes ... 20~30 GB (rendered as strikethrough); a reply stopped while a tool call ran showed a raw **bol until the chat was reopened. Both now match the merge base.
  • Startup bundle: a9adca1fd added 459 bytes to the eager startup JS, over the 160 bytes main leaves spare. 25bbd7047 trims it to 141 bytes merged with current main (19 bytes to spare) without raising the budget: the cut check is inlined, finished replies switch off only the bold, italic and inline-code completions, and the per-render link check is gone.
  • Frontend tests: the changed tests fail on the merge base sources at the new assertions and pass on head (80/80 with the neighbouring Markdown suites); typecheck clean; full frontend suite 12929 pass, 0 fail.
  • Repo tests (CPU, rest) and (Python 3.13, rest) failed on a9adca1fd for reasons outside this PR (a GPU check in a QAT test, test files read without encoding="utf-8", and hardware.py text I/O). Main has since fixed all three: QAT test: spoof CUDA in the unpickling child on GPU-less runners #14415, Tests: read checked-in sources as UTF-8 in three new test files #14414 and Studio: decode the Rosetta sysctl probe as UTF-8 #14419.

Conclusion: real defect on main, fixed; waiting only on the PR's CI run for 25bbd7047.

@danielhanchen

Copy link
Copy Markdown
Member

Frontend build + bundle sanity fails on the startup bundle budget:

eager startup JS: 6699.2 KB raw, 2017.2 KB transfer, 96 chunks
over the startup budget: raw 6699.2 KB > 6698.9 KB

That run merged into 4279fe4ae2, which already carries the latest budget (#14407), and main measured within it there. So the extra raw bytes come from this PR's changes to the eager chat markdown path. Either keep the new code out of the startup chunks, or raise BUDGET in studio/frontend/scripts/check-bundle-budget.ts in this PR, set to the merged build's measurement plus the same 160 B raw / 189 B transfer margin, with a comment entry like the others.

danielhanchen added a commit that referenced this pull request Oct 21, 2026
## Problem


`studio/backend/tests/test_text_io_encoding.py::test_text_io_names_its_encoding`
fails on main, so the `(Python 3.13, rest)` backend shard is red on
every PR built on top of #14374 (for example #14391):

```
AssertionError: Text I/O without an explicit encoding falls back to locale.getencoding(), ...
  hardware.py:165: subprocess(text = True) without encoding
```

#14374 added `_running_under_rosetta()`, which runs `sysctl -n
hw.optional.arm64` with `text = True` and no encoding. The guard is
right. Every other `subprocess` call in `hardware.py` names its
encoding, and a bare `text = True` decodes with the locale codec (ASCII
under a C or POSIX locale).

## Fix

Pass `encoding = "utf-8", errors = "replace"`, as the other probes in
this file do. The probe only reads `0` or `1`, so behaviour is
unchanged.

## Verification

- `studio/backend/tests/test_text_io_encoding.py`: fails on main (the
line above); with this change, 857 passed.
- `test_chat_only_reason.py`, `test_export_capability.py` and
`test_video_capability.py`, which exercise the Rosetta check: 64 passed.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 25bbd70476

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Lyxot Lyxot self-assigned this Oct 21, 2026
@danielhanchen danielhanchen self-assigned this Oct 21, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 21, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 21, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 21, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 21, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 21, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 21, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c92fefa538

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const cut = useAuiState(
({ message }) =>
message.status?.type !== "running" &&
!!readIncompleteInfo(message.metadata) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat content-filter terminal responses as cut

When an OpenAI-compatible provider ends a partial response with finish_reason: "content_filter" (or another truncating non-length reason), this condition leaves cut false: chat-adapter.ts:8021-8024 clears incompleteReason for every non-length finish reason, so the final metadata contains no incomplete stamp. If filtering happens midway through bold, code, a link, or an image, the response is therefore given FINISHED_TEXT_REMEND, which disables the repairs that the previous settled path applied and exposes the unfinished Markdown; stamp these terminal reasons as incomplete or otherwise include them in cut detection.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: Studio does not treat content_filter as incomplete anywhere (no stamp, no Continue bar), so such a reply is settled and shown exactly as the provider sent it; nothing is dropped, an unclosed marker just stays literal.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: c92fefa538

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 21, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 0660354c43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit acb31d9 into unslothai:main Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants