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,4 +1,5 @@
import pytest
import logging
from review_agent.file_summary.skills.base import BaseSkill, SkillResult, WorkflowContext
from review_agent.file_summary.skills.registry import SkillRegistry
@@ -25,3 +26,21 @@ def test_skill_registry_executes_registered_skill(django_user_model):
assert result.success is True
assert result.data == {"batch_id": batch.id}
@pytest.mark.django_db
def test_skill_registry_logs_skill_lifecycle(caplog, django_user_model):
from review_agent.models import Conversation, FileSummaryBatch
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")
batch = FileSummaryBatch.objects.create(conversation=conversation, user=user, batch_no="FS-LOG")
registry = SkillRegistry()
registry.register(EchoSkill())
with caplog.at_level(logging.INFO, logger="review_agent.file_summary"):
registry.execute("echo", WorkflowContext(batch=batch))
messages = [record.getMessage() for record in caplog.records]
assert any("Skill started" in message and "echo" in message for message in messages)
assert any("Skill finished" in message and "echo" in message for message in messages)