Skip to content

JacobHNU/AgenticSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AgenticSystem

Production-grade intelligent agent framework combining 6-layer context engineering, MCP tool orchestration, and Workflow Lifecycle Mode agent loop.

็‰ˆๆœฌ: 2.0.0

Architecture (V2.0)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        FastAPI Gateway                           โ”‚
โ”‚                  REST + WebSocket + Admin API                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Agent Loop (Workflow Lifecycle)                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  _resolve_skill() โ†’ SkillMatcher (no LLM)               โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚        โ†“                  โ†“                  โ†“                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”‚
โ”‚  โ”‚ Fast Path โ”‚    โ”‚  Build Path  โ”‚    โ”‚  ReAct Path  โ”‚          โ”‚
โ”‚  โ”‚ 0 LLM     โ”‚    โ”‚ 1-2 LLM      โ”‚    โ”‚ 2+ LLM/่ฝฎ    โ”‚          โ”‚
โ”‚  โ”‚ ็›ดๆŽฅๆ‰ง่กŒ   โ”‚    โ”‚ ๆž„ๅปบ+ๆ‰ง่กŒ+ไฟๅญ˜ โ”‚    โ”‚ Thinkโ†’Reflect โ”‚          โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”‚
โ”‚        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚
โ”‚                          โ†“                                       โ”‚
โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                          โ”‚
โ”‚              โ”‚     Skill Engine       โ”‚                          โ”‚
โ”‚              โ”‚  Match โ†’ Execute       โ”‚                          โ”‚
โ”‚              โ”‚  Promote โ†’ Persist     โ”‚                          โ”‚
โ”‚              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     Workflow Engine                               โ”‚
โ”‚  4 step types ยท Parallel execution ยท Conditional branching        โ”‚
โ”‚  Disk persistence (save/load YAML) ยท Checkpoint & resume         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Context Builder (L1-L6)                          โ”‚
โ”‚  L1 Base โ†’ L2 Business โ†’ L3 Dynamic โ†’ L4 History โ†’ L5 Tools     โ”‚
โ”‚  Smart trimming ยท Sensitive masking ยท Token management            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     MCP Client Layer                              โ”‚
โ”‚  Connection pool ยท Circuit breaker ยท Retry ยท Auth                 โ”‚
โ”‚  Tool discovery ยท Health monitoring                               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Features

  • Workflow Lifecycle Mode (V2.0) - Three-path execution model: Fast Path (0 LLM calls), Build Path (auto-construct workflow from description), ReAct Path (full Thinkโ†’Actโ†’Observeโ†’Reflect cycle). Automatic skill promotion from flexible to fixed.
  • 6-Layer Context Engineering - Structured context assembly with priority-based token trimming and configurable merge strategies (replace/append/union)
  • Skill Engine - Two-level matching (keyword 40% + embedding 60%), activation rules, version binding, hot reload, degradation with recursive fallback
  • Workflow Engine - 4 step types (MCP tool, LLM reasoning, sub-workflow, skill call), conditional branching, template variable substitution, checkpoint/resume, disk persistence
  • Agent Loop (ReAct) - Think โ†’ Act โ†’ Observe โ†’ Reflect cycle with LLM-driven planning, memory management, and scratch pad
  • MCP Client - Connection pooling, exponential backoff retry, circuit breaker (CLOSEDโ†’OPENโ†’HALF_OPEN), endpoint discovery, auth management
  • Sensitive Data Masking - Built-in patterns for phone, ID card, email, bank card + custom YAML rules
  • Hot Reload - File watcher (watchdog) + API trigger for skills and workflows with atomic replace
  • Observability - Structured JSON logging with trace_id propagation, Prometheus metrics (agent, skill, workflow, MCP dimensions)
  • Deployment - Docker Compose with MySQL 8.0 + Redis 7 + health checks

Performance (V2.0)

