RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(agent): use stored log titles in tables and exports (#21890)
Sbaaoui Idriss53599f3f4d4c
diff --git a/internal/dao/chat_session.go b/internal/dao/chat_session.goindex 069ab32720..4cc5bfaf19 100644--- a/internal/dao/chat_session.go+++ b/internal/dao/chat_session.go@@ -301,8 +301,7 @@ func (dao *ChatSessionDAO) ListAgentSessions(ctx context.Context, db *gorm.DB, pif params.Keywords != "" {keywords := strings.ToLower(params.Keywords)keywordPattern := "%" + keywords + "%"- messageMatch := "EXISTS (SELECT 1 FROM " + apiConversationMessageTable + " AS cm WHERE cm.conversation_id = api_4_conversation.id AND LOWER(cm.content) LIKE ?)"- query = query.Where("(LOWER(id) LIKE ? OR LOWER(name) LIKE ? OR "+messageMatch+")", keywordPattern, keywordPattern, keywordPattern)+ query = query.Where("(LOWER(id) LIKE ? OR LOWER(name) LIKE ?)", keywordPattern, keywordPattern)}dateColumn := "create_date"diff --git a/internal/dao/chat_session_test.go b/internal/dao/chat_session_test.goindex d9a6c9c89a..553557b0c2 100644--- a/internal/dao/chat_session_test.go+++ b/internal/dao/chat_session_test.go@@ -226,7 +226,7 @@ func TestChatSessionDAOListAgentSessionsFiltersAndPaginates(t *testing.T) {}}-func TestChatSessionDAOListAgentSessionsSearchesIDNameAndMessage(t *testing.T) {+func TestChatSessionDAOListAgentSessionsSearchesOnlyIDAndName(t *testing.T) {db := setupChatSessionDAOTestDB(t)createNamedAgentSessionForDAOTest(t, db, "release-session-id", "agent-1", "user-1", "plain", json.RawMessage(`[{"content":"ordinary"}]`), 1000)@@ -248,8 +248,8 @@ func TestChatSessionDAOListAgentSessionsSearchesIDNameAndMessage(t *testing.T) {t.Fatalf("ListAgentSessions failed: %v", err)}- if total != 3 {- t.Fatalf("expected total 3, got %d", total)+ if total != 2 {+ t.Fatalf("expected total 2, got %d", total)}gotIDs := make([]string, 0, len(sessions))for _, session := range sessions {@@ -258,7 +258,7 @@ func TestChatSessionDAOListAgentSessionsSearchesIDNameAndMessage(t *testing.T) {t.Fatalf("session %s leaked from agent %s", session.ID, session.DialogID)}}- wantIDs := []string{"release-session-id", "session-title", "session-message"}+ wantIDs := []string{"release-session-id", "session-title"}if len(gotIDs) != len(wantIDs) {t.Fatalf("ids = %v, want %v", gotIDs, wantIDs)}@@ -268,3 +268,42 @@ func TestChatSessionDAOListAgentSessionsSearchesIDNameAndMessage(t *testing.T) {}}}++func TestChatSessionDAOListAgentSessionsTitleSearch(t *testing.T) {+ db := setupChatSessionDAOTestDB(t)+ createNamedAgentSessionForDAOTest(t, db, "abc-session", "agent-1", "user-1", "hello in chinese", json.RawMessage(`[{"content":"你好"}]`), 1000)+ createNamedAgentSessionForDAOTest(t, db, "def-session", "agent-1", "user-1", "你好世界", json.RawMessage(`[{"content":"ordinary"}]`), 2000)+ for _, tc := range []struct {+ keyword, id string+ total int64+ page int+ }{+ {"HELLO IN CHINESE", "abc-session", 1, 1},+ {"in chin", "abc-session", 1, 1},+ {"ABC-SESSION", "abc-session", 1, 1},+ {"abc-", "abc-session", 1, 1},+ {"你好", "def-session", 1, 1},+ {"ordinary", "", 0, 1},+ {"", "abc-session", 2, 1},+ {"", "def-session", 2, 2},+ } {+ t.Run(tc.keyword+tc.id, func(t *testing.T) {+ total, rows, err := NewChatSessionDAO().ListAgentSessions(t.Context(), db, ListAgentSessionsParams{AgentID: "agent-1", Keywords: tc.keyword, Page: tc.page, PageSize: 1, OrderBy: "update_time"})+ if err != nil {+ t.Fatal(err)+ }+ if total != tc.total {+ t.Fatalf("total=%d, want %d", total, tc.total)+ }+ if tc.id == "" {+ if len(rows) != 0 {+ t.Fatalf("unexpected rows: %v", rows)+ }+ return+ }+ if len(rows) != 1 || rows[0].ID != tc.id {+ t.Fatalf("rows=%v, want %s", rows, tc.id)+ }+ })+ }+}diff --git a/web/src/pages/agents/agent-log-page.tsx b/web/src/pages/agents/agent-log-page.tsxindex ca122b638d..539aa835cc 100644--- a/web/src/pages/agents/agent-log-page.tsx+++ b/web/src/pages/agents/agent-log-page.tsx@@ -84,9 +84,7 @@ const AgentLogPage: React.FC = () => {dataIndex: 'title',key: 'title',render: (_text: string, record: IAgentLogResponse) => (- <span>- {record?.message?.length ? record?.message[0]?.content : ''}- </span>+ <span>{record.name}</span>),},{diff --git a/web/src/pages/agents/hooks/use-export-agent-log.ts b/web/src/pages/agents/hooks/use-export-agent-log.tsindex 1866432de8..42830f4e12 100644--- a/web/src/pages/agents/hooks/use-export-agent-log.ts+++ b/web/src/pages/agents/hooks/use-export-agent-log.ts@@ -50,7 +50,7 @@ export const useExportAgentLogToCSV = () => {const rows = data.map((item) => [item.id,item.user_id,- item.message?.length ? item.message[0]?.content : '',+ item.name,formatConversation(item),item.errors ? t('flow.failed') : t('flow.success'),item.round,