Skip to content

Studio: keep Claude's web search to the sites it asks for - #14046

Merged
danielhanchen merged 7 commits into
unslothai:mainfrom
NilayYadav:claude-web-search-domains
Oct 18, 2026
Merged

danielhanchen merged 7 commits into
unslothai:mainfrom
NilayYadav:claude-web-search-domains

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

When Claude runs on Studio through unsloth start claude and limits a web search to certain sites, for example "only docs.python.org" or "skip reddit.com", the limit was dropped. The search ran on the open web, and Claude got back and cited results from sites it had asked to leave out, with no sign that the limit was ignored.

The allowed and blocked site lists on Claude's web search tool now reach Studio's own web search. The query is scoped to the allowed sites, and results and page fetches from any other site are left out. An entry with a path, such as docs.python.org/3, limits to its domain. An entry that is not a domain, such as one with https://, or a list that is not a list, gets a 400 error instead of being silently ignored, on both /v1/messages and /v1/messages/count_tokens.

Searches without a site list behave as before. This covers GGUF models, which unsloth start claude uses by default.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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 ✅ Completed 2026-10-18T16:34:18.991656Z c498bc0 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[bot]

This comment was marked as resolved.

@danielhanchen

danielhanchen commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

The (Python 3.13, l-r) failure is the positional-signature guard noticing the new parameter:

studio/backend/tests/test_llama_admission_compat_matrix.py::TestOldCallers::test_the_sandbox_level_was_appended_rather_than_inserted
    assert names[-1] == "compact_context"
AssertionError: assert 'website_policy' == 'compact_context'

Appending website_policy after compact_context in generate_chat_completion_with_tools is the correct shape, since existing positional callers keep working. The test pins the old last name, so it needs updating in this PR: assert names[-1] == "website_policy" and names.index("website_policy") == names.index("compact_context") + 1, so the next addition is held to the same append-only rule.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@NilayYadav NilayYadav left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review + reproduction evidence

Pinned review: ff53c72922ac58c458c1ef17c00675570ed1898b. 3 findings, fixed in a2a1886a and ff53c729; 1 pre-existing gap left for a follow-up (below).

I reproduced a web search with a site list through the claude CLI (2.1.302, same environment unsloth start claude sets) against Studio on fresh upstream main (Linux, NVIDIA L4, unsloth/Qwen3-4B-Instruct-2507-GGUF Q4_K_M):

  • main db0e78c1: allowed_domains: ["docs.python.org"] returned 0 of 5 links on docs.python.org (geeksforgeeks.org, runebook.dev, superfastpython.com, async-concurrency.com x2). blocked_domains: ["wikipedia.org"] returned https://en.wikipedia.org/wiki/Alan_Turing as the first link.
  • PR head: 5 of 5 links on docs.python.org, and no Wikipedia link for the blocked case. The page fetch the model did next (docs.python.org/3/library/asyncio-task.html) also stayed inside the list.
  • Same request with no site list: identical results on main and the PR, and Studio's own chat web search is unchanged.

PR 14046 before/after

Fixed on the branch:

  • allowed_domains: ["docs.python.org/3"] and ["docs.python.org/*"] returned 400 Invalid website domain on the head as submitted, where main served the request. The upstream Messages API accepts a path after the domain (domain filtering), and the CLI surfaced it as API Error: 400 to the model. A path entry now limits by its domain (5 of 5 on docs.python.org). Entries with a scheme still get a 400, as they do upstream.
  • allowed_domains: "" or {} was taken as "no limit" (200, Wikipedia in the results). Only a missing or null list means no limit now; anything else that is not a list is a 400.
  • /v1/messages/count_tokens returned 200 for a site list that /v1/messages rejects. It now validates the same way, before any model switch.

Not covered by this PR: when the resident model is a transformers or MLX model, /v1/messages still ignores the site lists (unsloth/Qwen3-1.7B with blocked_domains: ["wikipedia.org"] returned en.wikipedia.org/wiki/Alan_Turing). That is the same on main and needs the policy threaded through chat's in-process tool loops, so it is better as its own change.

Tests (web search, domain and count_tokens tests in test_anthropic_messages.py and test_llama_cpp_tool_loop.py, CPU Linux): on main with the new tests overlaid, 8 failed and 40 passed. On this head, 48 passed. All other web search tests have the same result on both sides.

Conclusion: the issue is real on main and fixed on the PR for GGUF models, which unsloth start claude loads by default. With the fixes above it accepts every domain-list shape the upstream Messages API accepts.