ๅœบๆ™ฏ V1.0 (ReAct) V2.0 (Fast Path) ๆๅ‡
ๅ›บๅฎš workflow ๆ‰ง่กŒ ~4.5s (2 LLM calls) ~250ms (0 LLM calls) ~18x
้ฆ–ๆฌกๆž„ๅปบ workflow ~4.5s (้œ€ไบบๅทฅ้ข„ๅฎšไน‰) ~4s (่‡ชๅŠจๆž„ๅปบ) ่‡ชๅŠจๅŒ–
ๅทฒๆž„ๅปบ workflow ๅ†ๆฌกๆ‰ง่กŒ ~4.5s ~250ms ~18x
ๆ— ๅŒน้…ไปปๅŠก ~4.5s ~4.5s (ไธๅ˜) โ€”

Execution Mode Comparison

็ปดๅบฆ Fast Path Build Path ReAct Path
่งฆๅ‘ๆกไปถ fixed skill + workflow ๅญ˜ๅœจ flexible skill + ้ฆ–ๆฌก่ฐƒ็”จ ๆ—  skill ๅŒน้…
LLM ่ฐƒ็”จ๏ผˆ่ทฏ็”ฑ๏ผ‰ 0 ๆฌก 0 ๆฌก 2 ๆฌก/่ฝฎ
LLM ่ฐƒ็”จ๏ผˆworkflow ๅ†…๏ผ‰ ไป… llm_reasoning ๆญฅ้ชค 1 ๆฌก๏ผˆๆž„ๅปบ๏ผ‰+ llm_reasoning ๆญฅ้ชค 2 ๆฌก/่ฝฎ + llm_reasoning ๆญฅ้ชค
Post-eval๏ผˆๅฏ้€‰๏ผ‰ 1 ๆฌก 1 ๆฌก ๆ— ๏ผˆๅ†…ๅซๅœจ Reflect ไธญ๏ผ‰
้ข„ๆœŸๅปถ่ฟŸ ~250ms ~4s๏ผˆ้ฆ–ๆฌก๏ผ‰ ~4.5s+/่ฝฎ

Skill Lifecycle

้˜ถๆฎต 1: ๅฎšไน‰๏ผˆFlexible Skill๏ผ‰
  type: flexible, process_description: "ไธšๅŠกๆต็จ‹ๆ่ฟฐ", workflows.main: ""
        โ”‚ ้ฆ–ๆฌก่ฐƒ็”จ
        โ–ผ
้˜ถๆฎต 2: ๆž„ๅปบ๏ผˆBuild Path๏ผ‰
  DynamicWorkflowBuilder.build_workflow โ†’ ็”Ÿๆˆ WorkflowDefinition โ†’ ๆ‰ง่กŒ โ†’ ่ฏ„ไผฐ
        โ”‚ ๆˆๅŠŸๅŽ
        โ–ผ
้˜ถๆฎต 3: ๅ›บๅŒ–๏ผˆPromote + Persist๏ผ‰
  type: flexible โ†’ fixed, workflows.main: "skill_dynamic", ็‰ˆๆœฌๅท +1, ๆŒไน…ๅŒ–ๅˆฐ็ฃ็›˜
        โ”‚ ๅŽ็ปญ่ฐƒ็”จ
        โ–ผ
้˜ถๆฎต 4: ๅฟซ้€Ÿๆ‰ง่กŒ๏ผˆFast Path๏ผ‰
  ่ทณ่ฟ‡ Think/Reflect, ็›ดๆŽฅๆ‰ง่กŒ Workflow, 0 LLM ่ฐƒ็”จ๏ผˆ่ทฏ็”ฑๅฑ‚๏ผ‰

Quick Start

Local Development

# Install dependencies
pip install -r requirements.txt

# Run tests
python -m pytest tests/ -v

# Start server
uvicorn app.main:app --reload --port 8000

Docker Deployment

cd docker
docker-compose up -d

