Refactor code structure for improved readability and maintainability

This commit is contained in:
mi222eh
2026-07-06 21:37:20 +02:00
parent 6ca6a5687a
commit 5f35f56edc
48 changed files with 8128 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import logging
from typing import Any, Callable
from core.agent import BaseAgent
from core.prompts import NOTIFICATION_READER_SYSTEM_PROMPT
from core.notification_tools import NotificationTools
logger: logging.Logger = logging.getLogger("agent-notification-reader")
class NotificationNoToolCalledError(Exception):
"""Raised when the Notification Reader Agent completes execution without calling any routing tool."""
pass
class NotificationReaderAgent(BaseAgent):
"""AI agent that reviews Gitea notifications and decides how to route them."""
def __init__(self, model_name: str) -> None:
super().__init__(model_name)
self.system_prompt = NOTIFICATION_READER_SYSTEM_PROMPT
async def decide_notification(
self,
mission: str,
inspection_tools: list[Callable[..., Any]],
notification_tools: NotificationTools,
) -> str:
"""Run the Notification Reader Agent and ensure a decision tool is called."""
decision_tools: list[Callable[..., Any]] = [
notification_tools.process_issue,
notification_tools.process_pr,
notification_tools.skip_notification,
]
combined_tools: list[Callable[..., Any]] = inspection_tools + decision_tools
logger.info("Running NotificationReaderAgent to decide action...")
response_text: str = await self.run_with_tools(mission, combined_tools)
if not notification_tools.tool_called:
logger.warning("NotificationReaderAgent did not call any tools!")
raise NotificationNoToolCalledError(
"NotificationReaderAgent failed to call a routing tool during execution."
)
return response_text