fix(search): 채팅 web_search 라우터에 ollama_cloud 누락 수정 + Tavily 키 vault 참조 해석 — preferred_provider를 ollama_cloud로 바꾸자 검색 전체가 Tavily 폴백 401로 죽던 문제

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5.5 committed 2026-09-30 00:30:11 +09:00
1 parent 6677c4ff71
commit 03d278377b
3 files changed
+28 -2

No files matched your search

+6 -2
View File
@@ -7,6 +7,7 @@
* Logging: Daily session logs in memory/
*/
import { routesThroughWebTool } from '../tools/search-merge.js';
import 'dotenv/config';
import express from 'express';
import cors from 'cors';
@@ -1339,10 +1340,13 @@ async function duckDuckGoSearch(query: string): Promise<string> {
async function webSearch(query: string): Promise<string> {
const searchCfg = (getConfig().getConfig() as any).search || {};
const provider = searchCfg.preferred_provider || 'google';
const tavilyKey = searchCfg.tavily_api_key || '';
// 설정값은 `vault:...` 참조일 수 있다 — 풀지 않고 넘기면 Tavily가 참조 문자열을 키로 받아 401을 낸다.
const tavilyKey = getConfig().resolveSecret(searchCfg.tavily_api_key) || '';
console.log(`[v2] webSearch via ${provider}: ${query.slice(0, 80)}`);
if (provider === 'ollama' || provider === 'searxng') {
// ollama_cloud도 여기서 web.ts로 보낸다 — 빠지면 Ollama 1순위 설정이 통째로 Tavily 폴백으로 새서
// 채팅 검색이 401로 죽는다(2026-09-30 사고). 병행(SearXNG) 모드도 web.ts 안에서 처리된다.
if (routesThroughWebTool(provider)) {
try {
const { executeWebSearch } = await import('../tools/web.js');
const res = await executeWebSearch({ query, max_results: 5 });
+10
View File
@@ -71,3 +71,13 @@ export function renderMergedStdout(results: MergeItem[]): string {
.map((r, i) => `[${i + 1}] ${r.title}\n ${r.url}\n ${r.snippet}`)
.join('\n\n');
}
/**
* 채팅의 web_search 라우터(server.ts webSearch)가 web.ts의 executeWebSearch로 넘기는 provider들.
* 2026-09-30 사고: 여기에 'ollama_cloud'가 빠져 있어서 설정을 그 값으로 바꾸자 채팅 검색 전체가
* Tavily 폴백으로 새 401을 냈다. 설정에서 고를 수 있는 provider를 이 목록과 테스트로 묶어 둔다.
*/
export const WEB_TOOL_ROUTED_PROVIDERS = ['ollama', 'ollama_cloud', 'searxng'] as const;
export function routesThroughWebTool(provider: string): boolean {
return (WEB_TOOL_ROUTED_PROVIDERS as readonly string[]).includes(provider);
}
+12
View File
@@ -60,3 +60,15 @@ describe('renderMergedStdout', () => {
assert.match(out, /\n\n\[2\] T2\n/);
});
});
import { routesThroughWebTool, WEB_TOOL_ROUTED_PROVIDERS } from '../src/tools/search-merge';
describe('routesThroughWebTool — 채팅 검색 라우터', () => {
test('ollama_cloud가 web.ts로 라우팅된다 — 빠지면 Tavily 폴백으로 새 401 (2026-09-30 사고)', () => {
assert.equal(routesThroughWebTool('ollama_cloud'), true);
assert.deepEqual([...WEB_TOOL_ROUTED_PROVIDERS].sort(), ['ollama', 'ollama_cloud', 'searxng']);
});
test('직접 API를 쓰는 provider는 라우팅하지 않는다', () => {
assert.equal(routesThroughWebTool('tavily'), false);
assert.equal(routesThroughWebTool('google'), false);
});
});