Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

refactor(platform): remove the Fast/Thinking mode, control and plumbing (#14083)

Nicholas Tindle7f25de616bf6
diff --git a/autogpt_platform/backend/backend/api/features/chat/routes.py b/autogpt_platform/backend/backend/api/features/chat/routes.py
index 369c4e0102..b6112035d3 100644
--- a/autogpt_platform/backend/backend/api/features/chat/routes.py
+++ b/autogpt_platform/backend/backend/api/features/chat/routes.py
@@ -22,12 +22,7 @@ from backend.copilot.active_turns import (
inflight_turn_limit_message,
)
from backend.copilot.builder_context import resolve_session_permissions
-from backend.copilot.config import (
- ChatConfig,
- CopilotLlmAuthProvider,
- CopilotLLMModel,
- CopilotMode,
-)
+from backend.copilot.config import ChatConfig, CopilotLlmAuthProvider, CopilotLLMModel
from backend.copilot.db import (
chat_message_has_assistant_reply,
get_chat_messages_paginated,
@@ -264,11 +259,6 @@ class StreamChatRequest(BaseModel):
file_ids: list[str] | None = Field(
default=None, max_length=20
) # Workspace file IDs attached to this message
- mode: CopilotMode | None = Field(
- default=None,
- description="Autopilot mode: 'fast' for baseline LLM, 'extended_thinking' for Claude Agent SDK. "
- "If None, uses the server default (extended_thinking).",
- )
model: CopilotLLMModel | None = Field(
default=None,
description="Model tier: 'standard' for the default model, 'advanced' for the highest-capability model. "
@@ -1644,7 +1634,6 @@ async def stream_chat_post(
file_ids=sanitized_file_ids,
organization_id=turn_org_id,
team_id=turn_team_id,
- mode=request.mode,
model=request.model,
llm_auth_provider=session.metadata.llm_auth_provider,
llm_credential_id=session.metadata.llm_credential_id,
@@ -1671,7 +1660,6 @@ async def stream_chat_post(
is_user_message=request.is_user_message,
context=request.context,
file_ids=sanitized_file_ids,
- mode=request.mode,
model=request.model,
llm_auth_provider=session.metadata.llm_auth_provider,
llm_credential_id=session.metadata.llm_credential_id,
diff --git a/autogpt_platform/backend/backend/api/features/chat/routes_test.py b/autogpt_platform/backend/backend/api/features/chat/routes_test.py
index 27889b6ed6..646691ba70 100644
--- a/autogpt_platform/backend/backend/api/features/chat/routes_test.py
+++ b/autogpt_platform/backend/backend/api/features/chat/routes_test.py
@@ -1981,42 +1981,17 @@ def test_create_session_rejects_builder_graph_id_with_expert_id(
mock_create.assert_not_called()
-class TestStreamChatRequestModeValidation:
- """Pydantic-level validation of the ``mode`` field on StreamChatRequest."""
+class TestStreamChatRequestLegacyMode:
+ """Old clients may still send ``mode`` after the server stopped using it."""
- def test_rejects_invalid_mode_value(self) -> None:
- """Any string outside the Literal set must raise ValidationError."""
- from pydantic import ValidationError
-
- from backend.api.features.chat.routes import StreamChatRequest
-
- with pytest.raises(ValidationError):
- StreamChatRequest(message="hi", mode="turbo") # type: ignore[arg-type]
-
- def test_accepts_fast_mode(self) -> None:
- from backend.api.features.chat.routes import StreamChatRequest
-
- req = StreamChatRequest(message="hi", mode="fast")
- assert req.mode == "fast"
-
- def test_accepts_extended_thinking_mode(self) -> None:
- from backend.api.features.chat.routes import StreamChatRequest
-
- req = StreamChatRequest(message="hi", mode="extended_thinking")
- assert req.mode == "extended_thinking"
-
- def test_accepts_none_mode(self) -> None:
- """``mode=None`` is valid (server decides via feature flags)."""
- from backend.api.features.chat.routes import StreamChatRequest
-
- req = StreamChatRequest(message="hi", mode=None)
- assert req.mode is None
-
- def test_mode_defaults_to_none_when_omitted(self) -> None:
+ @pytest.mark.parametrize(
+ "legacy_mode", ["fast", "extended_thinking", "turbo", None]
+ )
+ def test_legacy_mode_is_ignored(self, legacy_mode: str | None) -> None:
from backend.api.features.chat.routes import StreamChatRequest
- req = StreamChatRequest(message="hi")
- assert req.mode is None
+ req = StreamChatRequest(message="hi", mode=legacy_mode) # type: ignore[call-arg]
+ assert "mode" not in req.model_dump()
# ─── Pending message queue (when a turn is already in flight) ─────────
diff --git a/autogpt_platform/backend/backend/copilot/baseline/engine_switch_exit_test.py b/autogpt_platform/backend/backend/copilot/baseline/engine_switch_exit_test.py
index 6a70421229..fec25b198d 100644
--- a/autogpt_platform/backend/backend/copilot/baseline/engine_switch_exit_test.py
+++ b/autogpt_platform/backend/backend/copilot/baseline/engine_switch_exit_test.py
@@ -25,7 +25,7 @@ def test_pending_switch_emits_mode_change_then_status():
assert isinstance(events[0], StreamModeChanged)
assert events[0].mode == "extended_thinking"
assert isinstance(events[1], StreamStatus)
- assert "Thinking" in events[1].message
+ assert "agent building" in events[1].message.lower()
finally:
engine_switch.pop_switch("sess-exit-1")
diff --git a/autogpt_platform/backend/backend/copilot/baseline/service.py b/autogpt_platform/backend/backend/copilot/baseline/service.py
index 5183b36b14..23e8498ca3 100644
--- a/autogpt_platform/backend/backend/copilot/baseline/service.py
+++ b/autogpt_platform/backend/backend/copilot/baseline/service.py
@@ -42,7 +42,7 @@ from backend.copilot.builder_context import (
build_builder_context_turn_prefix,
build_builder_system_prompt_suffix,
)
-from backend.copilot.config import CopilotLLMModel, CopilotMode
+from backend.copilot.config import CopilotLLMModel
from backend.copilot.context import get_workspace_manager, set_execution_context
from backend.copilot.expert_context import build_expert_identity_suffix
from backend.copilot.graphiti.config import is_enabled_for_user
@@ -1615,7 +1615,6 @@ async def stream_chat_completion_baseline(
file_ids: list[str] | None = None,
permissions: "CopilotPermissions | None" = None,
context: dict[str, str] | None = None,
- mode: CopilotMode | None = None,
model: CopilotLLMModel | None = None,
request_arrival_at: float = 0.0,
organization_id: str | None = None,
@@ -2671,13 +2670,16 @@ async def stream_chat_completion_baseline(
def _engine_switch_finish_events(session_id: str) -> "list[StreamBaseResponse]":
"""Terminal events for a turn that registered an engine switch.
- Emitted right before StreamFinish so the frontend flips its mode picker
- (StreamModeChanged) and narrates the handoff (StreamStatus) exactly once,
- at the turn boundary where the baseline loop stopped.
+ Emitted right before StreamFinish so the frontend learns the engine
+ changed (StreamModeChanged) and narrates the handoff (StreamStatus)
+ exactly once, at the turn boundary where the baseline loop stopped.
+ There is no mode picker to flip any more — the client uses this only to
+ widen its post-finish refetch window, since a switch takes longer to
+ settle.
"""
if not engine_switch.is_pending(session_id):
return []
return [
StreamModeChanged(mode="extended_thinking"),
- StreamStatus(message="Switching to Thinking mode for agent building…"),
+ StreamStatus(message="Switching engines for agent building…"),
]
diff --git a/autogpt_platform/backend/backend/copilot/config_test.py b/autogpt_platform/backend/backend/copilot/config_test.py
index 19f210ff02..2a854efeb5 100644
--- a/autogpt_platform/backend/backend/copilot/config_test.py
+++ b/autogpt_platform/backend/backend/copilot/config_test.py
@@ -477,7 +477,7 @@ class TestTransportProfile:
def test_thinking_available_alias_matches_profile(self):
"""``thinking_available`` is a backwards-compat alias used by
- ``executor.processor.resolve_use_sdk_for_mode`` — must stay in
+ ``executor.processor.resolve_use_sdk`` — must stay in
sync with ``transport.supports_sdk``."""
for kwargs in (
dict(use_local=True, api_key="ollama", base_url="http://h:11434/v1"),
@@ -651,7 +651,7 @@ class TestLocalTransport:
Claude Agent SDK CLI speaks Anthropic's wire protocol and Ollama
doesn't implement it. ``thinking_available`` reports this so the
request layer can downgrade gracefully (see
- ``executor.processor.resolve_use_sdk_for_mode``)."""
+ ``executor.processor.resolve_use_sdk``)."""
def test_local_transport_overrides_subscription(self):
"""An operator opting into local self-hosting must not have their
diff --git a/autogpt_platform/backend/backend/copilot/executor/manager.py b/autogpt_platform/backend/backend/copilot/executor/manager.py
index 4e3460f9b9..3d9c325dbc 100644
--- a/autogpt_platform/backend/backend/copilot/executor/manager.py
+++ b/autogpt_platform/backend/backend/copilot/executor/manager.py
@@ -674,7 +674,9 @@ def _dispatch_engine_switch_continuation(
turn_id=str(uuid.uuid4()),
message=engine_switch.CONTINUATION_MESSAGE,
is_user_message=False,
- mode="extended_thinking",
+ # No engine is named here: the processor pins a building-mode
+ # session to the SDK from its message history, which is what made
+ # this argument redundant even while it existed.
organization_id=switch.organization_id,
team_id=switch.team_id,
llm_auth_provider=session.metadata.llm_auth_provider,
diff --git a/autogpt_platform/backend/backend/copilot/executor/manager_test.py b/autogpt_platform/backend/backend/copilot/executor/manager_test.py
index 7003538c10..ebdd225994 100644
--- a/autogpt_platform/backend/backend/copilot/executor/manager_test.py
+++ b/autogpt_platform/backend/backend/copilot/executor/manager_test.py
@@ -56,10 +56,10 @@ def test_dispatch_succeeds_first_try():
assert kwargs["organization_id"] == "org-1"
assert kwargs["message"] == CONTINUATION_MESSAGE
assert kwargs["is_user_message"] is False
- assert kwargs["mode"] == "extended_thinking"
+ assert "mode" not in kwargs
-def test_dispatch_preserves_codex_transport_for_extended_thinking(
+def test_dispatch_preserves_codex_transport_for_engine_switch(
mock_chat_session,
):
mock_chat_session.return_value.metadata.llm_auth_provider = "codex"
@@ -71,7 +71,7 @@ def test_dispatch_preserves_codex_transport_for_extended_thinking(
_dispatch_engine_switch_continuation("sess-1", _SWITCH)
kwargs = mock_schedule.call_args.kwargs
- assert kwargs["mode"] == "extended_thinking"
+ assert "mode" not in kwargs
assert kwargs["llm_auth_provider"] == "codex"
assert kwargs["llm_credential_id"] == "cred-codex"
diff --git a/autogpt_platform/backend/backend/copilot/executor/processor.py b/autogpt_platform/backend/backend/copilot/executor/processor.py
index 4132886614..bb8a328292 100644
--- a/autogpt_platform/backend/backend/copilot/executor/processor.py
+++ b/autogpt_platform/backend/backend/copilot/executor/processor.py
@@ -15,7 +15,7 @@ from typing import TYPE_CHECKING, Callable, cast
from backend.copilot import stream_registry
from backend.copilot.baseline import stream_chat_completion_baseline
-from backend.copilot.config import ChatConfig, CopilotMode
+from backend.copilot.config import ChatConfig
from backend.copilot.expert_context import (
EXPERT_SESSION_MISSING_MESSAGE,
EXPERT_SESSION_TEMPORARY_MESSAGE,
@@ -135,62 +135,26 @@ def sync_fail_close_session(
# ============ Mode Routing ============ #
-async def resolve_effective_mode(
- mode: CopilotMode | None,
- user_id: str | None,
-) -> CopilotMode | None:
- """Strip ``mode`` when the user is not entitled to the toggle.
-
- The UI gates the mode toggle behind ``CHAT_MODE_OPTION``; the
- processor enforces the same gate server-side so an authenticated
- user cannot bypass the flag by crafting a request directly.
- """
- if mode is None:
- return None
- allowed = await is_feature_enabled(
- Flag.CHAT_MODE_OPTION,
- user_id or "anonymous",
- default=False,
- )
- if not allowed:
- logger.info(f"Ignoring mode={mode} — CHAT_MODE_OPTION is disabled for user")
- return None
- return mode
-
-
-async def resolve_use_sdk_for_mode(
- mode: CopilotMode | None,
+async def resolve_use_sdk(
user_id: str | None,
*,
use_claude_code_subscription: bool,
config_default: bool,
thinking_available: bool = True,
) -> bool:
- """Pick the SDK vs baseline path for a single turn.
-
- Per-request ``mode`` wins whenever it is set (after the
- ``CHAT_MODE_OPTION`` gate has been applied upstream). Otherwise
- falls back to the Claude Code subscription override, then the
- ``COPILOT_SDK`` LaunchDarkly flag, then the config default.
-
- ``thinking_available`` is the kill-switch for deployments where the
- SDK transport simply cannot run (today: ``CHAT_USE_LOCAL=true`` —
- Ollama doesn't speak Anthropic's wire protocol). When False the
- baseline path is forced regardless of mode / flags / subscription;
- an explicit ``mode='extended_thinking'`` request is logged at WARNING
- so misconfigured deployments are visible without 500s.
+ """Pick the SDK vs baseline engine for a single turn.
+
+ The engine is entirely the server's call: the Claude Code subscription
+ override, then the ``COPILOT_SDK`` LaunchDarkly flag, then the config
+ default. Callers used to be able to name an engine per request; nothing
+ can now, so there is one decision here instead of a request overriding it.
+
+ ``thinking_available`` is the kill-switch for deployments where the SDK
+ transport simply cannot run (today: ``CHAT_USE_LOCAL=true`` — Ollama
+ doesn't speak Anthropic's wire protocol).
"""
if not thinking_available:
- if mode == "extended_thinking":
- logger.warning(
- "Downgrading mode=extended_thinking to fast: SDK is "
- "unavailable under the current transport (CHAT_USE_LOCAL=true)"
- )
return False
- if mode == "fast":
- return False
- if mode == "extended_thinking":
- return True
return use_claude_code_subscription or await is_feature_enabled(
Flag.COPILOT_SDK,
user_id or "anonymous",
@@ -634,7 +598,6 @@ class CoPilotProcessor:
credential_lease = None
raise RuntimeError("codex_credential_not_found") from None
stream_fn = sdk_service.stream_chat_completion_sdk
- effective_mode = await resolve_effective_mode(entry.mode, entry.user_id)
log.info("Using Claude SDK with Codex subscription transport")
else:
if entry.llm_credential_id is not None:
@@ -646,15 +609,8 @@ class CoPilotProcessor:
if config.test_mode:
stream_fn = stream_chat_completion_dummy
log.warning("Using DUMMY service (CHAT_TEST_MODE=true)")
- effective_mode = None
else:
- # Enforce server-side feature-flag gate so unauthorised
- # users cannot force a mode by crafting the request.
- effective_mode = await resolve_effective_mode(
- entry.mode, entry.user_id
- )
- use_sdk = await resolve_use_sdk_for_mode(
- effective_mode,
+ use_sdk = await resolve_use_sdk(
entry.user_id,
use_claude_code_subscription=(
config.use_claude_code_subscription
@@ -664,9 +620,8 @@ class CoPilotProcessor:
)
# Building-mode sessions are pinned to the SDK engine
# (guide-in-prompt + in-turn restart live there). Derived
- # from message history — survives stale frontend mode
- # pickers. get_chat_session is Redis-cached, so this is
- # one cache hit, not a DB round-trip.
+ # from message history. get_chat_session is Redis-cached,
+ # so this is one cache hit, not a DB round-trip.
if not use_sdk and config.thinking_available:
if await _building_mode_forces_sdk(entry.session_id):
use_sdk = True
@@ -678,10 +633,7 @@ class CoPilotProcessor:
if use_sdk
else stream_chat_completion_baseline
)
- log.info(
- f"Using {'SDK' if use_sdk else 'baseline'} service "
- f"(mode={effective_mode or 'default'})"
- )
+ log.info(f"Using {'SDK' if use_sdk else 'baseline'} service")
# Stream chat completion and publish chunks to Redis.
# stream_and_publish wraps the raw stream with registry
@@ -695,7 +647,6 @@ class CoPilotProcessor:
user_id=entry.user_id,
context=entry.context,
file_ids=entry.file_ids,
- mode=effective_mode,
model=entry.model,
permissions=entry.permissions,
request_arrival_at=entry.request_arrival_at,
diff --git a/autogpt_platform/backend/backend/copilot/executor/processor_test.py b/autogpt_platform/backend/backend/copilot/executor/processor_test.py
index 10d901c764..8fd562a34f 100644
--- a/autogpt_platform/backend/backend/copilot/executor/processor_test.py
+++ b/autogpt_platform/backend/backend/copilot/executor/processor_test.py
@@ -1,13 +1,10 @@
-"""Unit tests for CoPilot mode routing logic in the processor.
+"""Unit tests for engine routing in the processor.
-Tests cover the mode→service mapping:
- - 'fast' → baseline service
- - 'extended_thinking' → SDK service
- - None → feature flag / config fallback
-
-as well as the ``CHAT_MODE_OPTION`` server-side gate. The tests import
-the real production helpers from ``processor.py`` so the routing logic
-has meaningful coverage.
+Nothing outside the server can name an engine, so the decision is one
+chain: the SDK kill switch, then a Claude Code subscription, then the
+``COPILOT_SDK`` flag, then the config default. The tests import the real
+production helper from ``processor.py`` so that chain has meaningful
+coverage.
"""
import asyncio
@@ -20,13 +17,11 @@ from unittest.mock import AsyncMock, MagicMock, patch
import pytest
-from backend.copilot.config import CopilotMode
from backend.copilot.executor.processor import (
_CODEX_CREDENTIAL_ACQUIRE_TIMEOUT_SECONDS,
CoPilotProcessor,
_normalize_private_expert_session_tenancy,
- resolve_effective_mode,
- resolve_use_sdk_for_mode,
+ resolve_use_sdk,
sync_fail_close_session,
)
from backend.copilot.executor.utils import CoPilotExecutionEntry, CoPilotLogMetadata
@@ -48,53 +43,17 @@ from backend.util.exceptions import (
)
-class TestResolveUseSdkForMode:
- """Tests for the per-request mode routing logic."""
-
- @pytest.mark.asyncio
- async def test_fast_mode_uses_baseline(self):
- """mode='fast' always routes to baseline, regardless of flags."""
- with patch(
- "backend.copilot.executor.processor.is_feature_enabled",
- new=AsyncMock(return_value=True),
- ):
- assert (
- await resolve_use_sdk_for_mode(
- "fast",
- "user-1",
- use_claude_code_subscription=True,
- config_default=True,
- )
- is False
- )
-
- @pytest.mark.asyncio
- async def test_extended_thinking_uses_sdk(self):
- """mode='extended_thinking' always routes to SDK, regardless of flags."""
- with patch(
- "backend.copilot.executor.processor.is_feature_enabled",
- new=AsyncMock(return_value=False),
- ):
- assert (
- await resolve_use_sdk_for_mode(
- "extended_thinking",
- "user-1",
- use_claude_code_subscription=False,
- config_default=False,
- )
- is True
- )
+class TestResolveUseSdk:
+ """Which engine runs a turn — entirely the server's call."""
@pytest.mark.asyncio
- async def test_none_mode_uses_subscription_override(self):
- """mode=None with claude_code_subscription=True routes to SDK."""
+ async def test_subscription_override_routes_to_sdk(self):
with patch(
"backend.copilot.executor.processor.is_feature_enabled",
new=AsyncMock(return_value=False),
):
assert (
- await resolve_use_sdk_for_mode(
- None,
+ await resolve_use_sdk(
"user-1",
use_claude_code_subscription=True,
config_default=False,
@@ -103,51 +62,47 @@ class TestResolveUseSdkForMode:
)
@pytest.mark.asyncio
- async def test_none_mode_uses_feature_flag(self):
- """mode=None with feature flag enabled routes to SDK."""
+ async def test_feature_flag_routes_to_sdk(self):
with patch(
"backend.copilot.executor.processor.is_feature_enabled",
new=AsyncMock(return_value=True),
- ) as flag_mock:
+ ):
assert (
- await resolve_use_sdk_for_mode(
- None,
+ await resolve_use_sdk(
"user-1",
use_claude_code_subscription=False,
config_default=False,
)
is True
)
- flag_mock.assert_awaited_once()
@pytest.mark.asyncio
- async def test_none_mode_uses_config_default(self):
- """mode=None falls back to config.use_claude_agent_sdk."""
- # When LaunchDarkly returns the default (True), we expect SDK routing.
- with patch(
- "backend.copilot.executor.processor.is_feature_enabled",
- new=AsyncMock(return_value=True),
- ):
+ async def test_config_default_is_the_flag_fallback(self):
+ captured: dict[str, object] = {}
+
+ async def _flag(_flag_name, _user, default=False):
+ captured["default"] = default
+ return default
+
+ with patch("backend.copilot.executor.processor.is_feature_enabled", new=_flag):
assert (
- await resolve_use_sdk_for_mode(
- None,
+ await resolve_use_sdk(
"user-1",
use_claude_code_subscription=False,
config_default=True,
)
is True
)
+ assert captured["default"] is True
@pytest.mark.asyncio
- async def test_none_mode_all_disabled(self):
- """mode=None with all flags off routes to baseline."""
+ async def test_everything_disabled_routes_to_baseline(self):
with patch(
"backend.copilot.executor.processor.is_feature_enabled",
new=AsyncMock(return_value=False),
):
assert (
- await resolve_use_sdk_for_mode(
- None,
+ await resolve_use_sdk(
"user-1",
use_claude_code_subscription=False,
config_default=False,
@@ -156,105 +111,42 @@ class TestResolveUseSdkForMode:
)
@pytest.mark.asyncio
- async def test_thinking_unavailable_forces_baseline(self, caplog):
- """When the SDK transport can't run (use_local=true), every mode
- routes to baseline — including an explicit extended_thinking
- request, which is logged at WARNING for visibility."""
- caplog.set_level(logging.WARNING, logger="backend.copilot.executor.processor")
- with patch(
- "backend.copilot.executor.processor.is_feature_enabled",
- new=AsyncMock(return_value=True),
- ):
- for mode in ("fast", "extended_thinking", None):
- assert (
- await resolve_use_sdk_for_mode(
- mode,
- "user-1",
- use_claude_code_subscription=True,
- config_default=True,
- thinking_available=False,
- )
- is False
- )
- # Compare levelno, not levelname: the FancyConsoleFormatter
- # colorizes record.levelname IN PLACE when a console handler is
- # installed in the test process, so string comparison breaks
- # depending on logging-config import order.
- warnings = [r for r in caplog.records if r.levelno == logging.WARNING]
- assert len(warnings) == 1
- assert "extended_thinking" in warnings[0].message
+ async def test_thinking_unavailable_forces_baseline(self):
+ """The kill switch wins over subscription and flag alike.
- @pytest.mark.asyncio
- async def test_thinking_available_default_preserves_legacy_behaviour(self):
- """The new ``thinking_available`` kwarg defaults to True, so
- existing call sites (and existing tests in this class) continue
- to work without explicit opt-in."""
+ Set where the SDK transport simply cannot run — today
+ ``CHAT_USE_LOCAL=true``, since Ollama does not speak Anthropic's
+ wire protocol.
+ """
with patch(
"backend.copilot.executor.processor.is_feature_enabled",
- new=AsyncMock(return_value=False),
+ new=AsyncMock(return_value=True),
):
assert (
- await resolve_use_sdk_for_mode(
- "extended_thinking",
+ await resolve_use_sdk(
"user-1",
- use_claude_code_subscription=False,
- config_default=False,
+ use_claude_code_subscription=True,
+ config_default=True,
+ thinking_available=False,
)
- is True
+ is False
)
-
-class TestResolveEffectiveMode:
- """Tests for the CHAT_MODE_OPTION server-side gate."""
-
- @pytest.mark.asyncio
- async def test_none_mode_passes_through(self):
- """mode=None is returned as-is without a flag check."""
- with patch(
- "backend.copilot.executor.processor.is_feature_enabled",
- new=AsyncMock(return_value=False),
- ) as flag_mock:
- assert await resolve_effective_mode(None, "user-1") is None
- flag_mock.assert_not_awaited()
-
@pytest.mark.asyncio
- async def test_mode_stripped_when_flag_disabled(self):
- """When CHAT_MODE_OPTION is off, mode is dropped to None."""
+ async def test_anonymous_user_is_routable(self):
with patch(
"backend.copilot.executor.processor.is_feature_enabled",
new=AsyncMock(return_value=False),
):
- assert await resolve_effective_mode("fast", "user-1") is None
- assert await resolve_effective_mode("extended_thinking", "user-1") is None
-
- @pytest.mark.asyncio
- async def test_mode_preserved_when_flag_enabled(self):
- """When CHAT_MODE_OPTION is on, the user-selected mode is preserved."""
- with patch(
- "backend.copilot.executor.processor.is_feature_enabled",
- new=AsyncMock(return_value=True),
- ):
- assert await resolve_effective_mode("fast", "user-1") == "fast"
assert (
- await resolve_effective_mode("extended_thinking", "user-1")
- == "extended_thinking"
+ await resolve_use_sdk(
+ None,
+ use_claude_code_subscription=False,
+ config_default=False,
+ )
+ is False
)
- @pytest.mark.asyncio
- async def test_anonymous_user_with_mode(self):
- """Anonymous users (user_id=None) still pass through the gate."""
- with patch(
- "backend.copilot.executor.processor.is_feature_enabled",
- new=AsyncMock(return_value=False),
- ) as flag_mock:
- assert await resolve_effective_mode("fast", None) is None
- flag_mock.assert_awaited_once()
-
-
-# ---------------------------------------------------------------------------
-# _execute_async aclose propagation
-# ---------------------------------------------------------------------------
-
class _TrackedStream:
"""Minimal async-generator stand-in that records whether ``aclose``
@@ -794,14 +686,12 @@ async def test_expert_tenancy_errors_publish_actionable_copy(
def _codex_entry(
*,
credential_id: str = "cred-1",
- mode: CopilotMode | None = None,
) -> CoPilotExecutionEntry:
return CoPilotExecutionEntry(
session_id="sess-codex",
turn_id="turn-codex",
user_id="user-1",
message="hi",
- mode=mode,
llm_auth_provider="codex",
llm_credential_id=credential_id,
)
@@ -831,7 +721,6 @@ async def test_codex_route_uses_claude_sdk_for_builder_and_releases_lease():
transport.acquire_runtime_lease = AsyncMock(return_value=lease)
baseline_stream = MagicMock()
sdk_stream = MagicMock(return_value=MagicMock())
- resolve_mode = AsyncMock(return_value=None)
with (
patch(
@@ -851,10 +740,6 @@ async def test_codex_route_uses_claude_sdk_for_builder_and_releases_lease():
"backend.copilot.sdk.service.stream_chat_completion_sdk",
sdk_stream,
),
- patch(
- "backend.copilot.executor.processor.resolve_effective_mode",
- resolve_mode,
- ),
patch(
"backend.copilot.executor.processor.wrap_stream_with_heartbeat",
return_value=MagicMock(),
@@ -869,7 +754,7 @@ async def test_codex_route_uses_claude_sdk_for_builder_and_releases_lease():
),
):
await CoPilotProcessor()._execute_async(
- _codex_entry(mode="extended_thinking"),
+ _codex_entry(),
threading.Event(),
MagicMock(),
_make_log(),
@@ -881,9 +766,7 @@ async def test_codex_route_uses_claude_sdk_for_builder_and_releases_lease():
lock_timeout_seconds=_CODEX_CREDENTIAL_ACQUIRE_TIMEOUT_SECONDS,
)
lease.release.assert_awaited_once()
- resolve_mode.assert_awaited_once_with("extended_thinking", "user-1")
sdk_stream.assert_called_once()
- assert sdk_stream.call_args.kwargs["mode"] is None
assert sdk_stream.call_args.kwargs["credential_lease"] is lease
assert sdk_stream.call_args.kwargs["session"].session_id == "sess-codex"
baseline_stream.assert_not_called()
diff --git a/autogpt_platform/backend/backend/copilot/executor/utils.py b/autogpt_platform/backend/backend/copilot/executor/utils.py
index 62a9355467..b577b86e1e 100644
--- a/autogpt_platform/backend/backend/copilot/executor/utils.py
+++ b/autogpt_platform/backend/backend/copilot/executor/utils.py
@@ -17,7 +17,7 @@ from backend.copilot.active_turns import (
get_inflight_turn_limit,
inflight_turn_limit_message,
)
-from backend.copilot.config import CopilotLlmAuthProvider, CopilotLLMModel, CopilotMode
+from backend.copilot.config import CopilotLlmAuthProvider, CopilotLLMModel
from backend.copilot.permissions import CopilotPermissions
from backend.data.rabbitmq import Exchange, ExchangeType, Queue, RabbitMQConfig
from backend.util.logging import TruncatedLogger, is_structured_logging_enabled
@@ -206,9 +206,6 @@ class CoPilotExecutionEntry(BaseModel):
team_id: str | None = None
"""Active workspace for tenant-scoped execution"""
- mode: CopilotMode | None = None
- """Autopilot mode override: 'fast' or 'extended_thinking'. None = server default."""
-
model: CopilotLLMModel | None = None
"""Per-request model tier: 'standard' or 'advanced'. None = server default."""
@@ -253,7 +250,6 @@ async def enqueue_copilot_turn(
file_ids: list[str] | None = None,
organization_id: str | None = None,
team_id: str | None = None,
- mode: CopilotMode | None = None,
model: CopilotLLMModel | None = None,
llm_auth_provider: CopilotLlmAuthProvider = "platform",
llm_credential_id: str | None = None,
@@ -287,7 +283,6 @@ async def enqueue_copilot_turn(
file_ids=file_ids,
organization_id=organization_id,
team_id=team_id,
- mode=mode,
model=model,
llm_auth_provider=llm_auth_provider,
llm_credential_id=llm_credential_id,
@@ -316,7 +311,6 @@ async def schedule_turn(
file_ids: list[str] | None = None,
organization_id: str | None = None,
team_id: str | None = None,
- mode: CopilotMode | None = None,
model: CopilotLLMModel | None = None,
llm_auth_provider: CopilotLlmAuthProvider = "platform",
llm_credential_id: str | None = None,
@@ -382,7 +376,6 @@ async def schedule_turn(
file_ids=file_ids,
organization_id=organization_id,
team_id=team_id,
- mode=mode,
model=model,
llm_auth_provider=llm_auth_provider,
llm_credential_id=llm_credential_id,
@@ -405,7 +398,6 @@ async def dispatch_turn(
file_ids: list[str] | None = None,
organization_id: str | None = None,
team_id: str | None = None,
- mode: CopilotMode | None = None,
model: CopilotLLMModel | None = None,
llm_auth_provider: CopilotLlmAuthProvider = "platform",
llm_credential_id: str | None = None,
@@ -458,7 +450,6 @@ async def dispatch_turn(
file_ids=file_ids,
organization_id=organization_id,
team_id=team_id,
- mode=mode,
model=model,
llm_auth_provider=llm_auth_provider,
llm_credential_id=llm_credential_id,
@@ -493,7 +484,6 @@ async def schedule_chat_turn(
file_ids: list[str] | None = None,
organization_id: str | None = None,
team_id: str | None = None,
- mode: CopilotMode | None = None,
model: CopilotLLMModel | None = None,
llm_auth_provider: CopilotLlmAuthProvider = "platform",
llm_credential_id: str | None = None,
@@ -563,7 +553,6 @@ async def schedule_chat_turn(
file_ids=file_ids,
organization_id=organization_id,
team_id=team_id,
- mode=mode,
model=model,
llm_auth_provider=llm_auth_provider,
llm_credential_id=llm_credential_id,
diff --git a/autogpt_platform/backend/backend/copilot/executor/utils_test.py b/autogpt_platform/backend/backend/copilot/executor/utils_test.py
index 0e675a799a..fb207af861 100644
--- a/autogpt_platform/backend/backend/copilot/executor/utils_test.py
+++ b/autogpt_platform/backend/backend/copilot/executor/utils_test.py
@@ -79,27 +79,10 @@ class TestCoPilotExecutionEntry:
assert entry.user_id == "u1"
assert entry.message == "hello"
assert entry.is_user_message is True
- assert entry.mode is None
+ assert not hasattr(entry, "mode")
assert entry.context is None
assert entry.file_ids is None
- def test_mode_field(self):
- entry = CoPilotExecutionEntry(
- session_id="s1",
- user_id="u1",
- message="test",
- mode="fast",
- )
- assert entry.mode == "fast"
-
- entry2 = CoPilotExecutionEntry(
- session_id="s1",
- user_id="u1",
- message="test",
- mode="extended_thinking",
- )
- assert entry2.mode == "extended_thinking"
-
def test_optional_fields(self):
entry = CoPilotExecutionEntry(
session_id="s1",
@@ -120,7 +103,6 @@ class TestCoPilotExecutionEntry:
session_id="s1",
user_id="u1",
message="hello",
- mode="fast",
)
json_str = entry.model_dump_json()
restored = CoPilotExecutionEntry.model_validate_json(json_str)
diff --git a/autogpt_platform/backend/backend/copilot/sdk/env.py b/autogpt_platform/backend/backend/copilot/sdk/env.py
index d8463b5350..19a30c3006 100644
--- a/autogpt_platform/backend/backend/copilot/sdk/env.py
+++ b/autogpt_platform/backend/backend/copilot/sdk/env.py
@@ -108,7 +108,7 @@ def build_sdk_env(
f"build_sdk_env() called under transport "
f"{config.transport.name!r}, which doesn't support the SDK. "
"The request should have been downgraded to the baseline "
- "path — see executor.processor.resolve_use_sdk_for_mode."
+ "path — see executor.processor.resolve_use_sdk."
)
# --- Mode 1: Claude Code subscription auth ---
diff --git a/autogpt_platform/backend/backend/copilot/sdk/service.py b/autogpt_platform/backend/backend/copilot/sdk/service.py
index 43af253ed8..b183a026de 100644
--- a/autogpt_platform/backend/backend/copilot/sdk/service.py
+++ b/autogpt_platform/backend/backend/copilot/sdk/service.py
@@ -65,7 +65,7 @@ from backend.util.prompt import (
)
from backend.util.settings import Settings
-from ..config import ChatConfig, CopilotLLMModel, CopilotMode
+from ..config import ChatConfig, CopilotLLMModel
from ..constants import (
COPILOT_ERROR_PREFIX,
COPILOT_RETRYABLE_ERROR_PREFIX,
@@ -126,7 +126,6 @@ from ..response_model import (
StreamFinish,
StreamFinishStep,
StreamHeartbeat,
- StreamModeChanged,
StreamReasoningDelta,
StreamReasoningEnd,
StreamReasoningStart,
@@ -4368,7 +4367,6 @@ async def stream_chat_completion_sdk( # pyright: ignore[reportGeneralTypeIssues
session: ChatSession | None = None,
file_ids: list[str] | None = None,
permissions: "CopilotPermissions | None" = None,
- mode: CopilotMode | None = None,
model: CopilotLLMModel | None = None,
request_arrival_at: float = 0.0,
organization_id: str | None = None,
@@ -4729,13 +4727,6 @@ async def stream_chat_completion_sdk( # pyright: ignore[reportGeneralTypeIssues
yield StreamStart(messageId=message_id, sessionId=session_id)
- if mode == "fast" and not is_codex_transport:
- # The request asked for Fast but this turn runs on the SDK
- # engine (building-mode pin or engine-switch continuation).
- # Tell stale pickers — a client that missed the original
- # data-mode-changed (reload, second tab) re-syncs here.
- yield StreamModeChanged(mode="extended_thinking")
-
set_execution_context(
user_id,
session,
@@ -4794,9 +4785,9 @@ async def stream_chat_completion_sdk( # pyright: ignore[reportGeneralTypeIssues
tier_name: "CopilotLLMModel" = (
"advanced" if model == "advanced" else "standard"
)
- route_mode = "fast" if mode == "fast" else "thinking"
sdk_model, codex_effort, routing_source = await resolve_codex_model_route(
- route_mode,
+ # This turn is on the SDK engine by definition.
+ "thinking",
tier_name,
credential_lease,
)
@@ -4907,11 +4898,7 @@ async def stream_chat_completion_sdk( # pyright: ignore[reportGeneralTypeIssues
# effort: applies to models with extended thinking (Sonnet,
# Opus, Mythos) and Kimi K2.6 via OpenRouter's ``reasoning``
# extension (#12871).
- effort=(
- "medium"
- if mode == "fast"
- else (config.claude_agent_thinking_effort or "high")
- ),
+ effort=config.claude_agent_thinking_effort or "high",
)
if not is_codex_transport:
# The Claude/OpenRouter paths use provider-USD controls. A Codex
@@ -6206,7 +6193,6 @@ async def stream_chat_completion_sdk( # pyright: ignore[reportGeneralTypeIssues
session=session,
file_ids=None,
permissions=permissions,
- mode=mode,
model=model,
organization_id=organization_id,
team_id=team_id,
diff --git a/autogpt_platform/backend/backend/copilot/tools/enter_building_mode.py b/autogpt_platform/backend/backend/copilot/tools/enter_building_mode.py
index fea2cba19c..d6dcec2b53 100644
--- a/autogpt_platform/backend/backend/copilot/tools/enter_building_mode.py
+++ b/autogpt_platform/backend/backend/copilot/tools/enter_building_mode.py
@@ -88,7 +88,8 @@ class EnterAgentBuildingModeTool(BaseTool):
# switch — the baseline loop ends this turn at the next
# iteration boundary and the processor dispatches an SDK
# continuation turn. The tool call in message history also
- # pins all later turns to SDK (resolve_use_sdk_for_mode).
+ # pins all later turns to SDK (see the building-mode pin in
+ # executor.processor, which resolve_use_sdk defers to).
engine_switch.request_switch(
session_id,
# The session owner is the authoritative identity — the
diff --git a/autogpt_platform/backend/backend/copilot/turn_queue.py b/autogpt_platform/backend/backend/copilot/turn_queue.py
index fc068e207e..2bc0852056 100644
--- a/autogpt_platform/backend/backend/copilot/turn_queue.py
+++ b/autogpt_platform/backend/backend/copilot/turn_queue.py
@@ -10,7 +10,7 @@ text column:
The user's pending message itself is just a normal ChatMessage row (no
status of its own). The dispatcher's submit-time payload (``file_ids``,
-``mode``, ``model``, ``permissions``, ``context``, ``request_arrival_at``)
+``model``, ``permissions``, ``context``, ``request_arrival_at``)
is stashed in that row's ``metadata`` JSONB so a later promotion can
replay the turn faithfully.
@@ -104,7 +104,6 @@ async def try_enqueue_turn(
is_user_message: bool = True,
context: Mapping[str, str] | None = None,
file_ids: list[str] | None = None,
- mode: str | None = None,
model: str | None = None,
llm_auth_provider: CopilotLlmAuthProvider = "platform",
llm_credential_id: str | None = None,
@@ -130,7 +129,6 @@ async def try_enqueue_turn(
is_user_message=is_user_message,
context=context,
file_ids=file_ids,
- mode=mode,
model=model,
llm_auth_provider=llm_auth_provider,
llm_credential_id=llm_credential_id,
@@ -149,7 +147,6 @@ async def enqueue_turn(
is_user_message: bool = True,
context: Mapping[str, str] | None = None,
file_ids: list[str] | None = None,
- mode: str | None = None,
model: str | None = None,
llm_auth_provider: CopilotLlmAuthProvider = "platform",
llm_credential_id: str | None = None,
@@ -170,8 +167,6 @@ async def enqueue_turn(
metadata["context"] = dict(context)
if file_ids is not None:
metadata["file_ids"] = list(file_ids)
- if mode is not None:
- metadata["mode"] = mode
if model is not None:
metadata["model"] = model
metadata["llm_auth_provider"] = llm_auth_provider
@@ -371,7 +366,6 @@ async def dispatch_next_for_user(user_id: str) -> bool:
# org context on promotion.
organization_id=head.organization_id,
team_id=head.team_id,
- mode=metadata.get("mode"),
model=metadata.get("model"),
llm_auth_provider=head.metadata.llm_auth_provider,
llm_credential_id=head.metadata.llm_credential_id,
diff --git a/autogpt_platform/backend/backend/copilot/turn_queue_test.py b/autogpt_platform/backend/backend/copilot/turn_queue_test.py
index 369f01a981..da1f2241a0 100644
--- a/autogpt_platform/backend/backend/copilot/turn_queue_test.py
+++ b/autogpt_platform/backend/backend/copilot/turn_queue_test.py
@@ -58,7 +58,7 @@ def _mock_session(session_id: str = "s1", title: str | None = "T") -> MagicMock:
@pytest.mark.asyncio
async def test_enqueue_turn_packs_metadata_into_metadata_payload() -> None:
- """Non-message dispatch params (file_ids, mode, model, permissions,
+ """Non-message dispatch params (file_ids, model, permissions,
context, request_arrival_at) land in the ChatMessage row's
``metadata`` JSONB so the dispatcher can replay the original turn
shape later."""
@@ -79,7 +79,6 @@ async def test_enqueue_turn_packs_metadata_into_metadata_payload() -> None:
message_metadata={"hidden": True, "kind": "expert_kickoff"},
context={"url": "https://example.com"},
file_ids=["f1", "f2"],
- mode="extended_thinking",
model="advanced",
permissions={"tool_filter": "allow"},
request_arrival_at=123.45,
@@ -90,7 +89,7 @@ async def test_enqueue_turn_packs_metadata_into_metadata_payload() -> None:
metadata = kwargs["metadata"]
assert metadata["context"] == {"url": "https://example.com"}
assert metadata["file_ids"] == ["f1", "f2"]
- assert metadata["mode"] == "extended_thinking"
+ assert "mode" not in metadata
assert metadata["model"] == "advanced"
assert metadata["llm_auth_provider"] == "platform"
assert metadata["permissions"] == {"tool_filter": "allow"}
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
index 1776eec035..6cf3732cd9 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
@@ -134,7 +134,6 @@ export function useBuilderChatPanel({
hydratedMessages,
hasActiveStream,
refetchSession: sessionQuery.refetch,
- copilotMode: "fast",
copilotModel: undefined,
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/autopilot-mode-switch.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/autopilot-mode-switch.test.tsx
deleted file mode 100644
index adafe03fa7..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/autopilot-mode-switch.test.tsx
+++ /dev/null
@@ -1,175 +0,0 @@
-import { server } from "@/mocks/mock-server";
-import {
- copilotResumeHandler,
- copilotStreamHandler,
-} from "@/tests/integrations/copilot-sse";
-import { screen, waitFor } from "@testing-library/react";
-import type { UIMessageChunk } from "ai";
-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import { resetCopilotChatRegistry } from "../copilotChatRegistry";
-import { useCopilotUIStore } from "../store";
-import {
- renderHost,
- sessionHandler,
- TEST_BACKEND_BASE_URL,
- TEST_SESSION_ID,
- typeAndSend,
-} from "./sse-helpers";
-
-vi.mock("@/services/environment", async (importActual) => {
- const actual = await importActual<typeof import("@/services/environment")>();
- return {
- ...actual,
- environment: {
- ...actual.environment,
- getAGPTServerBaseUrl: () => TEST_BACKEND_BASE_URL,
- },
- };
-});
-
-vi.mock("../helpers", async (importActual) => {
- const actual = await importActual<typeof import("../helpers")>();
- return {
- ...actual,
- getCopilotAuthHeaders: async () => ({ "x-test-auth": "yes" }),
- };
-});
-
-vi.mock("@/lib/auth/hooks/useAuth", () => ({
- useAuth: () => ({ isUserLoading: false, isLoggedIn: true }),
-}));
-
-vi.mock("@/services/feature-flags/use-get-flag", () => ({
- Flag: {
- ARTIFACTS: "ARTIFACTS",
- CHAT_MODE_OPTION: "CHAT_MODE_OPTION",
- ENABLE_PLATFORM_PAYMENT: "ENABLE_PLATFORM_PAYMENT",
- },
- useGetFlag: () => false,
-}));
-
-beforeEach(() => {
- resetCopilotChatRegistry();
- useCopilotUIStore.getState().setCopilotChatMode("fast");
- useCopilotUIStore.getState().clearCopilotModePin();
-});
-
-afterEach(() => {
- resetCopilotChatRegistry();
-});
-
-describe("AutoPilot streaming — server-initiated engine switch", () => {
- it("flips the chat mode when the stream emits data-mode-changed", async () => {
- server.use(
- copilotStreamHandler({
- baseUrl: TEST_BACKEND_BASE_URL,
- sessionId: TEST_SESSION_ID,
- chunks: [
- { type: "start", messageId: "msg-1" },
- { type: "text-start", id: "t1" },
- { type: "text-delta", id: "t1", delta: "Switching to Thinking…" },
- { type: "text-end", id: "t1" },
- {
- type: "data-mode-changed",
- data: { mode: "extended_thinking" },
- } as unknown as UIMessageChunk,
- { type: "finish" },
- ],
- }),
- );
-
- renderHost();
- await typeAndSend("build me an agent");
-
- await waitFor(
- () => {
- expect(useCopilotUIStore.getState().copilotChatMode).toBe(
- "extended_thinking",
- );
- },
- { timeout: 5000 },
- );
- // Session-scoped pin: the toggle locks, and the user's persisted
- // default must NOT have been rewritten by the server-forced switch.
- expect(useCopilotUIStore.getState().copilotModePinned).toBe(true);
- });
-
- it("keeps the selected mode on streams without a mode change", async () => {
- server.use(
- copilotStreamHandler({
- baseUrl: TEST_BACKEND_BASE_URL,
- sessionId: TEST_SESSION_ID,
- chunks: [
- { type: "start", messageId: "msg-1" },
- { type: "text-start", id: "t1" },
- { type: "text-delta", id: "t1", delta: "Hi." },
- { type: "text-end", id: "t1" },
- { type: "finish" },
- ],
- }),
- );
-
- renderHost();
- await typeAndSend("hi");
-
- await waitFor(() => {
- expect(useCopilotUIStore.getState().copilotChatMode).toBe("fast");
- });
- expect(useCopilotUIStore.getState().copilotModePinned).toBe(false);
- });
-});
-
-describe("AutoPilot streaming — continuation reconnect probe", () => {
- it("probes after a mode-switch turn and attaches the server-dispatched continuation", async () => {
- server.use(
- copilotStreamHandler({
- baseUrl: TEST_BACKEND_BASE_URL,
- sessionId: TEST_SESSION_ID,
- chunks: [
- { type: "start", messageId: "msg-1" },
- { type: "text-start", id: "t1" },
- { type: "text-delta", id: "t1", delta: "Switching to Thinking…" },
- { type: "text-end", id: "t1" },
- {
- type: "data-mode-changed",
- data: { mode: "extended_thinking" },
- } as unknown as UIMessageChunk,
- { type: "finish" },
- ],
- }),
- copilotResumeHandler({
- baseUrl: TEST_BACKEND_BASE_URL,
- sessionId: TEST_SESSION_ID,
- chunks: [
- { type: "start", messageId: "msg-2" },
- { type: "text-start", id: "t2" },
- { type: "text-delta", id: "t2", delta: "Continuing the build." },
- { type: "text-end", id: "t2" },
- { type: "finish" },
- ],
- }),
- );
-
- renderHost();
- await typeAndSend("build me an agent");
- expect(await screen.findByText("Switching to Thinking…")).toBeDefined();
-
- // The continuation turn registers its stream server-side; the probe's
- // session refetch (armed by data-mode-changed, up to 8×500ms) must see
- // it and reconnect via the GET resume route.
- server.use(
- sessionHandler({
- active_stream: {
- turn_id: "turn-2",
- last_message_id: "msg-2",
- },
- }),
- );
-
- expect(
- await screen.findByText("Continuing the build.", undefined, {
- timeout: 8000,
- }),
- ).toBeDefined();
- }, 15000);
-});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/helpers.test.ts
index 71c949c453..fd15a8185f 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/helpers.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/helpers.test.ts
@@ -10,7 +10,7 @@ import {
getCopilotAuthHeaders,
getSendSuppressionReason,
parseSessionIDs,
- resolveModeChangedMode,
+ isEngineSwitchPart,
resolveSessionDryRun,
shouldDebounceReconnect,
shouldSuppressDuplicateSend,
@@ -683,38 +683,38 @@ describe("getCopilotAuthHeaders", () => {
});
});
-describe("resolveModeChangedMode", () => {
- it("returns the mode for a data-mode-changed part with a known mode", () => {
+describe("isEngineSwitchPart", () => {
+ it("reports a switch for a data-mode-changed part naming either engine", () => {
expect(
- resolveModeChangedMode({
+ isEngineSwitchPart({
type: "data-mode-changed",
data: { mode: "extended_thinking" },
}),
- ).toBe("extended_thinking");
+ ).toBe(true);
expect(
- resolveModeChangedMode({
+ isEngineSwitchPart({
type: "data-mode-changed",
data: { mode: "fast" },
}),
- ).toBe("fast");
+ ).toBe(true);
});
- it("returns null for other data part types", () => {
+ it("ignores other data part types", () => {
expect(
- resolveModeChangedMode({ type: "data-status", data: { mode: "fast" } }),
- ).toBeNull();
+ isEngineSwitchPart({ type: "data-status", data: { mode: "fast" } }),
+ ).toBe(false);
});
- it("returns null for unknown or missing modes", () => {
+ it("ignores unknown or missing engines", () => {
expect(
- resolveModeChangedMode({
+ isEngineSwitchPart({
type: "data-mode-changed",
data: { mode: "turbo" },
}),
- ).toBeNull();
- expect(resolveModeChangedMode({ type: "data-mode-changed" })).toBeNull();
+ ).toBe(false);
+ expect(isEngineSwitchPart({ type: "data-mode-changed" })).toBe(false);
expect(
- resolveModeChangedMode({ type: "data-mode-changed", data: "fast" }),
- ).toBeNull();
+ isEngineSwitchPart({ type: "data-mode-changed", data: "fast" }),
+ ).toBe(false);
});
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
index d7944c3816..91b3859cee 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/store.test.ts
@@ -246,7 +246,6 @@ describe("useCopilotUIStore", () => {
isNotificationsEnabled: false,
isSoundEnabled: true,
showNotificationDialog: false,
- copilotChatMode: "extended_thinking",
copilotLlmModel: "standard",
});
});
@@ -393,32 +392,6 @@ describe("useCopilotUIStore", () => {
});
});
- describe("copilotChatMode", () => {
- it("defaults to extended_thinking", () => {
- expect(useCopilotUIStore.getState().copilotChatMode).toBe(
- "extended_thinking",
- );
- });
-
- it("sets mode to fast", () => {
- useCopilotUIStore.getState().setCopilotChatMode("fast");
- expect(useCopilotUIStore.getState().copilotChatMode).toBe("fast");
- });
-
- it("sets mode back to extended_thinking", () => {
- useCopilotUIStore.getState().setCopilotChatMode("fast");
- useCopilotUIStore.getState().setCopilotChatMode("extended_thinking");
- expect(useCopilotUIStore.getState().copilotChatMode).toBe(
- "extended_thinking",
- );
- });
-
- it("persists mode to localStorage", () => {
- useCopilotUIStore.getState().setCopilotChatMode("fast");
- expect(window.localStorage.getItem("copilot-mode")).toBe("fast");
- });
- });
-
describe("copilotLlmModel", () => {
it("defaults to standard", () => {
expect(useCopilotUIStore.getState().copilotLlmModel).toBe("standard");
@@ -440,8 +413,7 @@ describe("useCopilotUIStore", () => {
expect(useCopilotUIStore.getState().copilotLlmAuth).toBeNull();
});
- it("stores a Codex credential without changing the selected mode or model", () => {
- useCopilotUIStore.getState().setCopilotChatMode("extended_thinking");
+ it("stores a Codex credential without changing the selected model", () => {
useCopilotUIStore.getState().setCopilotLlmModel("advanced");
useCopilotUIStore.getState().setCopilotLlmAuth({
authProvider: "codex",
@@ -452,9 +424,6 @@ describe("useCopilotUIStore", () => {
authProvider: "codex",
credentialId: "codex-credential-1",
});
- expect(useCopilotUIStore.getState().copilotChatMode).toBe(
- "extended_thinking",
- );
expect(useCopilotUIStore.getState().copilotLlmModel).toBe("advanced");
});
});
@@ -462,7 +431,6 @@ describe("useCopilotUIStore", () => {
describe("clearCopilotLocalData", () => {
it("resets state and clears localStorage keys", () => {
useCopilotUIStore.getState().setSearchOpen(true);
- useCopilotUIStore.getState().setCopilotChatMode("fast");
useCopilotUIStore.getState().setCopilotLlmModel("advanced");
useCopilotUIStore.getState().setCopilotLlmAuth({
authProvider: "codex",
@@ -476,7 +444,6 @@ describe("useCopilotUIStore", () => {
const state = useCopilotUIStore.getState();
expect(state.isSearchOpen).toBe(false);
- expect(state.copilotChatMode).toBe("extended_thinking");
expect(state.copilotLlmModel).toBe("standard");
expect(state.copilotLlmAuth).toBeNull();
expect(state.isNotificationsEnabled).toBe(false);
@@ -519,13 +486,6 @@ describe("useCopilotUIStore localStorage initialisation", () => {
window.localStorage.clear();
});
- it("reads fast chat mode from localStorage on store creation", async () => {
- window.localStorage.setItem("copilot-mode", "fast");
- vi.resetModules();
- const { useCopilotUIStore: fresh } = await import("../store");
- expect(fresh.getState().copilotChatMode).toBe("fast");
- });
-
it("reads advanced model from localStorage on store creation", async () => {
window.localStorage.setItem("copilot-model", "advanced");
vi.resetModules();
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx
index 4654feca32..6dccd46bfa 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx
@@ -33,7 +33,6 @@ import { DryRunToggleButton } from "./components/DryRunToggleButton";
import { FileChips } from "./components/FileChips";
import { MentionDropdown } from "./components/MentionDropdown";
import { ModelToggleButton } from "./components/ModelToggleButton";
-import { ModeToggleButton } from "./components/ModeToggleButton";
import { LLMRouteSelector } from "./components/LlmRouteSelector";
import { RecordingButton } from "./components/RecordingButton";
import { RecordingIndicator } from "./components/RecordingIndicator";
@@ -95,46 +94,19 @@ export function ChatInput({
hideSubmitWhenEmpty = false,
recipientPicker,
}: Props) {
- const {
- copilotChatMode,
- copilotModePinned,
- setCopilotChatMode,
- copilotLlmModel,
- setCopilotLlmModel,
- isDryRun,
- setIsDryRun,
- } = useCopilotUIStore();
- const showModeToggle = useGetFlag(Flag.CHAT_MODE_OPTION);
- const showDryRunToggle = showModeToggle;
+ const { copilotLlmModel, setCopilotLlmModel, isDryRun, setIsDryRun } =
+ useCopilotUIStore();
+ // Still the CHAT_MODE_OPTION flag, which no longer names what it gates: the
+ // Fast/Thinking control it was created for is gone. Renaming it means an
+ // LaunchDarkly change, so it is left until the combined picker restructures
+ // these controls anyway. Splitting it now would need two new flags and would
+ // hide both survivors until someone created them.
+ const showAdvancedComposerControls = useGetFlag(Flag.CHAT_MODE_OPTION);
const showWorkspaceFiles = useGetFlag(Flag.CHAT_WORKSPACE_FILES);
const [attachments, setAttachments] = useState<Attachment[]>([]);
const [isPickerOpen, setIsPickerOpen] = useState(false);
const [isMultiline, setIsMultiline] = useState(false);
- function handleToggleMode() {
- if (copilotModePinned) {
- toast({
- title: "Mode is locked while building an agent",
- description:
- "This session switched to Extended Thinking for agent building — building sessions stay on that engine.",
- });
- return;
- }
- const next =
- copilotChatMode === "extended_thinking" ? "fast" : "extended_thinking";
- setCopilotChatMode(next);
- toast({
- title:
- next === "fast"
- ? "Switched to Fast mode"
- : "Switched to Extended Thinking mode",
- description:
- next === "fast"
- ? "Optimized for speed — ideal for simpler tasks."
- : "Responses may take longer.",
- });
- }
-
function handleToggleModel() {
const next = copilotLlmModel === "advanced" ? "standard" : "advanced";
setCopilotLlmModel(next);
@@ -378,20 +350,13 @@ export function ChatInput({
align="inline-end"
className="order-none ml-auto gap-1 py-1 pr-1.5"
>
- {showModeToggle && !isStreaming && (
- <>
- <ModeToggleButton
- mode={copilotChatMode}
- onToggle={handleToggleMode}
- pinned={copilotModePinned}
- />
- <ModelToggleButton
- model={copilotLlmModel}
- onToggle={handleToggleModel}
- />
- </>
+ {showAdvancedComposerControls && !isStreaming && (
+ <ModelToggleButton
+ model={copilotLlmModel}
+ onToggle={handleToggleModel}
+ />
)}
- {showDryRunToggle && !hasSession && (
+ {showAdvancedComposerControls && !hasSession && (
<DryRunToggleButton
isDryRun={isDryRun}
onToggle={handleToggleDryRun}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInput.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInput.test.tsx
index e65eac4fb5..8b5d67fe8d 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInput.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInput.test.tsx
@@ -10,11 +10,6 @@ import {
NEW_SKILL_PROMPT,
} from "@/components/contextual/guidedPrompts";
import type { UIMessage } from "ai";
-import type { CredentialsMetaResponse } from "@/lib/autogpt-server-api";
-import {
- CredentialsProvidersContext,
- type CredentialsProviderData,
-} from "@/providers/agent-credentials/credentials-provider";
import { useRef } from "react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { ChatInput } from "../ChatInput";
@@ -45,12 +40,6 @@ vi.mock("@/app/api/__generated__/endpoints/chat/chat", () => ({
}),
}));
-let mockCopilotMode = "extended_thinking";
-let mockCopilotModePinned = false;
-const mockSetCopilotChatMode = vi.fn((mode: string) => {
- mockCopilotMode = mode;
-});
-
let mockCopilotLlmModel = "standard";
const mockSetCopilotLlmModel = vi.fn((model: string) => {
mockCopilotLlmModel = model;
@@ -65,11 +54,6 @@ const mockSetInitialPrompt = vi.fn((value: string | null) => {
vi.mock("@/app/(platform)/copilot/store", () => ({
useCopilotUIStore: () => ({
- copilotMode: mockCopilotMode,
- setCopilotMode: mockSetCopilotChatMode,
- copilotChatMode: mockCopilotMode,
- setCopilotChatMode: mockSetCopilotChatMode,
- copilotModePinned: mockCopilotModePinned,
copilotLlmModel: mockCopilotLlmModel,
setCopilotLlmModel: mockSetCopilotLlmModel,
copilotLlmAuth: {
@@ -218,31 +202,9 @@ vi.mock("../components/DryRunToggleButton", () => ({
const mockOnSend = vi.fn();
-const codexCredential: CredentialsMetaResponse = {
- id: "codex-credential-1",
- provider: "codex",
- type: "oauth2",
- title: "Personal ChatGPT",
- scopes: [],
-};
-
-const codexProvider: CredentialsProviderData = {
- provider: "codex",
- providerName: "Codex",
- savedCredentials: [codexCredential],
- isSystemProvider: false,
- oAuthCallback: async () => codexCredential,
- mcpOAuthCallback: async () => codexCredential,
- createAPIKeyCredentials: async () => codexCredential,
- createUserPasswordCredentials: async () => codexCredential,
- createHostScopedCredentials: async () => codexCredential,
- deleteCredentials: async () => ({ deleted: true, revoked: null }),
-};
-
afterEach(() => {
vi.clearAllMocks();
mockCancel.mockReset();
- mockCopilotMode = "extended_thinking";
mockCopilotLlmModel = "standard";
mockCopilotLlmAuthProvider = "platform";
mockFlagValue = false;
@@ -311,25 +273,24 @@ describe("ChatInput token devtool badge", () => {
});
});
-describe("ChatInput mode toggle", () => {
- it("does not render mode toggle when flag is disabled", () => {
+describe("ChatInput advanced composer controls", () => {
+ it("does not render advanced controls when the flag is disabled", () => {
mockFlagValue = false;
render(<ChatInput onSend={mockOnSend} />);
expect(screen.queryByLabelText(/switch to/i)).toBeNull();
});
- it("renders mode toggle when flag is enabled", () => {
+ it("renders the model toggle when the flag is enabled", () => {
mockFlagValue = true;
render(<ChatInput onSend={mockOnSend} />);
- expect(screen.getByLabelText(/switch to fast mode/i)).toBeDefined();
+ expect(screen.getByLabelText(/switch to advanced model/i)).toBeDefined();
});
- it("shows Codex mode and model controls backed by the model catalog", () => {
+ it("shows the Codex model control backed by the model catalog", () => {
mockFlagValue = true;
mockCopilotLlmAuthProvider = "codex";
render(<ChatInput onSend={mockOnSend} />);
- expect(screen.getByLabelText(/switch to fast mode/i)).toBeTruthy();
expect(screen.getByLabelText(/switch to advanced model/i)).toBeTruthy();
});
@@ -356,115 +317,28 @@ describe("ChatInput mode toggle", () => {
it("hides the route selector when only one subsidized transport is connected", () => {
mockFlagValue = true;
- const { rerender } = render(
- <CredentialsProvidersContext.Provider value={{ codex: codexProvider }}>
- <ChatInput onSend={mockOnSend} />
- </CredentialsProvidersContext.Provider>,
- );
+ const { rerender } = render(<ChatInput onSend={mockOnSend} />);
expect(screen.queryByLabelText(/AI connection:/i)).toBeNull();
- rerender(
- <CredentialsProvidersContext.Provider value={{ codex: codexProvider }}>
- <ChatInput onSend={mockOnSend} hasSession />
- </CredentialsProvidersContext.Provider>,
- );
+ rerender(<ChatInput onSend={mockOnSend} hasSession />);
expect(screen.queryByLabelText(/AI connection:/i)).toBeNull();
});
- // The toggles are icon-only in the composer row, so the mode reaches
- // assistive tech through the label rather than visible text.
- it("names the switch out of extended_thinking mode", () => {
- mockFlagValue = true;
- mockCopilotMode = "extended_thinking";
- render(<ChatInput onSend={mockOnSend} />);
- expect(screen.getByLabelText("Switch to Fast mode")).toBeDefined();
- });
-
- it("names the switch out of fast mode", () => {
- mockFlagValue = true;
- mockCopilotMode = "fast";
- render(<ChatInput onSend={mockOnSend} />);
- expect(
- screen.getByLabelText("Switch to Extended Thinking mode"),
- ).toBeDefined();
- });
-
- it("keeps the mode locked while pinned (building mode)", () => {
- mockFlagValue = true;
- mockCopilotMode = "extended_thinking";
- mockCopilotModePinned = true;
- render(<ChatInput onSend={mockOnSend} />);
- const button = screen.getByLabelText(/mode locked to extended thinking/i);
- expect(button.getAttribute("aria-disabled")).toBe("true");
- fireEvent.click(button);
- expect(mockSetCopilotChatMode).not.toHaveBeenCalled();
- mockCopilotModePinned = false;
- });
-
- it("toggles from extended_thinking to fast on click", () => {
- mockFlagValue = true;
- mockCopilotMode = "extended_thinking";
- render(<ChatInput onSend={mockOnSend} />);
- fireEvent.click(screen.getByLabelText(/switch to fast mode/i));
- expect(mockSetCopilotChatMode).toHaveBeenCalledWith("fast");
- });
-
- it("toggles from fast to extended_thinking on click", () => {
- mockFlagValue = true;
- mockCopilotMode = "fast";
- render(<ChatInput onSend={mockOnSend} />);
- fireEvent.click(screen.getByLabelText(/switch to extended thinking/i));
- expect(mockSetCopilotChatMode).toHaveBeenCalledWith("extended_thinking");
- });
-
- it("hides toggle buttons when streaming", () => {
+ it("hides the model toggle when streaming", () => {
mockFlagValue = true;
render(<ChatInput onSend={mockOnSend} isStreaming />);
- expect(
- screen.queryByLabelText(/switch to (fast|extended thinking) mode/i),
- ).toBeNull();
expect(
screen.queryByLabelText(/switch to (advanced|balanced|standard) model/i),
).toBeNull();
});
- it("shows mode toggle when hasSession is true and not streaming", () => {
- // Mode is per-message — can be changed between turns even in an existing session.
+ it("shows the model toggle between turns of an existing session", () => {
mockFlagValue = true;
render(<ChatInput onSend={mockOnSend} hasSession />);
expect(
- screen.queryByLabelText(/switch to (fast|extended thinking) mode/i),
+ screen.queryByLabelText(/switch to (advanced|balanced|standard) model/i),
).not.toBeNull();
});
-
- it("exposes aria-pressed=true in extended_thinking mode", () => {
- mockFlagValue = true;
- mockCopilotMode = "extended_thinking";
- render(<ChatInput onSend={mockOnSend} />);
- const button = screen.getByLabelText(/switch to fast mode/i);
- expect(button.getAttribute("aria-pressed")).toBe("true");
- });
-
- it("sets aria-pressed=false in fast mode", () => {
- mockFlagValue = true;
- mockCopilotMode = "fast";
- render(<ChatInput onSend={mockOnSend} />);
- const button = screen.getByLabelText(/switch to extended thinking/i);
- expect(button.getAttribute("aria-pressed")).toBe("false");
- });
-
- it("shows a toast when the user toggles mode", async () => {
- const { toast } = await import("@/components/molecules/Toast/use-toast");
- mockFlagValue = true;
- mockCopilotMode = "extended_thinking";
- render(<ChatInput onSend={mockOnSend} />);
- fireEvent.click(screen.getByLabelText(/switch to fast mode/i));
- expect(toast).toHaveBeenCalledWith(
- expect.objectContaining({
- title: expect.stringMatching(/switched to fast mode/i),
- }),
- );
- });
});
describe("ChatInput queue button", () => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ModeToggleButton.stories.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ModeToggleButton.stories.tsx
deleted file mode 100644
index 02114b04a8..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ModeToggleButton.stories.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import type { Meta, StoryObj } from "@storybook/nextjs";
-import { ModeToggleButton } from "./ModeToggleButton";
-
-const meta: Meta<typeof ModeToggleButton> = {
- title: "Copilot/ModeToggleButton",
- component: ModeToggleButton,
- tags: ["autodocs"],
- parameters: {
- layout: "centered",
- docs: {
- description: {
- component:
- "Toggle between Fast and Extended Thinking copilot modes. Hidden while a response is streaming.",
- },
- },
- },
- args: {
- onToggle: () => {},
- },
-};
-
-export default meta;
-type Story = StoryObj<typeof meta>;
-
-export const FastMode: Story = {
- args: {
- mode: "fast",
- },
-};
-
-export const ExtendedThinkingMode: Story = {
- args: {
- mode: "extended_thinking",
- },
-};
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ModeToggleButton.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ModeToggleButton.tsx
deleted file mode 100644
index f27e77f939..0000000000
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ModeToggleButton.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-"use client";
-
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { Icon } from "@/components/atoms/Icon/Icon";
-import { cn } from "@/lib/utils";
-import { BrainIcon, FlashIcon, LockIcon } from "@hugeicons/core-free-icons";
-import type { CopilotMode } from "../../../store";
-
-interface Props {
- mode: CopilotMode;
- onToggle: () => void;
- /** When true the mode is locked to Extended Thinking (agent build flow). */
- pinned?: boolean;
-}
-
-export function ModeToggleButton({ mode, onToggle, pinned = false }: Props) {
- const isExtended = mode === "extended_thinking";
- const tooltipText = pinned
- ? "Extended Thinking is required while building an agent"
- : isExtended
- ? "Extended Thinking — deeper reasoning (click to switch to Fast)"
- : "Fast mode — quicker responses (click to switch to Thinking)";
-
- const ariaLabel = pinned
- ? "Mode locked to Extended Thinking while building an agent"
- : isExtended
- ? "Switch to Fast mode"
- : "Switch to Extended Thinking mode";
-
- // The glyph carries the state on its own — a brain, a lightning bolt, or a
- // padlock — so the button stays readable without a text label.
- function getIcon() {
- if (pinned) return <Icon icon={LockIcon} size={16} />;
- return isExtended ? (
- <Icon icon={BrainIcon} size={16} />
- ) : (
- <Icon icon={FlashIcon} size={16} />
- );
- }
-
- return (
- <Tooltip>
- <TooltipTrigger asChild>
- <button
- type="button"
- aria-pressed={isExtended}
- aria-disabled={pinned}
- onClick={onToggle}
- className={cn(
- "inline-flex h-8 w-8 items-center justify-center rounded-full text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-700",
- pinned && "cursor-not-allowed opacity-70 hover:bg-transparent",
- )}
- aria-label={ariaLabel}
- >
- {getIcon()}
- </button>
- </TooltipTrigger>
- <TooltipContent>{tooltipText}</TooltipContent>
- </Tooltip>
- );
-}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/copilotChatRegistry.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/copilotChatRegistry.ts
index e2650dd970..697e102e2d 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/copilotChatRegistry.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/copilotChatRegistry.ts
@@ -7,11 +7,10 @@ import {
createCopilotTransport,
type MutableValue,
} from "./copilotStreamTransport";
-import type { CopilotLlmModel, CopilotMode } from "./store";
+import type { CopilotLlmModel } from "./store";
interface CopilotChatRuntime {
chat: Chat<UIMessage>;
- copilotModeRef: MutableValue<CopilotMode | undefined>;
copilotModelRef: MutableValue<CopilotLlmModel | undefined>;
onFinish?: (args: {
isDisconnect?: boolean;
@@ -73,9 +72,6 @@ export function getOrCreateCopilotChatRuntime(sessionId: string) {
const existing = copilotChatRuntimes.get(sessionId);
if (existing) return existing;
- const copilotModeRef: MutableValue<CopilotMode | undefined> = {
- current: undefined,
- };
const copilotModelRef: MutableValue<CopilotLlmModel | undefined> = {
current: undefined,
};
@@ -85,7 +81,6 @@ export function getOrCreateCopilotChatRuntime(sessionId: string) {
id: sessionId,
transport: createCopilotTransport({
sessionId,
- copilotModeRef,
copilotModelRef,
}),
onFinish: (args) => {
@@ -106,7 +101,6 @@ export function getOrCreateCopilotChatRuntime(sessionId: string) {
});
const runtime = {
chat,
- copilotModeRef,
copilotModelRef,
get onData() {
return callbacks.onData;
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/copilotStreamTransport.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/copilotStreamTransport.ts
index 7992eb5aa9..97fd141417 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/copilotStreamTransport.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/copilotStreamTransport.ts
@@ -8,7 +8,7 @@ import { getKickoffExpertIdFromMetadata } from "./expertKickoff";
import { getCopilotAuthHeaders } from "./helpers";
import { isTokenDevtoolEnabled } from "./tokenDevtool/gate";
import { createUsageCapturingFetch } from "./tokenDevtool/usageTap";
-import type { CopilotLlmModel, CopilotMode } from "./store";
+import type { CopilotLlmModel } from "./store";
export interface MutableValue<T> {
current: T;
@@ -17,13 +17,9 @@ export interface MutableValue<T> {
interface CreateTransportArgs {
sessionId: string;
/**
- * Ref to the current autopilot mode. Kept as a ref (rather than captured
- * value) so mid-session mode changes are picked up on the next send without
- * recreating the transport — recreating would reset `useChat`'s internal
- * `Chat` instance and break mid-session streaming.
+ * Ref to the current model tier, rather than a captured value, so a
+ * mid-session change is picked up on the next send.
*/
- copilotModeRef: MutableValue<CopilotMode | undefined>;
- /** Ref to the current model tier. See `copilotModeRef` for rationale. */
copilotModelRef: MutableValue<CopilotLlmModel | undefined>;
}
@@ -58,7 +54,6 @@ class SmoothedCopilotChatTransport extends DefaultChatTransport<UIMessage> {
*/
export function createCopilotTransport({
sessionId,
- copilotModeRef,
copilotModelRef,
}: CreateTransportArgs) {
const baseUrl = `${environment.getAGPTServerBaseUrl()}/api/chat/sessions/${sessionId}/stream`;
@@ -103,7 +98,6 @@ export function createCopilotTransport({
is_user_message: last.role === "user",
context: null,
file_ids: fileIds && fileIds.length > 0 ? fileIds : null,
- mode: copilotModeRef.current ?? null,
model: copilotModelRef.current ?? null,
// Supplying options forces uuid's
// getRandomValues path. Unlike crypto.randomUUID,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/helpers.ts
index ef9af7ff58..023ea0a021 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/helpers.ts
@@ -377,11 +377,17 @@ export function deduplicateMessages(messages: UIMessage[]): UIMessage[] {
});
}
-export function resolveModeChangedMode(dataPart: {
+/**
+ * True when the server reports it moved a turn to a different execution
+ * engine. Nothing displays the engine and nothing can request one — the only
+ * consumer widens its post-finish refetch window, because a switch takes
+ * longer to settle. The named engine is deliberately not returned.
+ */
+export function isEngineSwitchPart(dataPart: {
type: string;
data?: unknown;
-}): "extended_thinking" | "fast" | null {
- if (dataPart.type !== "data-mode-changed") return null;
+}): boolean {
+ if (dataPart.type !== "data-mode-changed") return false;
const mode = (dataPart.data as { mode?: string } | undefined)?.mode;
- return mode === "extended_thinking" || mode === "fast" ? mode : null;
+ return mode === "extended_thinking" || mode === "fast";
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
index 2d592840fa..3f9fb49527 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts
@@ -56,9 +56,6 @@ export const MIN_ARTIFACT_PANEL_WIDTH = 400;
/** Space kept for the chat + rail when sizing a side panel (drag clamp and viewport clamp). */
export const PANEL_RESERVED_WIDTH = 440;
-/** Autopilot response mode. */
-export type CopilotMode = "extended_thinking" | "fast";
-
/** Per-request model tier. 'standard' = current default; 'advanced' = highest-capability. */
export type CopilotLlmModel = "standard" | "advanced";
@@ -206,13 +203,6 @@ interface CopilotUIState {
markUserClosedForAutoOpen: () => void;
resetAutoOpenState: () => void;
- /** Autopilot mode: 'extended_thinking' (default) or 'fast'. */
- copilotChatMode: CopilotMode;
- setCopilotChatMode: (mode: CopilotMode) => void;
- copilotModePinned: boolean;
- applyServerModeChange: (mode: CopilotMode) => void;
- clearCopilotModePin: () => void;
-
/** Model tier: 'standard' (default) or 'advanced' (highest-capability). */
copilotLlmModel: CopilotLlmModel;
setCopilotLlmModel: (model: CopilotLlmModel) => void;
@@ -520,22 +510,6 @@ export const useCopilotUIStore = create<CopilotUIState>((set, get) => ({
_autoOpenUserClosed = false;
},
- copilotChatMode: (() => {
- const saved = isClient ? storage.get(Key.COPILOT_MODE) : null;
- return saved === "fast" ? "fast" : "extended_thinking";
- })(),
- setCopilotChatMode: (mode) => {
- storage.set(Key.COPILOT_MODE, mode);
- set({ copilotChatMode: mode });
- },
- copilotModePinned: false,
- applyServerModeChange: (mode) => {
- set({ copilotChatMode: mode, copilotModePinned: true });
- },
- clearCopilotModePin: () => {
- set({ copilotModePinned: false });
- },
-
copilotLlmModel: (() => {
const saved = isClient ? storage.get(Key.COPILOT_MODEL) : null;
return saved === "advanced" ? "advanced" : "standard";
@@ -575,6 +549,8 @@ export const useCopilotUIStore = create<CopilotUIState>((set, get) => ({
storage.clean(Key.COPILOT_ARTIFACT_PANEL_WIDTH);
storage.clean(Key.COPILOT_COMPLETED_SESSIONS);
storage.clean(Key.COPILOT_DRY_RUN);
+ // Retired key — still cleaned so a user who set it before the control
+ // was removed does not keep a dead entry forever.
storage.clean(Key.COPILOT_MODE);
storage.clean(Key.COPILOT_MODEL);
set({
@@ -591,7 +567,6 @@ export const useCopilotUIStore = create<CopilotUIState>((set, get) => ({
activeTab: "files",
lastArtifact: null,
},
- copilotChatMode: "extended_thinking",
copilotLlmModel: "standard",
copilotLlmAuth: null,
isDryRun: false,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts
index 83e2ad1665..9ef0eefcdb 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts
@@ -64,7 +64,7 @@ function getLatestKickoffAttemptToken(messages: UIMessage[]) {
export function useCopilotPage() {
const { user, isUserLoading, isLoggedIn } = useAuth();
- const isModeToggleEnabled = useGetFlag(Flag.CHAT_MODE_OPTION);
+ const showAdvancedComposerControls = useGetFlag(Flag.CHAT_MODE_OPTION);
const isExpertsEnabled = useGetFlag(Flag.HIRE_EXPERTS);
const isBrainDumpEnabled = useGetFlag(Flag.ONBOARDING_BRAIN_DUMP);
const [expertIdParam] = useQueryState("expertId", parseAsString);
@@ -117,7 +117,7 @@ export function useCopilotPage() {
setKickoffParam,
]);
- const { copilotChatMode, copilotLlmModel, isDryRun } = useCopilotUIStore();
+ const { copilotLlmModel, isDryRun } = useCopilotUIStore();
const { mutate: completeGreeting } = useCompleteBrainDumpGreeting();
const {
@@ -180,8 +180,7 @@ export function useCopilotPage() {
activeTurnStartMessageId,
hasActiveStream,
refetchSession,
- copilotMode: isModeToggleEnabled ? copilotChatMode : undefined,
- copilotModel: isModeToggleEnabled ? copilotLlmModel : undefined,
+ copilotModel: showAdvancedComposerControls ? copilotLlmModel : undefined,
});
const kickoffAttemptToken = getLatestKickoffAttemptToken(currentMessages);
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotStream.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotStream.ts
index 79e0221f15..3648828ef8 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotStream.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotStream.ts
@@ -30,12 +30,12 @@ import {
hasActiveBackendStream,
hasInProgressAssistantParts,
hasVisibleAssistantContent,
- resolveModeChangedMode,
+ isEngineSwitchPart,
} from "./helpers";
import { extractDbSequence } from "./helpers/convertChatSessionToUiMessages";
import { getLatestAssistantStatusMessage } from "./messageParts";
import { useCopilotUIStore } from "./store";
-import type { CopilotLlmModel, CopilotMode } from "./store";
+import type { CopilotLlmModel } from "./store";
import { useCopilotReconnect } from "./useCopilotReconnect";
import { useCopilotStop } from "./useCopilotStop";
import { useHydrateOnStreamEnd } from "./useHydrateOnStreamEnd";
@@ -76,8 +76,6 @@ interface UseCopilotStreamArgs {
activeTurnStartMessageId?: string | null;
hasActiveStream: boolean;
refetchSession: () => Promise<{ data?: unknown }>;
- /** Autopilot mode to use for requests. `undefined` = let backend decide via feature flags. */
- copilotMode: CopilotMode | undefined;
/** Model tier override. `undefined` = let backend decide. */
copilotModel: CopilotLlmModel | undefined;
}
@@ -89,7 +87,6 @@ export function useCopilotStream({
activeTurnStartMessageId = null,
hasActiveStream,
refetchSession,
- copilotMode,
copilotModel,
}: UseCopilotStreamArgs) {
const queryClient = useQueryClient();
@@ -106,7 +103,6 @@ export function useCopilotStream({
return getOrCreateCopilotChatRuntime(sessionId);
}, [sessionId]);
if (chatRuntime) {
- chatRuntime.copilotModeRef.current = copilotMode;
chatRuntime.copilotModelRef.current = copilotModel;
}
@@ -285,14 +281,11 @@ export function useCopilotStream({
}
function handleData(dataPart: { type: string; data?: unknown }) {
- const mode = resolveModeChangedMode(dataPart);
- if (mode) {
+ // The execution engine is an internal detail with no control and no
+ // display — but a switch still takes longer to settle, so the signal
+ // is kept to widen the post-finish refetch window below.
+ if (isEngineSwitchPart(dataPart)) {
pendingEngineSwitchRef.current = true;
- // Server-forced switch: session-scoped UI state only — must not
- // persist to localStorage and rewrite the user's global default.
- // The pin locks the toggle for the rest of this session (the
- // backend overrides a manual flip anyway).
- useCopilotUIStore.getState().applyServerModeChange(mode);
}
}
@@ -306,7 +299,6 @@ export function useCopilotStream({
}
if (chatRuntime.onData === handleData) {
chatRuntime.onData = undefined;
- useCopilotUIStore.getState().clearCopilotModePin();
}
if (chatRuntime.onError === handleError) {
chatRuntime.onError = undefined;
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/MemoryChatPanel/useMemoryChatPanel.ts b/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/MemoryChatPanel/useMemoryChatPanel.ts
index 0e8a5d8c52..15dca8d2d3 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/MemoryChatPanel/useMemoryChatPanel.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/MemoryChatPanel/useMemoryChatPanel.ts
@@ -64,7 +64,6 @@ export function useMemoryChatPanel({ scopeExpertID }: Args) {
hydratedMessages,
hasActiveStream,
refetchSession: sessionQuery.refetch,
- copilotMode: undefined,
copilotModel: undefined,
});
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index c61f24ff0d..fdb0d3e2d6 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -26540,14 +26540,6 @@
],
"title": "File Ids"
},
- "mode": {
- "anyOf": [
- { "type": "string", "enum": ["fast", "extended_thinking"] },
- { "type": "null" }
- ],
- "title": "Mode",
- "description": "Autopilot mode: 'fast' for baseline LLM, 'extended_thinking' for Claude Agent SDK. If None, uses the server default (extended_thinking)."
- },
"model": {
"anyOf": [
{ "type": "string", "enum": ["standard", "advanced"] },