Services:

Configuration

All config in config/settings.yaml with ${ENV_VAR} and ${ENV_VAR:default} syntax:

app:
  name: agent-core
  port: 8000
  admin_api_key: "${ADMIN_API_KEY}"

agent:
  max_iterations: 10
  checkpoint_interval: 3

mcp:
  discovery_url: "${MCP_DISCOVERY_URL:http://mcp-discovery:8080}"
  circuit_breaker:
    failure_threshold: 5
    recovery_timeout: 60

context:
  token_limit: 4000
  sensitive_fields: [phone, id_card, email, bank_card]

# V2.0: Workflow Lifecycle
workflow_lifecycle:
  enable_post_evaluation: false
  fast_path_confidence_threshold: 0.6
  auto_persist_workflows: true

Agent Loop Runtime Config

config.enable_workflow_lifecycle = True        # ๆ€ปๅผ€ๅ…ณ๏ผŒ้ป˜่ฎค True
config.fast_path_confidence_threshold = 0.6    # ็ฝฎไฟกๅบฆ้˜ˆๅ€ผ๏ผŒ้ป˜่ฎค 0.6
config.enable_post_evaluation = False          # Fast Path ้ป˜่ฎคๅ…ณ้—ญ๏ผŒBuild Path ้ป˜่ฎคๅผ€ๅฏ
config.max_iterations = 10                     # ReAct Path ๆœ€ๅคง่ฟญไปฃๆฌกๆ•ฐ
config.checkpoint_interval = 3                 # ReAct Path checkpoint ้—ด้š”

API Endpoints

Method Path Description
GET /health Health check
GET /health/detailed Component health (MySQL, Redis, MCP, LLM)
POST /api/v1/agents/{id}/tasks Create agent task
GET /api/v1/agents/{id}/tasks/{task_id} Get task status
GET /api/v1/agents/{id}/state Get agent state
WS /ws/{agent_id}/stream WebSocket event stream
POST /api/v1/admin/reload/skills Reload skills (admin)
POST /api/v1/admin/reload/workflows Reload workflows (admin)
POST /api/v1/admin/reload/all Reload all (admin)

TaskResult (V2.0)

execution_mode ๅญ—ๆฎตๆ ‡่ฏ†ๆ‰ง่กŒ่ทฏๅพ„๏ผš

{
  "status": "completed",
  "data": {"result": "verified"},
  "execution_report": {
    "metrics": {"tool_calls": 2, "llm_calls": 0, "total_duration_ms": 180}
  },
  "total_iterations": 1,
  "execution_mode": "fast_path"
}

execution_mode ๅ–ๅ€ผ๏ผš"fast_path" / "build_path" / "react"

Project Structure

