Skip to content

Studio: stop normal chat from opening the API monitor - #12305

Merged
Lyxot merged 4 commits into
unslothai:mainfrom
Imagineer99:fix/chat-monitor-origin
Sep 30, 2026
Merged

Lyxot merged 4 commits into
unslothai:mainfrom
Imagineer99:fix/chat-monitor-origin

Conversation

@Imagineer99

Copy link
Copy Markdown
Member

Fix the API monitor opening after normal signed-in Studio chat when keyless Everything else access is enabled. Background chat requests currently lose the original caller classification and can be mistaken for external API traffic.

Persist the server-derived monitor classification with the run and restore it on the background request. No credentials are persisted, and authentication/authorization behavior is unchanged. Previously persisted runs retain the existing fallback.

Verification

  • 128 focused backend tests pass, including caller classification, retry identity, settings changes and rejection of client-supplied attribution.
  • Fresh Playwright run in Edge on Windows using separate Studio homes, the same production frontend, and real Gemma 3 270M Q4_K_M CPU inference. No mocked API responses.
  • Both sides enable keyless full access and tools. Normal chat completes on both; the monitor is observed for 12 seconds afterward.
  • Tested commits: before 7bacc24d4, after 938eac981. The fix merges cleanly with current main.
Scenario Before After
Normal signed-in chat Monitor opens; via_api_key=true Monitor stays closed; via_api_key=false
External keyless API call Not repeated Monitor opens; via_api_key=true

Normal chat before and after

External API control screenshot · Recorded results

These are browser captures, not native desktop screenshots.

@Lyxot Lyxot self-assigned this Sep 30, 2026
Carry the recorded origin in the synthetic request's scope state alongside the cancel event, leaving a single bool check in the classifier, and tighten the related comments.

Record the producer-side checks and assert after the run, since assertions raised inside the fake producer were swallowed by the supervisor's error handling. Drop parametrizations that cannot affect the classifier.
@Lyxot

Lyxot commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Pushed two commits on top of this branch:

  • 32af6443d1 keeps the fix the same but carries the recorded origin in the producer request's scope["state"], next to generation_cancel_event, so the classifier does the only bool check. The focused test now asserts the producer-side checks after the run, because assertions raised inside the fake producer were swallowed by the supervisor's error handling (a .pop → .get regression passed). It also drops the tools and inference cases, which cannot change the result. Comments are shorter.
  • 58aeecd437 merges current main (the branch was 126 commits behind). No conflicts.

Verified that the persisted value is derived server-side only (a client-supplied key is rejected with 400, and the route overwrites it), is read only by _request_used_api_key for API monitor rows and usage receipts, and that runs saved without it fall back to the old behavior.

@Lyxot

Lyxot commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Codex review has converged on this PR.

  • Reviewed commit: 58aeecd437 (current head), mirror: [staging codex review] #12305 Studio: stop normal chat from opening the API monitor Lyxot/unsloth#116
  • Result: Didn't find any major issues, on the first round.
  • CI on the same head (backend, core zoo, workflow lint): 42 passed, 4 skipped, 9 failed. None of the failures are in code this PR touches:
    • PyAV on the runner no longer accepts metadata_errors and lacks the amr_nb codec, which breaks the audio decode tests in the backend shards and core zoo.
    • test_text_io_names_its_encoding[export.py1], test_fa2_fast_generate_bypass.py (2), test_desktop_surfaces_do_not_restore_studio_branding and test_every_tight_elapsed_bound_is_isolated (also the workflow-lint failure) fail the same way on this branch's merge base, main at 7ebf192674.
    • test_webm_export_keeps_the_audio_track is in the video export path, which this PR does not touch.
  • Durable chat, API monitor and keyless tests pass, including Unsloth API & Auth Tests, Chat UI Tests and Chat UI, API, Update and GGUF inference.

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. The monitor origin is derived server-side at run creation, cannot be supplied by clients, and only feeds API monitor rows and usage receipts. Codex converged and staging CI failures are unrelated.

@Lyxot
Lyxot merged commit de4930c into unslothai:main Sep 30, 2026
43 of 49 checks passed
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