Skip to content

Studio: keep ticked check boxes when reading HTML files - #15601

Merged
danielhanchen merged 1 commit into
unslothai:mainfrom
NilayYadav:checked-html-check-boxes-task
Oct 28, 2026
Merged

danielhanchen merged 1 commit into
unslothai:mainfrom
NilayYadav:checked-html-check-boxes-task

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

An HTML file with a task list or a form, such as a checklist exported from Typora, pandoc, Obsidian or a saved GitHub page, lost every check box when it was added to a knowledge base, to Chat with files, or attached to a chat. "Ship release" and "Write docs" read the same whether they were done or not, and "Smoker: [x] Yes [ ] No" became "Smoker: Yes No". Asked which tasks were still open, the model had to guess and often got it wrong.

Check boxes and radio buttons now read as a ticked or empty box mark, the same marks Word files already get. This applies to files indexed on the server and to HTML attachments read in the browser. Other inputs, buttons and the rest of the page read as before.

Chat with files

Before (main) After (this PR)
before after

HTML attached to a chat

Before (main) After (this PR)
before after

Same checklist (Ship release and Tag version ticked, Write docs and Announce on forum open, Smoker: Yes), same question, Qwen3-4B-Instruct-2507. Before, the model lists the wrong tasks as done. After, it matches the ticked boxes.

Composer attachment preview (independent before/after, merge base vs head)

BEFORE / AFTER: .xhtml checklist attached in the chat composer

An .xhtml checklist attached in the chat composer, from two fresh Studio installs (merge base c4f9de9c0 vs head 4ba707d62). The chip shows the server-extracted text: 0 ticked / 0 empty marks before, 3 ticked / 2 empty after, and the radio pair reads as one ticked and one empty mark.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Reproduction evidence

Pinned head: 4ba707d62. No findings.

I attached an HTML checklist (Ship release and Tag version ticked, Write docs and Announce on forum open, Smoker radio on Yes) in real Studios on the merge base c4f9de9 and on the PR head. Setup: Linux, NVIDIA L4, Chromium 1400x1000, Qwen3-4B-Instruct-2507 Q4_K_M.

  • Attached to a chat, before: the text sent to the model is Ship release / Write docs / Tag version / Announce on forum / Smoker: Yes No, with no tick state. The model answers backwards: "Done: Write docs, Tag version, Announce on forum / Open: Ship release".
  • Attached to a chat, PR head: the text is ☒ Ship release / ☐ Write docs / ☒ Tag version / ☐ Announce on forum / Smoker: ☒ Yes ☐ No, and the answer is correct.
  • Chat with files, before: the retrieved passage has no marks, and the model says "No specific information is provided on which tasks are completed or still open".
  • Chat with files, PR head: the passage has ☒/☐, and the done/open answer is correct.

PR 15601 before/after

  • The text input and button on the same page read "Name: Save" on both sides, and there are no new console errors.
  • The new backend test fails on the merge base and passes on head, with 87 other tests unchanged. Frontend tests are 79/80 on base (only the new test fails) and 80/80 on head.

Conclusion: real and fixed.