agent-core/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ agent/           # Agent Loop (Workflow Lifecycle)
โ”‚   โ”‚   โ”œโ”€โ”€ loop.py      # Three-path routing: Fast/Build/ReAct
โ”‚   โ”‚   โ”œโ”€โ”€ models.py    # ExecutionMode, Thought, TaskResult
โ”‚   โ”‚   โ””โ”€โ”€ state.py     # Redis hot + MySQL cold state store
โ”‚   โ”œโ”€โ”€ api/             # FastAPI routers
โ”‚   โ”‚   โ”œโ”€โ”€ health.py    # Health endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ agent.py     # Agent task endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ admin.py     # Admin reload endpoints
โ”‚   โ”‚   โ””โ”€โ”€ ws.py        # WebSocket stream
โ”‚   โ”œโ”€โ”€ context/         # 6-Layer Context Engineering
โ”‚   โ”‚   โ”œโ”€โ”€ builder.py   # Context assembly orchestrator
โ”‚   โ”‚   โ”œโ”€โ”€ loaders.py   # L1-L6 layer loaders
โ”‚   โ”‚   โ”œโ”€โ”€ merger.py    # Merge strategies (replace/append/union)
โ”‚   โ”‚   โ”œโ”€โ”€ trimmer.py   # Smart history + token trimming
โ”‚   โ”‚   โ””โ”€โ”€ masker.py    # Sensitive data masking
โ”‚   โ”œโ”€โ”€ core/            # Shared infrastructure
โ”‚   โ”‚   โ”œโ”€โ”€ cache.py     # Redis client
โ”‚   โ”‚   โ”œโ”€โ”€ config.py    # YAML config loader
โ”‚   โ”‚   โ”œโ”€โ”€ database.py  # MySQL connection pool
โ”‚   โ”‚   โ”œโ”€โ”€ exceptions.py # Exception hierarchy
โ”‚   โ”‚   โ””โ”€โ”€ trace.py     # TraceContext (ContextVar)
โ”‚   โ”œโ”€โ”€ mcp/             # MCP Client Layer
โ”‚   โ”‚   โ”œโ”€โ”€ client.py    # Unified MCP client
โ”‚   โ”‚   โ”œโ”€โ”€ circuit_breaker.py # CLOSEDโ†’OPENโ†’HALF_OPEN
โ”‚   โ”‚   โ”œโ”€โ”€ retry.py     # Exponential backoff
โ”‚   โ”‚   โ”œโ”€โ”€ pool.py      # Connection pool
โ”‚   โ”‚   โ”œโ”€โ”€ auth.py      # Auth manager
โ”‚   โ”‚   โ””โ”€โ”€ discovery.py # Tool discovery
โ”‚   โ”œโ”€โ”€ monitoring/      # Observability
โ”‚   โ”‚   โ”œโ”€โ”€ logger.py    # Structured JSON logging
โ”‚   โ”‚   โ””โ”€โ”€ metrics.py   # Prometheus metrics
โ”‚   โ”œโ”€โ”€ reload/          # Hot Reload
โ”‚   โ”‚   โ”œโ”€โ”€ manager.py   # Reload orchestrator
โ”‚   โ”‚   โ””โ”€โ”€ watcher.py   # File system watcher
โ”‚   โ”œโ”€โ”€ skill/           # Skill Engine
โ”‚   โ”‚   โ”œโ”€โ”€ engine.py    # Main entry + persist_workflow()
โ”‚   โ”‚   โ”œโ”€โ”€ matcher.py   # Two-level matching
โ”‚   โ”‚   โ”œโ”€โ”€ executor.py  # Execution + degradation
โ”‚   โ”‚   โ”œโ”€โ”€ registry.py  # Version management + promote
โ”‚   โ”‚   โ”œโ”€โ”€ loader.py    # YAML loader
โ”‚   โ”‚   โ””โ”€โ”€ validator.py # Flexible/fixed validation
โ”‚   โ”œโ”€โ”€ workflow/         # Workflow Engine
โ”‚   โ”‚   โ”œโ”€โ”€ engine.py    # Step executor + disk persistence
โ”‚   โ”‚   โ”œโ”€โ”€ context.py   # Workflow context
โ”‚   โ”‚   โ””โ”€โ”€ models.py    # Step/Workflow models
โ”‚   โ””โ”€โ”€ main.py          # FastAPI app factory
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ settings.yaml    # Main config
โ”‚   โ””โ”€โ”€ masking_rules.yaml # Custom masking rules
โ”œโ”€โ”€ docker/
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ””โ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ AgenticSystem-V2.0.md
โ”‚   โ””โ”€โ”€ workflow-lifecycle-plan.md
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ init.sql         # Database schema
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ unit/            # 102 unit tests
โ”‚   โ””โ”€โ”€ integration/     # Integration tests
โ””โ”€โ”€ requirements.txt

Testing

# Run all tests
python -m pytest tests/ -v

# Run with coverage
python -m pytest tests/ --cov=app --cov-report=term-missing

# Run specific module
python -m pytest tests/unit/test_agent_loop.py -v

