@@ -175,17 +175,12 @@ function createCategoryTool(categoryId: CategoryId): ToolDefinition {
175175 ) ;
176176 }
177177
178- const extraParams : Record < string , string > = { } ;
179- if ( isuCd ) {
180- extraParams [ "isuCd" ] = isuCd ;
181- }
182-
178+ // isuCd omitted from API params — see comment in single-date path above
183179 const rangeResult = await fetchDateRange ( {
184180 endpoint : endpoint . path ,
185181 from : dateFrom ,
186182 to : dateTo ,
187183 apiKey,
188- extraParams,
189184 } ) ;
190185
191186 if ( ! rangeResult . success ) {
@@ -195,6 +190,10 @@ function createCategoryTool(categoryId: CategoryId): ToolDefinition {
195190 let data : readonly Record < string , string > [ ] =
196191 rangeResult . data as Record < string , string > [ ] ;
197192
193+ if ( isuCd ) {
194+ data = data . filter ( ( row ) => row [ "ISU_CD" ] === isuCd ) ;
195+ }
196+
198197 const filterExpr = args . filter as string | undefined ;
199198 const sortField = args . sort as string | undefined ;
200199 const sortDirection = ( args . sort_direction as "asc" | "desc" ) ?? "desc" ;
@@ -228,10 +227,10 @@ function createCategoryTool(categoryId: CategoryId): ToolDefinition {
228227 ) ;
229228 }
230229
230+ // isuCd is NOT passed to the API — KRX endpoints ignore it and return
231+ // all rows regardless. Client-side filtering is applied after fetch.
232+ // This also ensures a single cache entry per date (no isuCd in cache key).
231233 const params : Record < string , string > = { basDd : dateStr } ;
232- if ( isuCd ) {
233- params [ "isuCd" ] = isuCd ;
234- }
235234
236235 const result = await krxFetch ( {
237236 endpoint : endpoint . path ,
@@ -251,6 +250,10 @@ function createCategoryTool(categoryId: CategoryId): ToolDefinition {
251250
252251 let data : readonly Record < string , string > [ ] = result . data ;
253252
253+ if ( isuCd ) {
254+ data = data . filter ( ( row ) => row [ "ISU_CD" ] === isuCd ) ;
255+ }
256+
254257 data = applyPipeline ( data , {
255258 filter : filterExpr2 ,
256259 sort : sortField ,
0 commit comments