New archi: domain driven development

Working but need to check out code
This commit is contained in:
2025-12-01 07:10:03 +01:00
parent 2b815502f6
commit 2c8cdd3ab1
73 changed files with 4084 additions and 853 deletions
+21 -3
View File
@@ -3,9 +3,10 @@ from typing import Any, Dict, List
import json
from .llm import DeepSeekClient
from .memory import Memory
from infrastructure.persistence.memory import Memory
from .registry import make_tools, Tool
from .prompts import PromptBuilder
from .config import settings
class Agent:
def __init__(self, llm: DeepSeekClient, memory: Memory, max_tool_iterations: int = 5):
@@ -69,18 +70,35 @@ class Agent:
# Build system prompt using PromptBuilder
system_prompt = self.prompt_builder.build_system_prompt(self.memory.data)
# Initialize conversation with user input
# Initialize conversation with system prompt
messages: List[Dict[str, Any]] = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_input},
]
# Add conversation history from memory (last N messages for context)
# Only add user/assistant messages, NOT system messages
history = self.memory.get("history", [])
max_history = settings.max_history_messages
if history and max_history > 0:
# Filter to keep only user and assistant messages
filtered_history = [
msg for msg in history
if msg.get("role") in ("user", "assistant")
]
recent_history = filtered_history[-max_history:]
messages.extend(recent_history)
print(f"Added {len(recent_history)} messages from history (filtered)")
# Add current user input
messages.append({"role": "user", "content": user_input})
# Tool execution loop
iteration = 0
while iteration < self.max_tool_iterations:
print(f"\n--- Iteration {iteration + 1} ---")
# Get LLM response
print(messages)
llm_response = self.llm.complete(messages)
print("LLM response:", llm_response)