# Run integration tests only
python -m pytest tests/integration/ -v

Test Coverage (V2.0)

ๆจกๅ— ๆต‹่ฏ•ๆ•ฐ ็Šถๆ€
test_agent_loop.py 12 (1 ๅŽŸๆœ‰ + 11 ๆ–ฐๅขž) โœ… ๅ…จ้ƒจ้€š่ฟ‡
test_skill_validator.py 6 (ๆ–ฐๅปบ) โœ… ๅ…จ้ƒจ้€š่ฟ‡
test_skill_executor.py 2 (ไฟฎๅค mock) โœ… ๅ…จ้ƒจ้€š่ฟ‡
test_skill_engine.py 4 โœ… ๅ…จ้ƒจ้€š่ฟ‡
test_workflow_engine.py 3 โœ… ๅ…จ้ƒจ้€š่ฟ‡
ๅ…ถไป–ๆจกๅ— 75 โœ… ๅ…จ้ƒจ้€š่ฟ‡
ๆ€ป่ฎก 102 โœ… 102 passed, 0 failed

Key Design Decisions

  • Three-path execution model - Fast Path (0 LLM, direct workflow execution), Build Path (auto-construct from description), ReAct Path (full reasoning loop). Dynamically selected based on skill type and confidence.
  • Skill lifecycle: flexible โ†’ fixed - Skills start as flexible (description-only), auto-build workflow on first call, then promote to fixed for Fast Path reuse. Survives restarts via disk persistence.
  • Skill as MCP upper-layer abstraction - Skills encapsulate workflow + context + activation rules, providing richer semantics than raw MCP tools
  • Agent Loop as top-level controller - ReAct pattern drives all task execution; Skills and Workflows are invoked through it
  • Dual storage - Redis for hot state (fast read/write), MySQL for cold persistence (checkpoint every 5 versions)
  • Circuit breaker - Prevents cascading failures from MCP tool timeouts; supports automatic recovery
  • Hot reload with version binding - Running agents bind to the skill version at execution start; new executions use updated versions

Backward Compatibility

  • ็Žฐๆœ‰ Fixed Skill ๆ— ้œ€ๆ”นๅŠจ๏ผštype: "fixed" + workflows.main ๅทฒๅญ˜ๅœจ็š„ Skill ่‡ชๅŠจ่ตฐ Fast Path
  • ReAct ่กŒไธบไธๅ˜๏ผš_think()ใ€_act()ใ€_observe()ใ€_reflect() ๆ–นๆณ•ๅฎŒๅ…จไฟ็•™
  • TaskResult ้ป˜่ฎคๅ€ผ๏ผšexecution_mode ้ป˜่ฎคไธบ "react"๏ผŒไธๅฝฑๅ“็Žฐๆœ‰ๆถˆ่ดน่€…
  • ้…็ฝฎๅฏ้€‰๏ผšworkflow_lifecycle ้…็ฝฎๆฎตไธ่ฎพ็ฝฎๆ—ถไฝฟ็”จ้ป˜่ฎคๅ€ผ
  • ๆ— ๆ–ฐๅขžๅค–้ƒจไพ่ต–๏ผšๆ‰€ๆœ‰ๆ”นๅŠจๅŸบไบŽๅทฒๆœ‰็š„ PyYAMLใ€Pydanticใ€ๆ ‡ๅ‡†ๅบ“

ๅฆ‚้œ€็ฆ็”จ Workflow Lifecycle Mode๏ผŒๅ›ž้€€ๅˆฐ V1.0 ็บฏ ReAct ๆจกๅผ๏ผš

workflow_lifecycle:
  enable_post_evaluation: false

ๆˆ–ๅœจ AgentLoop config ไธญ่ฎพ็ฝฎ enable_workflow_lifecycle = Falseใ€‚

License

MIT

About

Agent-Skills-Workflows Archtecture

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors