feat(ai): complete Phase 2/3 documentation and memory system improvements

Phase completion and enhancement updates:

## Documentation Added
- Phase 2 completion: Memory system implementation details
- Phase 3 completion: Research capabilities and tool integration
- Session documentation: Model testing, VRAM optimization analysis
- Test results: Comprehensive prompt testing (v1_verbose: 87/100)
- Tool logging implementation guide

## System Prompts
- Added prompts.py with 7 tested variants for A/B testing
- v1_verbose, v2_concise, v3_imperative, v4_minimal, etc.
- Comprehensive testing results for each variant
- Production-ready prompt selection guidance

## Memory System Enhancements
- Multi-tenancy support: Added user_id parameter throughout
- System message filtering: Don't store system messages in history
- Improved conversation turn tracking with user isolation
- Enhanced memory manager for better multi-user support

## AI Controller Improvements
- Better memory integration with user_id support
- Enhanced error handling for memory operations
- Improved token tracking for usage monitoring
- Skip system message storage (part of agent state)

## Portainer Client
- Comprehensive API client (148 lines)
- Stack management and service monitoring
- Container operations with full error handling
- Async support for all operations

## Architecture Documentation
- Updated agent flow diagrams for ADK architecture
- Enhanced core-api README with current setup
- Updated Docker compose stack configuration
- Complete testing and validation documentation
This commit is contained in:
2025-11-26 08:41:44 +01:00
parent e3b451b7b0
commit 0c2c838766
21 changed files with 3830 additions and 51 deletions
+22 -20
View File
@@ -15,29 +15,31 @@ This document shows the data flow through the agent system for various scenarios
│ (or any OpenAI client) │
└────────────────────────┬────────────────────────────────────────┘
│ POST /v1/chat/completions
{"use_agent": true/false}
┌─────────────────────────────────────────────────────────────────┐
│ Core API (FastAPI) │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ AI Controller (ai_controller.py) │ │
│ │ • Routes to agent or direct LLM based on use_agent │ │
│ │ • Routes all requests to unified agent │ │
│ │ • Converts OpenAI format ↔ agent format │ │
│ └─────────┬────────────────────────────────────────┬───────┘ │
│ │ use_agent=false │ │
│ │ use_agent=true │ │
└────────────┼───────────────────────────────────────────────────┘
┌────────────────┐ ┌──────────────────────┐
│ Direct to │ │ Unified Agent │
│ Ollama │ │ (orchestrator.py) │
│ (any model) │ │ • LangGraph ReAct │
└────────────────┘ │ • mistral:7b only
│ • Tool calling │
└──────────┬───────────┘
─────────────────────
│ │ │ │
│ │ │ │
└────────────┼─────────────────────────────────────────────────────┘
┌──────────────────────┐
│ Unified Agent │
│ (orchestrator.py) │
│ • LangGraph ReAct │
│ • mistral:7b
│ • Tool calling │
│ • Decides: tools │
│ or direct answer
─────────────────────
┌──────────▼───────────┐
│ Agent Tools │
│ (tools.py) │
│ • Infrastructure │
@@ -57,13 +59,13 @@ This document shows the data flow through the agent system for various scenarios
│ User │ "What is Docker?"
└────┬─────┘
│ POST /v1/chat/completions
use_agent: true
┌────────────────────────────────────────────┐
│ Core API - AI Controller │
│ │
│ 1. Parse request │
│ 2. Check use_agent flag → TRUE
│ 2. Routes to unified agent
│ 3. Extract message & history │
└────┬───────────────────────────────────────┘
@@ -142,7 +144,7 @@ This document shows the data flow through the agent system for various scenarios
┌──────────┐
│ User │ "What's the weather in SF?"
└────┬─────┘
use_agent: true
┌────────────────────────────────────────────┐
│ AI Controller │
@@ -594,7 +596,7 @@ Multi-Tool Flow:
| Scenario | Model Used | Reason |
|----------|-----------|--------|
| **Agent mode** (any query) | `mistral:7b` | Supports tool calling |
| **Direct chat** (use_agent=false) | User's choice | gemma:2b, gemma:7b, etc. |
| **Direct chat** () | User's choice | gemma:2b, gemma:7b, etc. |
| **Embeddings** | `nomic-embed-text` (via Ollama) | No local PyTorch needed |
### Why mistral:7b for Agent?