@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: ff53c72922

ℹ️ 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".

Comment on lines +42267 to +42269
if isinstance(entry, str) and "://" not in entry:
return entry.split("/", 1)[0]
return entry

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 Reject boolean entries in domain lists

When a client submits blocked_domains: [true], this helper returns the boolean unchanged, and normalize_website_policy later converts it via str(value or "") into the syntactically accepted domain "true". Both Messages endpoints therefore accept a malformed restriction and leave normal web results unrestricted instead of returning invalid_request_error; require every list entry to be a string before path normalization.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: ff53c72922

ℹ️ 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 added a commit that referenced this pull request Oct 17, 2026
## Summary

`Chat UI Tests (extra)` failed on main at `eb0617b6` (run 38980950910)
and on #14046 in the same window, with the same error:

```
playwright_chat_ime_i18n.py, line 645: composer.click()
Locator.click: Timeout 60000ms exceeded.
  <p class="mt-1 text-ui-11 text-muted-foreground/70">54 MB download · No restart needed after update</p>
  from <div data-testid="overlay-rail" ...>
```

The job's screenshot shows the card: "New audio.cpp update,
v0.9.1-unsloth.1 to v0.9.2-unsloth.1". The job installed audio.cpp at
00:54 UTC, and `unslothai/audio.cpp` published v0.9.2-unsloth.1 at
01:00:49. Studio's update check then saw the fresh install as one behind
and put the card in the bottom-right overlay rail, on top of the
composer.

This is the same race #14007 fixed for studiobench (a llama.cpp release
mid-job), now hitting the Chat UI smoke through the audio.cpp half of
the same update item. Neither the product nor the IME script is wrong.
Any llama.cpp, whisper.cpp or audio.cpp release that lands during a run
can do this to any script in the job that clicks near the bottom-right.

## Change

- **`studio-ui-smoke.yml`:** the `ui-smoke` job sets
`UNSLOTH_DISABLE_UPDATE_CHECK: '1'` in its job env, with a comment
explaining why.
  - These scripts test chat, not live update checks.
- The two update banner scripts in this job stub
`/api/studio/update-status`, `/api/llama/update-status` and
`/api/llama/update-changelog` with `context.route`, so they do not
depend on the live check.
- The switch also defers the startup hardware warm, but this job already
runs as `chat_only` on the CPU runner (`[ui-extra] chat_only mode: True`
in the failing run). Loading a model still triggers detection as before.
- **`tests/studio/test_studiobench_ci_update_checks_off.py`:** the
existing studiobench guard now covers both workflows.
- It is parametrized over `studiobench-ci.yml` and
`studio-ui-smoke.yml`.
  - It requires the switch on every job that runs `boot-studio`.
- It also fails if a step-level env sets the switch to anything other
than `1`.

## Testing

- **Guard:** the guard file gives 3 passed. With the workflow change
reverted, it fails with `studio-ui-smoke.yml job 'ui-smoke' boots Studio
without UNSLOTH_DISABLE_UPDATE_CHECK=1`.
- **Other tests that read `studio-ui-smoke.yml`:** 123 passed.
- **The job itself:** this PR changes `studio-ui-smoke.yml`, so its own
Chat UI smoke run exercises all shards with the switch on.
@danielhanchen danielhanchen self-assigned this Oct 18, 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: 8b20ac8933

ℹ️ 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".

declared[key] = entries
declared = normalize_website_policy(declared)
for key in policy:
policy[key] += declared[key]

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 Keep each server tool's allowed-domain scope separate

When one request includes both supported server types (for example, web_search_20250305 allowed only docs.python.org and web_fetch_20250910 allowed only example.com), both are accepted and alias to Studio's single web_search, but this concatenation turns the active tool's allowlist into {docs.python.org, example.com}. A forced web-search call can therefore return example.com even though that tool's own allowed_domains excludes it; retain the selected tool's policy or reject conflicting per-tool scopes instead of unioning allowlists.

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: web_search and web_fetch both map onto Studio's one web tool, which serves search and fetch alike, so the union is what lets each declared scope keep working; intersecting would block both tools, and two server tools with different allowlists in one request is not a shape real clients send.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 18, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 18, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 18, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 18, 2026
@unslothai unslothai deleted a comment from NilayYadav Oct 18, 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. What shall we delve into next?

Reviewed commit: 506a4c6f0d

ℹ️ 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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: c498bc0005

ℹ️ 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 20531d9 into unslothai:main Oct 18, 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.

2 participants