fix(agent): filter TuShare news with upstream keyword input (#16361)

## Summary

TuShare required non-empty upstream input but filtered fetched news with
the static `keyword` param (default empty string), so agent-provided
keywords were ignored.

Use `self._param.keyword or ans` when filtering, matching how AkShare
uses upstream input for its query.

Fixes #16360

## Test plan

- [x] `test_tushare_filters_with_upstream_keyword_when_param_empty`
mocks the API and asserts only rows matching the upstream keyword are
returned

---------

Co-authored-by: yzc <yuzhichang@gmail.com>
Co-authored-by: Harsh Kashyap <harshkashyap@Harshs-MacBook-Pro.local>
This commit is contained in:
Harsh Kashyap
2026-07-01 11:21:39 +05:30
committed by GitHub
parent 572f1ea9f4
commit 508f6226f8
2 changed files with 104 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
# limitations under the License.
#
import json
import logging
from abc import ABC
import pandas as pd
import time
@@ -73,7 +74,18 @@ class TuShare(ComponentBase, ABC):
df.columns = response['data']['fields']
if self.check_if_canceled("TuShare processing"):
return
tus_res.append({"content": (df[df['content'].str.contains(self._param.keyword, case=False)]).to_markdown()})
keyword = self._param.keyword or ans
logging.info(
"TuShare news filter keyword source=%s",
"param.keyword" if self._param.keyword else "upstream_input",
)
tus_res.append(
{
"content": (
df[df["content"].str.contains(keyword, case=False, na=False, regex=False)]
).to_markdown()
}
)
except Exception as e:
if self.check_if_canceled("TuShare processing"):
return