Files
langcode_agent/IMPLEMENTATION_PLAN.md
T
opencode 56f2819a92 feat: Aggiunge miglioramenti per memoria e pianificazione con integrazione MCP
- Aggiunto sistema SimplePersistentMemory per fatti, preferenze e cronologia conversazioni
- Aggiunto EnhancedPlanner con dipendenze task, priorità e tracciamento progresso
- Integrati strumenti di miglioramento nell'agente (remember, recall, preference, planning)
- Aggiunti comandi CLI /memory e /plan per accesso diretto da terminale
- Aggiunto client MCP per connessione a server Model Context Protocol
- Aggiornato README con documentazione completa per tutte le nuove funzionalità
- Corretto parsing comando creazione piano per gestire nomi multi-parola

Nuovi comandi:
- /memory remember <testo> - Ricorda un fatto
- /memory recall <query> - Cerca nella memoria
- /memory preference set/get - Gestisci preferenze
- /memory stats - Statistiche memoria
- /plan create <nome> <task1;task2;...> - Crea un piano
- /plan list - Elenca tutti i piani
- /plan progress <plan_id> - Mostra progresso piano
- /plan start <task_id> - Inizia un task
- /plan complete <task_id> - Completa un task
2026-03-23 08:57:21 +01:00

6.4 KiB

LangCode Agent Enhancement Implementation Plan

Based on LangChain Deep Agents Architecture Analysis

Overview

This plan outlines the integration of enhancements inspired by LangChain's Deep Agents architecture into the LangCode Agent. The enhancements focus on:

  1. Advanced Memory Systems - Persistent, semantic, and summary-based memory
  2. Enhanced Planning & Reasoning - Sophisticated task planning and execution tracking
  3. Production Observability - Monitoring, tracing, and debugging capabilities
  4. Agent Hierarchies - Specialist agents and routing capabilities

Phase 1: Foundation Enhancements (Immediate Integration)

1.1 Simple Persistent Memory System

File: enhancements/simple_memory.py Status: Implemented and tested Integration Points:

  • Import in main.py: from enhancements.simple_memory import simple_memory, create_simple_memory_tools
  • Add to get_custom_tools(): Extend with memory tools
  • Update system prompt to mention memory capabilities
  • Add CLI commands: /memory remember, /memory recall, /memory preference, /memory stats

1.2 Enhanced Planning System

File: enhancements/planning_enhancement.py Status: Implemented and tested Integration Points:

  • Import in main.py: from enhancements.planning_enhancement import enhanced_planner
  • Add to get_custom_tools(): Extend with planning tools
  • Update system prompt to mention planning capabilities
  • Enhance existing /todo commands or add /plan subcommands

Phase 2: Advanced Features (Next Iteration)

2.1 Advanced Memory with Vector Storage

File: enhancements/memory_enhancement.py Dependencies:

  • langchain-community for OllamaEmbeddings and FAISS
  • sentence-transformers for embeddings Integration Points:
  • Similar to simple memory but with semantic search capabilities
  • Add background processing for conversation summarization
  • Implement memory consolidation during idle periods

2.2 Agent Hierarchies and Routing

New File: enhancements/agent_hierarchy.py Features:

  • Specialist agents for different domains (coding, research, system admin)
  • Intelligent routing based on task analysis
  • Agent-to-agent communication patterns
  • Load balancing and specialization

2.3 Production Observability

New File: enhancements/observability.py Features:

  • LangChain-style callbacks for tracing
  • Tool usage monitoring and metrics
  • Performance profiling
  • Error tracking and alerting
  • Integration with LangSmith or custom monitoring

Phase 3: Deep Agents Alignment (Future Work)

3.1 Context Management Enhancements

  • Implement automatic summarization at 85% context usage
  • Add file-based storage for large tool outputs
  • Implement pointer-based context management
  • Add context compression techniques

3.2 Subagent Spawning Improvements

  • Enhance the task tool with better isolation
  • Add per-subagent model configuration
  • Implement subagent pooling for efficiency
  • Add inter-subagent communication mechanisms

3.3 Advanced Planning Features

  • Implement plan-and-execute agent pattern
  • Add self-reflection and critique mechanisms
  • Enable dynamic replanning based on execution results
  • Add contingency planning and error recovery

Integration Strategy

Step-by-Step Integration:

  1. Start with Simple Enhancements (Phase 1)

    • Integrate simple_memory.py and planning_enhancement.py
    • Test thoroughly with existing functionality
    • Gather user feedback
  2. Update Documentation

    • Update docs/plans/ with enhancement designs
    • Add usage examples to README
    • Create tutorial examples
  3. Gradual Rollout of Advanced Features (Phase 2)

    • Add one enhancement at a time
    • Maintain backward compatibility
    • Provide migration paths
  4. Performance Optimization

    • Profile and optimize memory usage
    • Implement caching where appropriate
    • Add configuration options to enable/disable features

CLI Integration Examples

Memory Commands:

/memory remember "LangCode uses Ollama for local models" --category architecture
/memory recall "Ollama"
/memory preference set model_provider ollama
/memory preference get model_provider
/memory stats

Planning Commands:

/plan create "Implement user authentication" --tasks "Design DB schema" "Create API endpoints" "Write frontend" "Add tests"
/plan start auth-plan
/plan list
/plan progress auth-plan
/task list
/task start task_0000
/task complete task_0000 "Authentication system implemented"

Configuration Options

Add to configuration system:

{
  "enhancements": {
    "memory": {
      "type": "simple|advanced",
      "persist_directory": "./.langcode/memory",
      "max_conversations": 100,
      "max_facts": 50
    },
    "planning": {
      "enabled": true,
      "auto_create_todos": true,
      "dependency_tracking": true
    },
    "observability": {
      "enabled": false,
      "trace_level": "info",
      "metrics_endpoint": "http://localhost:9090/metrics"
    }
  }
}

Backward Compatibility Strategy

All enhancements are designed to be:

  • Optional: Can be enabled/disabled via configuration
  • Additive: Don't modify existing core functionality
  • Testable: Include comprehensive test suites
  • Documented: Clear usage instructions and examples

Risk Mitigation

  1. Dependency Management:

    • Enhancements with heavy dependencies are isolated
    • Fallback to simpler implementations when deps missing
    • Clear error messages when features unavailable
  2. Performance Impact:

    • Lazy initialization of heavy components
    • Configurable feature flags
    • Performance monitoring built-in
  3. Data Safety:

    • Memory data stored locally by default
    • No automatic data transmission
    • User control over what gets remembered

Success Metrics

After implementation, measure:

  • User adoption of new features
  • Reduction in repeated context requests
  • Improvement in complex task completion rates
  • User satisfaction scores
  • System performance impact

Next Steps

  1. Review and approve this implementation plan
  2. Begin Phase 1 integration (simple memory and planning)
  3. Conduct internal testing
  4. Gather feedback from pilot users
  5. Iterate based on feedback
  6. Proceed to Phase 2 enhancements

This plan brings LangCode Agent closer to the production-grade architecture patterns revealed in LangChain's Deep Agents while maintaining the project's core strengths in configurability and modularity.