danielhanchen added a commit that referenced this pull request Oct 28, 2026
…, and name any test that still does (#15626)

## Summary

Backend CI (`(Python 3.13, a-f)`) and `Repo tests (CPU, rest)` have been
failing intermittently with dozens of errors like

```
AttributeError: torch._dynamo.config.recompile_limit does not exist
AttributeError: torch._dynamo.config.suppress_errors does not exist
AttributeError: torch._inductor.config.emulate_precision_casts does not exist
```

Seen on #15586, #15589, #15590, #15592, #15593, #15596 and #15601.
Locally, on pytest 9.1.1, it never reproduced.

### Root cause

CI resolves pytest 9.2.0, which changed `MonkeyPatch.setattr`
(pytest-dev/pytest#10644).
- For a non-class target it now records the old value from the instance
`__dict__`. Before, it used `getattr`.
- A torch `ConfigModule` (`torch._dynamo.config`,
`torch._inductor.config`, and its `SubConfigProxy` children such as
`torch._inductor.config.triton`) serves its entries from `__getattr__`.
They are never in `__dict__`, so pytest records "not set".
- On undo it therefore calls `delattr`. `ConfigModule.__delattr__` marks
the entry hidden, and every later read in that process raises `... does
not exist`.

So every `monkeypatch.setattr(torch._dynamo.config, ...)` in the suite
now deletes the entry it patched. Which shard fails depends on which
xdist worker such a test lands on.

Minimal reproduction:

```python
def test_patch(monkeypatch):
    monkeypatch.setattr(torch._dynamo.config, "suppress_errors", True)

def test_after():
    assert torch._dynamo.config.suppress_errors is False
```

On pytest 9.1.1 both pass. On 9.2.0 `test_after` fails with
`torch._dynamo.config.suppress_errors does not exist`.

## Change

`tests/_shared/torch_config_guard.py`, installed from
`tests/conftest.py` and `studio/backend/tests/conftest.py`:
- **`install_monkeypatch_fix()`:** wraps `pytest.MonkeyPatch.setattr`.
When the target is a torch `ConfigModule` or `SubConfigProxy`, including
the dotted-string form, it records the real value that was replaced, so
`undo()` restores it with `setattr` instead of deleting the entry. Every
other target goes through pytest unchanged. The fix is a no-op until
torch is imported, and it never imports torch itself.
- **`_no_deleted_torch_config_entries` autouse fixture:** any test that
still leaves a config entry deleted, by any route, errors at its own
teardown with the stack of the delete. The entry is then restored with
its previous value, so the rest of the worker is not poisoned. Cost is
about 24 us per test.

The guard is what found the cause. On the first push (guard only),
staging CI named 15 deletes, and every recorded stack ended in
`_pytest/monkeypatch.py, line 437, in undo: delattr(obj, name)`.

## Testing

**Under pytest 9.2.0** (CI's version):
- `tests/test_torch_config_guard.py`: 10 passed. Two tests pin the fix:
- `test_monkeypatch_undo_restores_a_config_entry_instead_of_deleting_it`
covers `torch._dynamo.config`, `torch._inductor.config` and
`torch._inductor.config.triton`.
- `test_monkeypatch_undo_restores_a_config_entry_named_by_import_path`
covers the dotted-string form.
- **Sabotage:** with `install_monkeypatch_fix` turned into a no-op,
those 4 cases fail and the guard errors at teardown.
- `tests/test_block_compile.py`: 13 failed on main (`suppress_errors` /
`recompile_limit does not exist`, the CI signature), 42 passed with this
change.

**Under pytest 9.1.1:**
- `tests/test_torch_config_guard.py`: 10 passed, and
`tests/test_block_compile.py`: 42 passed, on both trees.
- `studio/backend/tests/test_diffusion_*.py` (about 17,400 tests, run in
parallel with main on one loaded host): the guard fired 0 times. The
branch had 67 failed / 14 errors against 79 / 26 on main. The 3 failures
seen only on the branch pass when rerun alone, so they are load flakes.
- Meta-tests that read conftests and `tests/_shared`, plus
`test_ci_backend_pytest_shards.py`: 604 passed.
danielhanchen added a commit that referenced this pull request Oct 28, 2026
…g (pytest 9.2) (#15638)

## Summary


`studio/backend/tests/test_mcp_session_cache_reset_between_tests.py::test_the_next_test_starts_with_an_empty_cache_and_the_session_closed`
has failed on the `(Python 3.13, g-r)` shard of #15587, #15593, #15601
and #15615 (`assert 0 == 1` on `_Session.closed`).

### Root cause

CI now resolves pytest 9.2.0, and pytest-xdist 3.8.0 (the latest
release) does not work with it:
- `--dist loadgroup` keeps an `xdist_group` on one worker by rewriting
`item._nodeid` to `<id>@<group>`.
- pytest 9.2 builds `Item.nodeid` from a structured `_id` instead, so
that write is lost.
- Every grouped test is therefore scheduled like an ungrouped one.

The MCP pair (and the other `*_reset_between_tests` pairs) only hold
when both tests run on the same worker. With `-v`, the first test ran on
`gw0` and the second on `gw3`.

Minimal reproduction:

```python
pytestmark = pytest.mark.xdist_group("g1")
def test_one(): pass
def test_two(): pass
```

`pytest -n 2 --dist loadgroup -v`:
- pytest 9.1.1 reports `test_one@g1` and `test_two@g1`, both on `gw0`.
- pytest 9.2.0 reports `test_one` on `gw0` and `test_two` on `gw1`.

The same pytest release is behind the `torch._dynamo.config.* does not
exist` failures (#15624 pins Backend CI below 9.2 for that; #15626 makes
the suite tolerate it).

## Change

This builds on #15624 (merged), which pins `'pytest<9.2'` in
`studio-backend-ci.yml`, the only workflow that runs `--dist loadgroup`.

- **`version-compat-ci.yml`**: `'pytest>=8'` becomes `'pytest>=8,<9.2'`.
These lanes run the CPU-spoof fixtures that monkeypatch
`torch._dynamo.config`, which pytest 9.2 deletes on undo.
- **`tests/_shared/xdist_group_check.py`**, installed as a `trylast`
`pytest_collection_modifyitems` hook in `tests/conftest.py` and
`studio/backend/tests/conftest.py`:
- On an xdist worker running `--dist loadgroup`, any test that carries
an `xdist_group` mark but whose node id has no `@group` tag now fails
with the reason.
- Before, it would sometimes pass and sometimes fail depending on
scheduling. If the pin is lifted before pytest-xdist catches up, the
grouped tests fail by name with an explanation instead of flaking.
- Raising a usage error at collection time would be swallowed into an
xdist `INTERNALERROR`, so each affected test fails individually instead.
- **`tests/test_xdist_group_check.py`**: unit tests for the check, the
conftest wiring, and both pins (Backend CI from #15624 and
version-compat from this PR).

## Testing

Run on `studio/backend/tests/test_mcp_*.py` with `-n 4 --dist
loadgroup`:
- **pytest 9.1.1:** 2089 passed, twice.
- **pytest 9.2.0:** the MCP pair failed in both runs.
- **Serially on 9.2.0:** 2089 passed, so the failure needs xdist.

With the check in place, the two grouped pair files under `-n 2 --dist
loadgroup`:
- **pytest 9.1.1:** 4 passed.
- **pytest 9.2.0:** all 4 grouped tests fail with "--dist loadgroup did
not tag this xdist_group test ...".

`tests/test_xdist_group_check.py` with
`tests/test_torch_config_guard.py` (from #15626) after merging main: 18
passed.
@danielhanchen danielhanchen self-assigned this Oct 28, 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 commented Oct 28, 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 🔄 Running since 2026-10-28T06:05:43.891499Z 4ba707d Manual request
ℹ️ 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: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 28, 2026
@danielhanchen
danielhanchen merged commit f2a1f32 into unslothai:main Oct 28, 2026
51 of 58 checks 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.

2 participants