Compare commits

...

2 Commits

Author SHA1 Message Date
Richard Guan
b600bb9a14 Merge branch 'main' into remove-simple-agent-feature-flag 2025-10-31 00:27:16 -07:00
Richard Guan
99496c117b feat: enable simple agent framework by default
Remove the simple-agent-framework feature flag and enable the functionality
by default. The simple agent framework is now always used for all research
types except DEEP research.

Changes:
- Remove feature flag checks in backend (process_message.py, streaming_utils.py)
- Remove feature flag checks in frontend (SearchToolRenderer.tsx, useChatController.ts)
- Remove feature flag key definition from feature_flags_keys.py
- Update tests to remove feature flag mocking

The simple agent framework improves the chat experience with better
tool rendering and packet handling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 11:53:47 -07:00
6 changed files with 29 additions and 88 deletions

View File

@@ -78,8 +78,6 @@ from onyx.db.projects import get_project_instructions
from onyx.db.projects import get_user_files_from_project
from onyx.db.search_settings import get_current_search_settings
from onyx.document_index.factory import get_default_document_index
from onyx.feature_flags.factory import get_default_feature_flag_provider
from onyx.feature_flags.feature_flags_keys import SIMPLE_AGENT_FRAMEWORK
from onyx.file_store.models import FileDescriptor
from onyx.file_store.models import InMemoryChatFile
from onyx.file_store.utils import build_frontend_file_url
@@ -757,15 +755,7 @@ def stream_chat_message_objects(
and (file.file_id not in project_file_ids)
]
)
feature_flag_provider = get_default_feature_flag_provider()
simple_agent_framework_enabled = (
feature_flag_provider.feature_enabled_for_user_tenant(
flag_key=SIMPLE_AGENT_FRAMEWORK,
user=user,
tenant_id=tenant_id,
)
and not new_msg_req.use_agentic_search
)
simple_agent_framework_enabled = not new_msg_req.use_agentic_search
prompt_user_message = default_build_user_message(
user_query=final_msg.message,
prompt_config=prompt_config,

View File

@@ -2,5 +2,3 @@
Feature flag keys used throughout the application.
Centralizes feature flag key definitions to avoid magic strings.
"""
SIMPLE_AGENT_FRAMEWORK = "simple-agent-framework"

View File

@@ -17,8 +17,6 @@ from onyx.db.chat import get_db_search_doc_by_id
from onyx.db.chat import translate_db_search_doc_to_server_search_doc
from onyx.db.models import ChatMessage
from onyx.db.tools import get_tool_by_id
from onyx.feature_flags.factory import get_default_feature_flag_provider
from onyx.feature_flags.feature_flags_keys import SIMPLE_AGENT_FRAMEWORK
from onyx.server.query_and_chat.streaming_models import CitationDelta
from onyx.server.query_and_chat.streaming_models import CitationInfo
from onyx.server.query_and_chat.streaming_models import CitationStart
@@ -45,7 +43,6 @@ from onyx.tools.tool_implementations.knowledge_graph.knowledge_graph_tool import
)
from onyx.tools.tool_implementations.search.search_tool import SearchTool
from onyx.tools.tool_implementations.web_search.web_search_tool import WebSearchTool
from shared_configs.contextvars import get_current_tenant_id
_CANNOT_SHOW_STEP_RESULTS_STR = "[Cannot display step results]"
@@ -473,16 +470,10 @@ def translate_db_message_to_packets(
db_session: Session,
start_step_nr: int = 1,
) -> EndStepPacketList:
use_simple_translation = False
if chat_message.research_type and chat_message.research_type != ResearchType.DEEP:
feature_flag_provider = get_default_feature_flag_provider()
tenant_id = get_current_tenant_id()
user = chat_message.chat_session.user
use_simple_translation = feature_flag_provider.feature_enabled_for_user_tenant(
flag_key=SIMPLE_AGENT_FRAMEWORK,
user=user,
tenant_id=tenant_id,
)
use_simple_translation = (
chat_message.research_type is not None
and chat_message.research_type != ResearchType.DEEP
)
if use_simple_translation:
return translate_db_message_to_packets_simple(

View File

@@ -1,6 +1,4 @@
from datetime import datetime
from typing import Any
from unittest.mock import patch
from sqlalchemy.orm import Session
@@ -15,34 +13,18 @@ from onyx.db.models import ResearchAgentIteration
from onyx.db.models import ResearchAgentIterationSubStep
from onyx.db.models import Tool
from onyx.db.models import User
from onyx.feature_flags.feature_flags_keys import SIMPLE_AGENT_FRAMEWORK
from onyx.feature_flags.interface import FeatureFlagProvider
from onyx.server.query_and_chat.streaming_models import FetchToolStart
from onyx.server.query_and_chat.streaming_models import SearchToolStart
from onyx.server.query_and_chat.streaming_utils import translate_db_message_to_packets
from tests.external_dependency_unit.conftest import create_test_user
class MockFeatureFlagProvider(FeatureFlagProvider):
"""Mock feature flag provider that returns a configurable value"""
def __init__(self, enabled: bool = True):
self.enabled = enabled
def feature_enabled(
self, flag_key: str, user_id: Any, user_properties: dict[str, Any] | None = None
) -> bool:
if flag_key == SIMPLE_AGENT_FRAMEWORK:
return self.enabled
return False
def test_simple_agent_with_search_and_fetch_packets(
db_session: Session,
tenant_context: None,
) -> None:
"""
Test that when feature flag is on and research_type is FAST,
Test that when research_type is FAST,
the translate_db_message_to_packets function returns packets with
SearchToolStart followed by FetchToolStart for web fetch operations.
"""
@@ -174,18 +156,12 @@ def test_simple_agent_with_search_and_fetch_packets(
# Refresh to load relationships
db_session.refresh(assistant_message)
# Mock the feature flag provider to return True
with patch(
"onyx.server.query_and_chat.streaming_utils.get_default_feature_flag_provider"
) as mock_get_provider:
mock_get_provider.return_value = MockFeatureFlagProvider(enabled=True)
# Call translate_db_message_to_packets
result = translate_db_message_to_packets(
chat_message=assistant_message,
db_session=db_session,
start_step_nr=1,
)
# Call translate_db_message_to_packets
result = translate_db_message_to_packets(
chat_message=assistant_message,
db_session=db_session,
start_step_nr=1,
)
# Verify packets were created
assert len(result.packet_list) > 0
@@ -218,7 +194,7 @@ def test_deep_research_ignores_simple_agent(
tenant_context: None,
) -> None:
"""
Test that even with feature flag on, DEEP research type
Test that DEEP research type
uses the old translation logic (no FetchToolStart packets).
"""
# Create a test user
@@ -315,18 +291,12 @@ def test_deep_research_ignores_simple_agent(
db_session.add(sub_step)
db_session.commit()
# Mock the feature flag provider to return True
with patch(
"onyx.server.query_and_chat.streaming_utils.get_default_feature_flag_provider"
) as mock_get_provider:
mock_get_provider.return_value = MockFeatureFlagProvider(enabled=True)
# Call translate_db_message_to_packets
result = translate_db_message_to_packets(
chat_message=assistant_message,
db_session=db_session,
start_step_nr=1,
)
# Call translate_db_message_to_packets
result = translate_db_message_to_packets(
chat_message=assistant_message,
db_session=db_session,
start_step_nr=1,
)
# Verify packets were created
assert len(result.packet_list) > 0
@@ -337,7 +307,7 @@ def test_deep_research_ignores_simple_agent(
# Verify we have NO FetchToolStart packets (should use old logic for DEEP)
assert (
len(fetch_packets) == 0
), "DEEP research should not produce FetchToolStart packets even with feature flag on"
), "DEEP research should not produce FetchToolStart packets"
# Verify we have SearchToolStart packets instead
search_packets = [

View File

@@ -329,21 +329,17 @@ export function useChatController({
// Check if the current message uses agent search (any non-null research type)
const isDeepResearch = lastMessage?.researchType === ResearchType.Deep;
const isSimpleAgentFrameworkEnabled =
posthog.isFeatureEnabled("simple-agent-framework") ?? false;
// Always call the backend stop endpoint if feature flag is enabled
if (isSimpleAgentFrameworkEnabled) {
try {
await stopChatSession(currentSession);
} catch (error) {
console.error("Failed to stop chat session:", error);
// Continue with UI cleanup even if backend call fails
}
// Always call the backend stop endpoint
try {
await stopChatSession(currentSession);
} catch (error) {
console.error("Failed to stop chat session:", error);
// Continue with UI cleanup even if backend call fails
}
// Only do the subsequent cleanup if the message was agent search or feature flag is not enabled
if (isDeepResearch || !isSimpleAgentFrameworkEnabled) {
// Only do the subsequent cleanup if the message was deep research
if (isDeepResearch) {
abortSession(currentSession);
if (

View File

@@ -14,7 +14,6 @@ import { SourceChip2 } from "@/app/chat/components/SourceChip2";
import { BlinkingDot } from "../../BlinkingDot";
import Text from "@/refresh-components/texts/Text";
import { SearchToolRendererV2 } from "./SearchToolRendererV2";
import { usePostHog } from "posthog-js/react";
import { ResearchType } from "@/app/chat/interfaces";
const INITIAL_RESULTS_TO_SHOW = 3;
@@ -80,9 +79,6 @@ export const SearchToolRenderer: MessageRenderer<
stopPacketSeen,
children,
}) => {
const posthog = usePostHog();
const isSimpleAgentFrameworkEnabled =
posthog.isFeatureEnabled("simple-agent-framework") ?? false;
// Check if this message has a research_type, which indicates it's using the simple agent framework
const isDeepResearch = state.researchType === ResearchType.Deep;
@@ -195,7 +191,7 @@ export const SearchToolRenderer: MessageRenderer<
const icon = isInternetSearch ? FiGlobe : FiSearch;
// If this message has a research type, use the V2 renderer (simple agent framework)
if (isSimpleAgentFrameworkEnabled && !isDeepResearch) {
if (!isDeepResearch) {
return (
<SearchToolRendererV2
packets={packets}