Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
studio: serve the deep research event stream over post so proxies stop buffering it (#8205)
Maheswar Kumar2a56df02e6a0
diff --git a/studio/backend/routes/research_runs.py b/studio/backend/routes/research_runs.pyindex 804f04ba200..bd41e769235 100644--- a/studio/backend/routes/research_runs.py+++ b/studio/backend/routes/research_runs.py@@ -427,7 +427,10 @@ async def retry_research_run(return run[email protected]("/{run_id}/events")+# POST too: proxies that stream /v1/chat/completions still buffer a streamed GET until it closes.[email protected]("/{run_id}/events")+# Separate registration, out of the schema: one api_route would give both verbs one operationId.[email protected]("/{run_id}/events", include_in_schema = False)async def research_events(run_id: str,request: Request,diff --git a/studio/backend/tests/test_research_progress_events.py b/studio/backend/tests/test_research_progress_events.pyindex f4518ff337c..3fdd2c3bb2b 100644--- a/studio/backend/tests/test_research_progress_events.py+++ b/studio/backend/tests/test_research_progress_events.py@@ -272,3 +272,30 @@ def test_decision_phase_bracket_carries_its_step_position(research_home, monkeypstarted = next(e for e in _events("run-1") if e["type"] == "phase.started")assert started["data"]["stepPosition"] == 3assert started["data"]["phase"] == "decision"+++def test_event_stream_is_reachable_over_post_as_well_as_get():+ # Proxies that stream POST /v1/chat/completions still hold a streamed GET until it closes.+ from routes.research_runs import router+ events = [route for route in router.routes if route.path == "/{run_id}/events"]+ assert {method for route in events for method in route.methods} >= {"GET", "POST"}+++def test_event_stream_verbs_do_not_share_one_operation_id():+ # A single api_route for both verbs gave them one operationId, which FastAPI warns about and+ # OpenAPI generators resolve by dropping one of the two operations.+ import warnings++ from fastapi import FastAPI+ from fastapi.openapi.utils import get_openapi++ from routes.research_runs import router++ app = FastAPI()+ app.include_router(router, prefix = "/api/chat/research-runs")+ with warnings.catch_warnings(record = True) as caught:+ warnings.simplefilter("always")+ spec = get_openapi(title = "t", version = "1", routes = app.routes)+ assert not [w for w in caught if "Duplicate Operation ID" in str(w.message)]+ operations = spec["paths"]["/api/chat/research-runs/{run_id}/events"]+ assert list(operations) == ["post"]diff --git a/studio/frontend/src/features/chat/api/research-api.ts b/studio/frontend/src/features/chat/api/research-api.tsindex 1f60461eb4b..8e72e2bfe7b 100644--- a/studio/frontend/src/features/chat/api/research-api.ts+++ b/studio/frontend/src/features/chat/api/research-api.ts@@ -146,9 +146,10 @@ export async function* streamResearchEvents(after: number,signal?: AbortSignal,): AsyncGenerator<StreamResearchEvent> {+ // POST, not GET: proxies hold a streamed GET until it closes. The route accepts both.const response = await authFetch(`/api/chat/research-runs/${id}/events?after=${Math.max(0, after)}`,- { headers: { accept: "text/event-stream" }, signal },+ { method: "POST", headers: { accept: "text/event-stream" }, signal },);if (!response.ok) {await json(response);diff --git a/tests/studio/test_deep_research_frontend_contract.py b/tests/studio/test_deep_research_frontend_contract.pyindex 9efd27eb2cc..c8c0b20d3ba 100644--- a/tests/studio/test_deep_research_frontend_contract.py+++ b/tests/studio/test_deep_research_frontend_contract.py@@ -21,7 +21,8 @@ def test_research_api_is_isolated_and_cursor_based() -> None:assert "runs.at(-1) ?? null" in apiassert "getResearchThreadState" in apiassert "/events?after=${Math.max(0, after)}" in api- assert 'headers: { accept: "text/event-stream" }' in api+ # POST, not GET: proxies that buffer a streamed GET leave the activity panel empty.+ assert 'method: "POST", headers: { accept: "text/event-stream" }' in apiassert "export async function* followResearchRun" in apiassert "Math.min(8_000, 500 * 2 ** (failures - 1))" in apiassert "for await (const event of streamResearchEvents" in api