feat(agent): 合并同批次整理失败的agent重试调用,避免重复浪费token

同一download_hash或同一源目录下的失败记录在5分钟缓冲期内合并为一次agent调用,
批量处理时只识别一次媒体信息后复用到所有文件。
This commit is contained in:
jxxghp
2026-04-09 07:16:56 +08:00
parent 1b489ba581
commit 0c51d79be7
3 changed files with 197 additions and 42 deletions
+20 -2
View File
@@ -799,8 +799,17 @@ class TransferChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
try:
from app.agent import agent_manager
# 使用 download_hash 或源文件父目录作为分组键,
# 同一批次(如同一个种子)的失败记录会被合并为一次agent调用
group_key = (
task.download_hash or str(task.fileitem.path).rsplit("/", 1)[0]
if task.fileitem
else ""
)
asyncio.run_coroutine_threadsafe(
agent_manager.retry_failed_transfer(history.id),
agent_manager.retry_failed_transfer(
history.id, group_key=group_key
),
global_vars.loop,
)
logger.info(f"已触发AI智能体重试整理历史记录 #{history.id}")
@@ -1127,8 +1136,17 @@ class TransferChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
try:
from app.agent import agent_manager
# 使用 download_hash 或源文件父目录作为分组键
group_key = (
task.download_hash
or str(task.fileitem.path).rsplit("/", 1)[0]
if task.fileitem
else ""
)
asyncio.run_coroutine_threadsafe(
agent_manager.retry_failed_transfer(his.id),
agent_manager.retry_failed_transfer(
his.id, group_key=group_key
),
global_vars.loop,
)
logger.info(f"已触发AI智能体重试整理历史记录 #{his.id}")