feat(agent): 增加 LLM 路由与诊断日志

This commit is contained in:
2026-06-06 17:56:41 +08:00
parent 47b5ad1054
commit fa77c68d77
21 changed files with 832 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import logging
from pathlib import Path
from review_agent.models import FileSummaryBatchAttachment
@@ -9,6 +10,9 @@ from ..services.archive import ARCHIVE_EXTENSIONS, extract_archive
from .base import BaseSkill, SkillResult, WorkflowContext
logger = logging.getLogger("review_agent.file_summary.skills.archive_extract")
class ArchiveExtractSkill(BaseSkill):
name = "archive_extract"
@@ -16,11 +20,27 @@ class ArchiveExtractSkill(BaseSkill):
extracted_count = 0
target_dir = Path(context.batch.work_dir or "")
if not target_dir:
logger.info(
"Archive extract skipped without work dir",
extra={"batch_id": context.batch.pk, "batch_no": context.batch.batch_no},
)
return SkillResult(success=True, data={"extracted_count": 0})
for binding in FileSummaryBatchAttachment.objects.filter(batch=context.batch):
path = resolve_storage_path(binding.attachment.storage_path)
if path.suffix.lower().lstrip(".") not in ARCHIVE_EXTENSIONS:
continue
logger.info(
"Archive extract started",
extra={
"batch_id": context.batch.pk,
"attachment_id": binding.attachment_id,
"path": str(path),
},
)
extracted_count += len(extract_archive(path, target_dir))
logger.info(
"Archive extract finished",
extra={"batch_id": context.batch.pk, "extracted_count": extracted_count},
)
return SkillResult(success=True, data={"extracted_count": extracted_count})