refactor(agent): simplify grep_chunks tool to a single regex query
The grep_chunks tool previously accepted an array of regex queries (1-5) and an optional knowledge_base_ids filter and limit. In practice the LLM either fired multiple near-duplicate calls or split synonyms across entries instead of using POSIX alternation, and KB scoping plus result limit are server-side concerns the model should not control. Reshape the contract to match `grep -E -i` semantics: - Schema accepts a single required `query` string. Combine concepts with `|` alternation in one regex instead of multiple calls. - Drop `knowledge_base_ids` and `limit` from the schema; the tool now always searches the full agent scope and uses a fixed internal cap. - Legacy `pattern`, `queries`, `patterns`, `max_results` keys are still accepted and joined into a single alternation regex so older callers and in-flight model outputs keep working. - Update the agent system prompt template to document the new single `query` field. - Frontend tool title now reads `query`/`queries`/`pattern`/`patterns` in that order so the search text is shown again under the new schema. - Add a dedicated `grepSearch` / `grepSearchFailed` tool status (zh-CN, en-US, ko-KR, ru-RU) and rename the zh-CN tool label to "搜索关键词" so the UI no longer prefixes the call with a generic "调用 ..." label.
This commit is contained in:
@@ -3889,6 +3889,8 @@ export default {
|
||||
searchKbFailed: 'Knowledge base search failed',
|
||||
webSearch: 'Web search',
|
||||
webSearchFailed: 'Web search failed',
|
||||
grepSearch: 'Keyword search',
|
||||
grepSearchFailed: 'Keyword search failed',
|
||||
getDocInfo: 'Getting document info',
|
||||
getDocInfoFailed: 'Failed to get document info',
|
||||
thinkingDone: 'Thinking complete',
|
||||
|
||||
@@ -3952,6 +3952,8 @@ export default {
|
||||
searchKbFailed: '지식베이스 검색 실패',
|
||||
webSearch: '웹 검색',
|
||||
webSearchFailed: '웹 검색 실패',
|
||||
grepSearch: '키워드 검색',
|
||||
grepSearchFailed: '키워드 검색 실패',
|
||||
getDocInfo: '문서 정보 조회',
|
||||
getDocInfoFailed: '문서 정보 조회 실패',
|
||||
thinkingDone: '사고 완료',
|
||||
|
||||
@@ -3527,6 +3527,8 @@ export default {
|
||||
searchKbFailed: 'Ошибка поиска по базе знаний',
|
||||
webSearch: 'Веб-поиск',
|
||||
webSearchFailed: 'Ошибка веб-поиска',
|
||||
grepSearch: 'Поиск по ключевым словам',
|
||||
grepSearchFailed: 'Ошибка поиска по ключевым словам',
|
||||
getDocInfo: 'Получение информации о документе',
|
||||
getDocInfoFailed: 'Ошибка получения информации о документе',
|
||||
thinkingDone: 'Размышление завершено',
|
||||
|
||||
@@ -3723,7 +3723,7 @@ export default {
|
||||
tools: {
|
||||
multiKbSearch: "跨库搜索",
|
||||
knowledgeSearch: "知识库搜索",
|
||||
grepChunks: "文本模式搜索",
|
||||
grepChunks: "搜索关键词",
|
||||
getChunkDetail: "获取片段详情",
|
||||
listKnowledgeChunks: "查看知识分块",
|
||||
listKnowledgeBases: "列出知识库",
|
||||
@@ -3824,7 +3824,7 @@ export default {
|
||||
},
|
||||
tools: {
|
||||
searchKnowledge: "知识库检索",
|
||||
grepChunks: "文本模式搜索",
|
||||
grepChunks: "搜索关键词",
|
||||
webSearch: "网络搜索",
|
||||
webFetch: "网页抓取",
|
||||
getDocumentInfo: "获取文档信息",
|
||||
@@ -3884,6 +3884,8 @@ export default {
|
||||
searchKbFailed: "检索知识库失败",
|
||||
webSearch: "网络搜索",
|
||||
webSearchFailed: "网络搜索失败",
|
||||
grepSearch: "搜索关键词",
|
||||
grepSearchFailed: "搜索关键词失败",
|
||||
getDocInfo: "获取文档信息",
|
||||
getDocInfoFailed: "获取文档信息失败",
|
||||
thinkingDone: "完成思考",
|
||||
|
||||
@@ -2200,14 +2200,22 @@ const getToolTitle = (event: any): string => {
|
||||
// Try to get patterns from arguments or tool_data
|
||||
let patterns: string[] = [];
|
||||
if (event.arguments && typeof event.arguments === 'object') {
|
||||
if (Array.isArray(event.arguments.patterns)) {
|
||||
if (Array.isArray(event.arguments.queries)) {
|
||||
patterns = event.arguments.queries;
|
||||
} else if (Array.isArray(event.arguments.patterns)) {
|
||||
patterns = event.arguments.patterns;
|
||||
} else if (event.arguments.query) {
|
||||
patterns = [event.arguments.query];
|
||||
} else if (event.arguments.pattern) {
|
||||
patterns = [event.arguments.pattern];
|
||||
}
|
||||
} else if (event.tool_data) {
|
||||
if (Array.isArray(event.tool_data.patterns)) {
|
||||
if (Array.isArray(event.tool_data.queries)) {
|
||||
patterns = event.tool_data.queries;
|
||||
} else if (Array.isArray(event.tool_data.patterns)) {
|
||||
patterns = event.tool_data.patterns;
|
||||
} else if (event.tool_data.query) {
|
||||
patterns = [event.tool_data.query];
|
||||
} else if (event.tool_data.pattern) {
|
||||
patterns = [event.tool_data.pattern];
|
||||
}
|
||||
@@ -2244,6 +2252,8 @@ const getToolDescription = (event: any): string => {
|
||||
return success ? t('agentStream.toolStatus.searchKb') : t('agentStream.toolStatus.searchKbFailed');
|
||||
} else if (toolName === 'web_search') {
|
||||
return success ? t('agentStream.toolStatus.webSearch') : t('agentStream.toolStatus.webSearchFailed');
|
||||
} else if (toolName === 'grep_chunks') {
|
||||
return success ? t('agentStream.toolStatus.grepSearch') : t('agentStream.toolStatus.grepSearchFailed');
|
||||
} else if (toolName === 'get_document_info') {
|
||||
return success ? t('agentStream.toolStatus.getDocInfo') : t('agentStream.toolStatus.getDocInfoFailed');
|
||||
} else if (toolName === 'thinking') {
|
||||
|
||||
Reference in New Issue
Block a user