JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
docs: 优化上下文压缩与技能演进文档
xiaoxiawang09341030cf3d
diff --git "a/docs/assets/images/jiuwenswarm\345\211\215\347\253\257\346\227\245\345\277\227.png" "b/docs/assets/images/jiuwenswarm\345\211\215\347\253\257\346\227\245\345\277\227.png"new file mode 100644index 0000000000..5697897187Binary files /dev/null and "b/docs/assets/images/jiuwenswarm\345\211\215\347\253\257\346\227\245\345\277\227.png" differdiff --git "a/docs/assets/images/skill\346\274\224\350\277\233_\346\211\213\345\212\250\350\247\246\345\217\221.png" "b/docs/assets/images/skill\346\274\224\350\277\233_\346\211\213\345\212\250\350\247\246\345\217\221.png"index cb628b123f..4f9fa273ff 100644Binary files "a/docs/assets/images/skill\346\274\224\350\277\233_\346\211\213\345\212\250\350\247\246\345\217\221.png" and "b/docs/assets/images/skill\346\274\224\350\277\233_\346\211\213\345\212\250\350\247\246\345\217\221.png" differdiff --git "a/docs/assets/images/skill\346\274\224\350\277\233_\350\207\252\345\212\250\346\243\200\346\265\213\345\274\200\345\205\263.png" "b/docs/assets/images/skill\346\274\224\350\277\233_\350\207\252\345\212\250\346\243\200\346\265\213\345\274\200\345\205\263.png"index 1930b9b91f..bfa66632c5 100644Binary files "a/docs/assets/images/skill\346\274\224\350\277\233_\350\207\252\345\212\250\346\243\200\346\265\213\345\274\200\345\205\263.png" and "b/docs/assets/images/skill\346\274\224\350\277\233_\350\207\252\345\212\250\346\243\200\346\265\213\345\274\200\345\205\263.png" differdiff --git "a/docs/assets/images/skill\346\274\224\350\277\233_\350\207\252\345\212\250\350\247\246\345\217\221.png" "b/docs/assets/images/skill\346\274\224\350\277\233_\350\207\252\345\212\250\350\247\246\345\217\221.png"index 689bcc17f5..d3fd7c33bb 100644Binary files "a/docs/assets/images/skill\346\274\224\350\277\233_\350\207\252\345\212\250\350\247\246\345\217\221.png" and "b/docs/assets/images/skill\346\274\224\350\277\233_\350\207\252\345\212\250\350\247\246\345\217\221.png" differdiff --git "a/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251_\345\274\200\345\220\257.png" "b/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251_\345\274\200\345\220\257.png"new file mode 100644index 0000000000..745a949922Binary files /dev/null and "b/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251_\345\274\200\345\220\257.png" differdiff --git "a/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251_\346\234\252\345\274\200\345\220\257.png" "b/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251_\346\234\252\345\274\200\345\220\257.png"new file mode 100644index 0000000000..a2a20269d8Binary files /dev/null and "b/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251_\346\234\252\345\274\200\345\220\257.png" differdiff --git "a/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251\350\256\276\347\275\256.png" "b/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251\350\256\276\347\275\256.png"new file mode 100644index 0000000000..11b4cddf6cBinary files /dev/null and "b/docs/assets/images/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251\350\256\276\347\275\256.png" differdiff --git "a/docs/assets/images/\344\270\212\344\270\213\346\226\207\347\212\266\346\200\201.png" "b/docs/assets/images/\344\270\212\344\270\213\346\226\207\347\212\266\346\200\201.png"new file mode 100644index 0000000000..b7d4d74e22Binary files /dev/null and "b/docs/assets/images/\344\270\212\344\270\213\346\226\207\347\212\266\346\200\201.png" differdiff --git "a/docs/assets/images/\346\227\245\345\277\227\350\260\203\350\257\225\346\250\241\345\274\217.png" "b/docs/assets/images/\346\227\245\345\277\227\350\260\203\350\257\225\346\250\241\345\274\217.png"new file mode 100644index 0000000000..efd90928efBinary files /dev/null and "b/docs/assets/images/\346\227\245\345\277\227\350\260\203\350\257\225\346\250\241\345\274\217.png" differdiff --git a/docs/en/ContextCompression.md b/docs/en/ContextCompression.mdindex 0b4d4777e2..0977fbe38e 100644--- a/docs/en/ContextCompression.md+++ b/docs/en/ContextCompression.md@@ -1,17 +1,317 @@-# Context compression & offload+# Context Compression: Making AI Long Conversations More Efficient-Long chats hit **context window limits**: the model slows, forgets early details, or makes mistakes on dense material. JiuwenSwarm uses openJiuwen’s **context offload** to **archive bulky content** when counts or token thresholds are exceeded—like clearing a cluttered desk: large or secondary material is summarized and indexed with `[[OFFLOAD:...]]` markers so the active window stays focused.+## 1. Concept Explanation-## Configuration (high level)+### 1.1 The Concept of Context-| Parameter | Role |-| :--- | :--- |-| **Trigger** | When message count exceeds `messages_threshold` (e.g. 3) **or** total tokens exceed `tokens_threshold` (default 20000), offload runs. |-| **Large messages** | `large_message_threshold` (e.g. 1000 tokens) marks messages to prioritize for offload. |-| **What to offload** | `offload_message_type` can target specific roles (e.g. compress long tool output, keep user/assistant dialogue). |-| **How** | Sampling or summarization; indexed with `[[OFFLOAD:...]]` for later retrieval. |-| **Protect recent** | `messages_to_keep` or `keep_last_round` keeps the latest user–assistant turn intact. |+In AI dialogue systems, **context** refers to all historical information generated during a conversation, including user questions, AI answers, tool call results, etc. This information together forms the basis for the AI to understand the current dialogue state and provide accurate responses.-[Demo video](../assets/videos/compression.mp4)+### 1.2 Context Window Limitations-Together, this keeps important facts (billing, contracts) while trimming noise so long sessions stay coherent.+Although context is crucial for AI to understand conversations, all AI models have **context window limitations** - the maximum amount of information (usually measured in tokens) that a model can process in a single conversation. When conversations exceed this limit, the AI will exhibit the following problems:++- Significantly slower response times+- Forgetting early key information+- Decreased answer accuracy+- Excessive system resource consumption++### 1.3 The Concept of Context Compression++**Context compression** is an intelligent optimization technology that analyzes, filters, and streamlines historical dialogue content to compress context information within the model's processable range while maintaining conversation coherence.++Its core idea can be analogized to reading a long novel - we don't need to remember every detail, only key plot points and character relationships, to understand the story's development.++### 1.4 Implementation Principles of Context Compression++JiuwenSwarm's context compression system uses the following core technologies:++1. **Intelligent Recognition**: The system automatically identifies key information and redundant content in conversations+ - Distinguishes important messages from secondary messages through semantic analysis+ - Identifies duplicate information and low-value content++2. **Selective Compression**: Adopts different processing strategies for different types of content+ - Preserves user questions and AI core answers+ - Summarizes lengthy tool return results+ - Merges duplicate information++3. **Index Marking**: Inserts special markers in compressed context+ - Uses `[[OFFLOAD:...]]` format index markers for offloaded large tool messages+ - Preserves retrieval capabilities for offloaded tool messages++4. **Dynamic Regulation**: Automatically adjusts compression strategies based on dialogue state+ - Triggers compression when message count or token count exceeds thresholds+ - Can be configured to keep the most recent messages uncompressed++## 2. Basic Usage++### 2.1 Enable Context Compression++Context compression is disabled by default. You can enable it in the following ways:++**Method 1: Enable via Configuration File**++Edit the `config.yaml` configuration file, find the `context_engine_config` section:++```yaml+ enabled: true # Set this to true to enable context compression+```++**Method 2: Enable via Frontend Interface**++In the JiuwenSwarm client, navigate to:++++- Click "Configuration" in the left menu bar+- Select "Other Configurations"+- Find "Context Compression"+- Toggle the switch to enable it++### 2.2 View Context Compression Status++After enabling context compression, you can check the compression status as follows:++**Method 1: Check Conversation Status Panel**++In the bottom right corner of the conversation interface, the system displays the real-time usage of the context window:++++The status panel includes:+- Current Token count used+- Maximum Token count supported by the model+- Current usage percentage++**Method 2: View via Slash Command**++Enter the following command in the conversation input box to view detailed context compression information:++```bash+/context+```+++## 3. Case Practice++### 3.1 Without Context Compression++**Scenario**: User has a long data analysis conversation with AI++**Process**:+1. User asks: "Help me analyze this month's sales data"+2. AI requests data+3. User uploads a 5000-token sales data table+4. AI analyzes and provides preliminary conclusions+5. User continues: "Help me compare with last month's data"+6. AI requests last month's data+7. User uploads a 4500-token sales data table for last month+8. AI analyzes and provides comparison results+9. User continues: "What about next year's sales forecast?"++**Results**:+- Total context tokens exceed 10,000+- AI response time significantly slows (from 2 seconds to 10 seconds)+- AI begins to forget some key indicators mentioned earlier+- System resource utilization increases significantly++### 3.2 With Context Compression++**Same Scenario**: User has a long data analysis conversation with AI++**Process**:+1. User asks: "Help me analyze this month's sales data"+2. AI requests data+3. User uploads a 5000-token sales data table+4. AI analyzes and provides preliminary conclusions+5. User continues: "Help me compare with last month's data"+6. AI requests last month's data+7. User uploads a 4500-token sales data table for last month+8. System detects token count approaching threshold and automatically triggers compression+9. System summarizes and compresses sales data tables, retaining only key statistical information+10. AI analyzes and provides comparison results+11. User continues: "What about next year's sales forecast?"++**Results**:+- Total context tokens remain around 3,000+- AI response time is stable (2-3 seconds)+- AI can completely remember all key indicators and analysis results+- System resource utilization remains at a reasonable level++### 3.3 Travel Planning Example++**Scenario**: User asks AI to plan a 3-day trip to Beijing (single request)++**Conversation Process (Without Compression)**:++```+User: Help me plan a 3-day trip to Beijing next week+Assistant: Sure, I'll plan a detailed 3-day itinerary for you.+Tool: Querying weather and attraction information for Beijing...+Tool Response: Returns detailed weather data and attraction recommendations+Assistant: Based on your requirements, here's your travel plan:++[3-Day Beijing Tour Itinerary]++Day 1: Tiananmen Square → Forbidden City → Jingshan Park+- Morning: Watch the flag-raising at Tiananmen Square+- Noon: Explore the Forbidden City+- Afternoon: Overlook the Forbidden City from Jingshan Park++Day 2: Badaling Great Wall → Ming Tombs+- Morning: Badaling Great Wall+- Afternoon: Ming Tombs++Day 3: Summer Palace → Yuanmingyuan → Nanluoguxiang+- Morning: Summer Palace+- Noon: Yuanmingyuan+- Afternoon: Experience old Beijing culture at Nanluoguxiang++Food Recommendations: Peking Duck, Zhajiangmian, Hot Pot++Important Reminder: Please book Forbidden City tickets in advance+```++**Explanation**:+- The AI response contains rich travel information+- Status panel at bottom right shows: Context Window 41.3K/289.0K (20.6%)+- Token consumption mainly comes from: AI's detailed response + Tool call return data++**Results**:+- Total context tokens: 41.3K, occupying 20.6% of the model window+- Risk: If user continues asking for details or expanding the plan, context will continue growing+- Potential issue: May approach the model's context window limit as conversation progresses++++**Conversation Process (With Compression)**:++```+User: Help me plan a 3-day trip to Beijing next week+Assistant: Sure, I'll plan a detailed 3-day itinerary for you.+Tool: Querying weather and attraction information for Beijing...+Tool Response: Returns detailed weather data and attraction recommendations+Assistant: Based on your requirements, here's your travel plan:++[3-Day Beijing Tour Itinerary]++Day 1: Tiananmen Square → Forbidden City → Jingshan Park+...(System automatically compressed detailed itinerary content)++[[OFFLOAD: Travel plan details compressed, core information retained]]+```++**Explanation**:+- AI completed the full travel planning task+- Status panel at bottom right shows: Context Window 40.7K/289.0K (28.3%)++**Results**:+- Total context tokens remain at 40.7K, occupying 28.3% of the model window+- AI retains core information: Can handle subsequent requests+- System supports additional tasks: Such as creating skills+- Improved user experience: Enables continued multi-turn interactions and feature extensions++++### 3.4 Effect Analysis++Based on the actual data from the examples:++1. **Context Token Usage**:+ - Without compression: 41.3K tokens+ - With compression: 40.7K tokens+ - The difference is small, indicating that compression mainly optimizes information structure rather than simply reducing token count++2. **System Performance**:+ - Both scenarios successfully generated travel plans+ - Compressed scenario additionally supports skill creation and other extended features+ - Memory usage stable around 362MB++3. **Practical Value**:+ - Context compression optimizes information structure, enabling better handling of subsequent extension requests+ - Enhances system functionality while maintaining core information integrity++### 3.5 Comparison Summary++| Metric | Without Context Compression | With Context Compression |+|--------|------------------------------|---------------------------|+| Response Speed | Gradually slows (10+ seconds) | Stable (2-3 seconds) |+| Information Integrity | Gradually lost | Key information fully retained |+| System Resource Usage | High (> 2GB memory) | Low (< 1GB memory) |+| Conversation Coherence | Gradually decreases | Remains consistent |+| Supported Conversation Length | Limited (about 20-30 rounds) | Unlimited (supports hundreds of rounds) |++## 4. Feature Interpretation++### 4.1 Dynamic Triggering Mechanism++Context compression is not a fixed preprocessing step, but an intelligent optimization dynamically triggered based on dialogue state:++- **Based on Message Count**: Triggers when conversation rounds exceed `messages_threshold` (default 3)+- **Based on Token Count**: Triggers when accumulated tokens exceed `tokens_threshold` (default 20,000)+- **Configurable**: Users can adjust trigger thresholds as needed++### 4.2 Intelligent Recognition and Compression++The system uses advanced natural language processing technology to:++- **Distinguish Message Types**: Automatically identifies user messages, AI answers, and tool results+- **Identify Importance**: Judges message importance based on semantic analysis+- **Select Compression Methods**: Adopts different compression strategies for different content types+ - Summarizes lengthy tool return results+ - Merges duplicate information+ - Filters unimportant content++### 4.3 Key Information Protection++Context compression does not lose important information; the system:++- **Preserves Recent Messages**: Retains a specified number of latest messages through `messages_to_keep` parameter+- **Preserves Complete Rounds**: Enables `keep_last_round` to ensure the latest round of user-assistant dialogue is fully retained+- **Identifies Key Content**: Automatically identifies and retains key information through semantic analysis++### 4.4 Retrieval Capability Preservation++> **Note**: Normally compressed content cannot be recalled. Only offloaded large tool message content can be retrieved through `[[OFFLOAD:...]]` index markers.++- **Index Marking**: Uses `[[OFFLOAD:...]]` format index markers for offloaded large tool messages+- **Association Preservation**: Offloaded information remains associated with the original context+- **Recoverability**: Offloaded tool message information can be recovered through indices when needed++### 4.5 Performance Optimization++Context compression can significantly improve system performance:++- **Reduces Memory Usage**: Reduces context data volume by 50%-80%+- **Improves Response Speed**: Reduces model inference time and improves user experience+- **Supports Longer Conversations**: Breaks through model context window limitations and supports long conversations+- **Reduces Costs**: Reduces token consumption and lowers usage costs++## 5. Application Scenarios++Context compression technology is suitable for various scenarios requiring long conversations:++- **Data Analysis**: Processing large data tables and analysis results+- **Project Management**: Cross-day project follow-up and discussions+- **Code Development**: Long-time code writing and debugging+- **Document Creation**: Collaborative writing of long documents+- **Customer Support**: Long-time resolution of complex issues++## 6. Advanced Configuration++The following is a typical configuration example for context compression:++```yaml+context_engine:+ max_messages: 100 # Maximum number of messages+ max_tokens: 100000 # Maximum number of tokens+ compression:+ enabled: true # Enable context compression+ messages_threshold: 3 # Message count trigger threshold+ tokens_threshold: 20000 # Token count trigger threshold+ large_message_threshold: 1000 # Large message definition+ offload_message_type: ["tool"] # Only compress tool return results+ messages_to_keep: 5 # Keep the last 5 messages+ keep_last_round: true # Keep complete last round conversation+```++By configuring context compression parameters reasonably, users can obtain the best dialogue experience according to their usage scenarios and needs.\ No newline at end of filediff --git a/docs/en/Logs.md b/docs/en/Logs.mdnew file mode 100644index 0000000000..84b1eb3d07--- /dev/null+++ b/docs/en/Logs.md@@ -0,0 +1,241 @@+# Logging System++JiuwenSwarm provides a comprehensive logging system to record system operation status, debugging information, and audit logs, helping users monitor system operation, troubleshoot issues, and analyze system behavior.++## 1. Logging Basics++### 1.1 Storage Location++By default, JiuwenSwarm log files are stored in the following location:++```+~/.jiuwenswarm/agent/.logs/+```++### 1.2 Log File Classification++The logging system categorizes logs by component type and stores them in different files:++| Log File | Content |+|---------|---------|+| `gateway.log` | Gateway-related logs, including modules under `app`, `gateway`, `evolution`, `utils`, etc. |+| `channel.log` | Channel-related logs, including all modules under `channels` |+| `agent_server.log` | Agent server logs, including modules under `agents` and `.server` |+| `full.log` | Aggregation of all component logs |+| `desktop.log` | Desktop application logs |+| `permissions.log` | Permission-related logs |+| `ws-dev.log` | Web service development mode logs |++### 1.3 Log Content Types++The logging system has two main content types:++#### 1.3.1 General Logs++General logs are categorized by component and record system operation status, error messages, debugging information, etc.:+- Implemented using the standard Python logging module+- Stored in different files based on component types (see Section 1.2)++#### 1.3.2 Audit Logs++Audit logs record sandbox operation details in structured JSONL format, including:+- Command execution (`exec_command`)+- File transfer (`file_transfer`)+- Network requests (`network_request`)++Each audit log contains operation type, parameters, results, execution time, etc.++For sandbox operation audit logs, the storage location can be specified through configuration:+- Default: Not set (audit logs are not persisted)+- Can be specified via `--save-logs DIR` parameter or `JIUWENBOX_SAVE_LOGS_DIR` environment variable+- File name format: `{sandbox_id}-{YYYYMMDDTHHMMSS}.audit.log`++## 2. Viewing Logs++### 2.1 Frontend Log Viewing++++### 2.2 Real-time Log Viewing++Use the `tail` command to view logs in real-time:++```bash+# View full logs+tail -f ~/.jiuwenswarm/agent/.logs/full.log++# View specific component logs+tail -f ~/.jiuwenswarm/agent/.logs/gateway.log+```++### 2.3 Viewing Historical Logs++Use `cat` to view logs:++```bash+# View complete log file+cat ~/.jiuwenswarm/agent/.logs/full.log+```++### 2.4 Log Searching++Use the `grep` command to search log content:++```bash+# Search logs containing "error"+grep -i "error" ~/.jiuwenswarm/agent/.logs/full.log++# Search logs for a specific time range+grep "2026-05-19 15:" ~/.jiuwenswarm/agent/.logs/full.log+```++### 2.5 Viewing Audit Logs++```bash+# View audit logs+cat /var/log/jiuwenbox/9284a4bf-870-20260515T112345.audit.log++# View audit logs with jq formatting+jq '.' /var/log/jiuwenbox/9284a4bf-870-20260515T112345.audit.log+```++## 3. Log Rotation Strategy++The logging system adopts the following rotation strategy:++- **Size Limit**: Default maximum 20MB per log file (configurable via `max_bytes`)+- **Retention Count**: Default 20 log files retained (configurable via `backup_count`)+- **Automatic Rotation**: When a log file reaches the size limit, a new file is automatically created and old files are archived+- **Naming Format**: Archived files are named `{filename}.{index}`, e.g., `gateway.log.1`++## 4. Log System Architecture++### 4.1 Core Modules++- **Log Configuration**: `setup_logger` function in `jiuwenclaw/common/utils.py`+- **Audit Logs**: `jiuwenbox/src/jiuwenbox/server/audit_logger.py`+- **Default Log Implementation**: `openjiuwen/core/common/logging/default/default_impl.py`++### 4.2 Log Flow++1. Each module obtains a logger through `logging.getLogger(__name__)`+2. Automatically classified into different components based on logger name+3. Logs are output to both console and corresponding component log files+4. All logs are aggregated into `full.log`+5. Automatic rotation when log files reach size limit++## 5. Log Configuration++### 5.1 Configuration File++Log levels are mainly configured through the `logging` section in the `config.yaml` file:++```yaml+logging:+ level: INFO # Default log level+ console_level: INFO # Console log level+ gateway: INFO # Gateway component log level+ channel: INFO # Channel component log level+ agent_server: INFO # Agent server log level+ full: INFO # Full log level+ max_bytes: 20971520 # Log file size limit (20MB)+ backup_count: 20 # Number of log files to retain+```++### 5.2 Environment Variables++The console log level can be overridden through environment variables:++```bash+LOG_LEVEL=DEBUG jiuwenswarm-start+```++### 5.3 Command Line Parameters++When starting the service, log level can be specified via parameters:++```bash+jiuwenswarm-start --log-level DEBUG+```++## 6. Log Levels++JiuwenSwarm supports standard Python logging levels:++| Level | Description |+|------|------|+| DEBUG | Debug information, used for development and debugging |+| INFO | General information, recording normal system operation status |+| WARNING | Warning information, recording potential issues |+| ERROR | Error information, recording system errors |+| CRITICAL | Critical error information, recording system crashes and other serious issues |++## 7. Log Format++The log format includes timestamp, log level, module name, and log message:++```+2026-05-19 15:30:45.123 INFO jiuwenclaw.app: Service started successfully+```++### 7.1 Audit Log Format++Audit logs use structured JSON format:++```json+{+ "timestamp": "2026-05-19T15:30:45.123Z",+ "event_type": "exec_command",+ "sandbox_id": "9284a4bf-870",+ "command": "ls -la",+ "workdir": "/home/user",+ "ok": true,+ "exit_code": 0,+ "stdout": "total 40\ndrwxr-xr-x 5 user user 4096 May 19 15:30 .",+ "stderr": "",+ "duration_ms": 123+}+```++## 8. Common Issues and Troubleshooting++### 8.1 Large Log Files++**Problem**: Log files grow too quickly and occupy too much disk space++**Solution**:+- Lower log level to reduce log output+- Decrease `max_bytes` configuration to reduce individual log file size+- Decrease `backup_count` configuration to reduce the number of retained log files++### 8.2 No Log Output++**Problem**: Cannot find log files or log content is empty++**Solution**:+- Check if log directory permissions are correct+- Check if log level configuration is too high+- Check if the service is started normally++### 8.3 Log Garbled Characters++**Problem**: Log files contain garbled characters++**Solution**:+- Ensure system encoding is set correctly (UTF-8 recommended)+- Use text editors that support UTF-8 encoding to view logs++## 9. Best Practices++1. **Development Environment**: Use DEBUG level to obtain detailed debugging information+2. **Production Environment**: Use INFO or WARNING level to reduce log output+3. **Regular Cleaning**: Regularly clean expired log files to avoid occupying too much disk space+4. **Centralized Management**: Consider using log collection tools (such as ELK Stack) for centralized log management+5. **Sensitive Information**: Be careful with sensitive information that may be included in logs, such as API keys, passwords, etc.++## 10. Related Configuration Files++- Main configuration file: `~/.jiuwenswarm/config/config.yaml`+- Environment variable file: `~/.jiuwenswarm/config/.env`+- Log system implementation: `jiuwenclaw/common/utils.py`+- Audit log implementation: `jiuwenbox/src/jiuwenbox/server/audit_logger.py`\ No newline at end of filediff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.mdindex bf5770cccd..b626d63915 100644--- a/docs/en/SUMMARY.md+++ b/docs/en/SUMMARY.md@@ -27,7 +27,7 @@- [Memory](Memory.md)- [Auto Memory](AutoMemory.md)- [Task Memory](TaskMemory.md)- - [Context compression & offload](ContextCompression.md)+ - [Context Compression](ContextCompression.md)- [Coding Memory](CodingMemory.md)- [Skills](Skills.md)- [Symphony](symphony.md)@@ -41,6 +41,7 @@- [Packaging desktop executables](PackExeGuide.md)- [ACP Plugin Usage](ACP_Client_Config.md)- [Windows auto-update design](WindowsAutoUpdateDesign.md)+ - [Logging System](Logs.md)- [Development practices](development-practices/README.md)- [Daily report generator practice](development-practices/JiuwenSwarm-Daily-Report-Generator.md)- [Code review assistant practice](development-practices/JiuwenSwarm-Code-Review-Assistant.md)diff --git a/docs/en/SkillSelfEvolution.md b/docs/en/SkillSelfEvolution.mdindex 7878ec741f..07cf503a02 100644--- a/docs/en/SkillSelfEvolution.md+++ b/docs/en/SkillSelfEvolution.md@@ -1,307 +1,293 @@-# Skill self-evolution+# Skill Self-Evolution-Most agents **freeze** skills after deployment: tool errors become log lines; user corrections do not change behavior. JiuwenSwarm uses the **openJiuwen evolution stack** with **`SkillCallOperator`** to unify skill reads/writes and evolution, plus **signal detection** that turns failures and user corrections into updates stored in **`evolutions.json`** and merged back into **`SKILL.md`** when appropriate.+## 1. Concept Explanation-## Core components+### 1.1 Introduction to Skill Self-Evolution-### SkillCallOperator+Skill self-evolution is a core feature of JiuwenSwarm based on the openJiuwen evolution framework. It breaks the limitation of fixed capabilities in traditional Agent systems. In traditional systems, once capability definitions are written, they rarely change—tool call errors only generate log entries, and user feedback about misunderstandings doesn't alter future behavior. The capability ceiling is fixed from the day of deployment.-Central entry for skills: read `SKILL.md`, run skill logic, load accumulated evolution notes. When improvements are detected, they go to `evolutions.json` and are merged on the next skill call so the agent always sees the latest guidance.+JiuwenSwarm's skill self-evolution mechanism uses a built-in evolution signal detection system to continuously monitor execution processes and dialogue content, automatically converting real-world usage issues into improvement inputs for skills. This transforms skills from one-time static documents into living documents that continuously iterate with real usage.-### SkillOptimizer+### 1.2 Core Value-Drives evolution: receives signals from `SignalDetector`, decides if they matter, calls the LLM for concrete changes, and writes evolution records. **`/evolve`** invokes this path.+The core value of the skill self-evolution mechanism lies in:-### SkillEvolutionManager+- **No manual intervention required**: The agent automatically improves itself during daily operation+- **Continuous capability improvement**: Skills become more accurate and reliable with increased usage time+- **Adaptive to scene changes**: Automatically adjusts and optimizes based on actual usage scenarios+- **Reduced maintenance costs**: Decreases manual effort for updating and maintaining skills-Orchestrates scanning, LLM-generated records, `evolutions.json` I/O, and optional **solidify** into `SKILL.md`. Connects `SignalDetector`, `SkillOptimizer`, and `SkillCallOperator`.+## 2. Usage Methods-### SignalDetector+### 2.1 Self-Evolution Configuration Switch-Rule-based (no LLM): watches tool results for error patterns and user phrases that look like corrections, and attributes signals to the active skill.+The skill auto-evolution feature is enabled by turning on the self-evolution configuration item `evolution_auto_scan` in the configuration information.----+-## What counts as a signal?+### 2.2 Automatic Evolution (No Intervention Required)-### Execution failures+The system automatically detects evolution signals after each tool execution and dialogue completion. When execution exceptions or user corrections are detected, it automatically generates evolution records and stores them in `evolutions.json`.-Timeouts, HTTP errors, exceptions, etc. Keywords include: `error`, `exception`, `failed`, `failure`, `timeout`, `connection error`, `econnrefused`, `enoent`, `permission denied`, `command not found`, and similar.+No user action is required—evolution proceeds silently in the background. When the skill is called next time, it automatically loads content including evolution experience.-### User corrections+-Phrases like “wrong”, “should be”, “not that”, or English: `that's wrong`, `should be`, `actually`—treated as negative feedback for the current skill.+### 2.3 Manual Evolution Triggering----+If you want to immediately trigger evolution for a specific skill, you can enter:-## What happens after a signal?--### Failure → troubleshooting notes--Failure context is turned into actionable bullets under **Troubleshooting** (or similar) in the skill doc.--```text-Raw:-Tool 'weather-check' returned: Error: API timeout after 30s--Evolved:-## Troubleshooting-- On weather API timeout, check network first; consider retries or a fallback.+```bash+/evolve <skill_name>```-### Correction → examples--User corrections become **Examples** so the next run matches real intent.+For example:-```text-Raw:-User: No—I meant Shanghai, not Beijing--Evolved:-## Examples-- For "Shanghai weather" use Shanghai coordinates, not the default Beijing.+```bash+/evolve xlsx```------## Evolution flow--```text-User chat / tool run- │- ▼-┌───────────────────┐-│ SignalDetector │-└────────┬──────────┘- ▼-┌─────────────────────────────┐-│ SkillEvolutionManager │ .scan()-└────────────┬────────────────┘- ▼-┌─────────────────────────────┐-│ SkillEvolutionManager │ .generate()-└────────────┬────────────────┘- ▼-┌─────────────────────────────┐-│ evolutions.json │-└────────────┬────────────────┘- ▼ (optional)-┌─────────────────────────────┐-│ .solidify() │ merge into SKILL.md-└─────────────────────────────┘-```+The system scans recent dialogue and execution records, generates evolution experience for the skill, and displays the generated results.----+-## Evolution file+### 2.4 View Evolution Status-Per-skill `evolutions.json`:+To see which skills have pending evolution experience, you can enter:-```json-{- "skill_id": "<skill_name>",- "version": "1.0.0",- "updated_at": "2024-01-15T10:30:00Z",- "entries": [- {- "id": "ev_1234abcd",- "source": "execution_failure",- "timestamp": "2024-01-15T10:30:00Z",- "context": "API timeout after 30s",- "change": {- "section": "Troubleshooting",- "action": "append",- "content": "## FAQ\n- On API timeout..."- },- "applied": false- }- ]-}+```bash+/evolve list```-`applied: false` = pending solidify; `applied: true` = merged into `SKILL.md`.-----+The system lists all skills containing pending evolution records and their specific content summaries.-## Effect+-Skills stay **living documents**: risks, examples, and fixes accumulate from real use. On the next skill load, `evolutions.json` is merged so behavior improves without manual editing.+### 2.5 Manage Evolution Experience----+Evolution experience is stored in the `evolutions.json` file under the skill directory. You can directly edit this file to manage evolution experience:-## How to use+**Directory location:**+```+~/.jiuwenswarm/workspace/agent/skills/<skill_name>/+├── SKILL.md # Skill source document+├── evolutions.json # Evolution experience records ← Edit here+└── ...+```-When using Skill self-evolution, first decide what you want to do:+**Common operations:**+- Add new records: Append new objects to the `entries` array+- Modify records: Edit the `change.content` field to update evolution content+- Delete records: Remove from the array+- Mark as solidified: Set `applied` to `true` (system will also toggle this during solidify)-- Let the system discover and preserve experience in the background: enable **Auto-detect evolution signals**.-- Immediately improve an existing Skill: use the `/evolve` commands.-- Let the system propose creating a new Skill when there is a capability gap: enable **Auto-suggest new skill creation**.+⚠️ **Important**: Do not modify system-managed fields such as `id`, `source`, `timestamp`, `context`, `section`, `action`, `target`, or `relevant`. These fields are generated and maintained by the system.-### Enable auto-evolution+Changes take effect automatically in the next dialogue.-In **Self-Evolution Configuration**, enable the options you need:+## 3. Case Practice: Triggering Code Modifications Through Text Dialogue Fields-- **Auto-detect evolution signals**: lets the system scan failures, corrections, and other evolution signals after chat and tool execution; maps to `evolution.auto_scan` and is disabled by default.-- **Auto-suggest new skill creation**: lets the system propose creating a new Skill when no suitable Skill exists; maps to `evolution.skill_create` and is disabled by default.+### 3.1 Scenario Background-If you manage settings through a config file, the corresponding keys are:+Suppose we have a simple `file-operations` skill for handling file operations. This skill includes a `read_file` function for reading file content.-```yaml-evolution:- auto_scan: false- skill_create: false-```+**Initial SKILL.md definition:**+```markdown+# file-operations Skill-Environment variables take precedence: `EVOLUTION_AUTO_SCAN` overrides `auto_scan`, and `SKILL_CREATE` overrides `skill_create`.+## Functions-+### read_file+- Function: Read the content of the specified file+- Parameters:+ - `file_path`: File path+- Return: File content-### Automatic path+## Examples+- Read file: read_file({"file_path": "/path/to/file.txt"})+```-When **Auto-detect evolution signals** is enabled, the system scans for evolution signals after tool execution and conversation turns. Common signals include tool failures, execution errors, user corrections, and explicit negative feedback.+### 3.2 Evolution Triggered by Dialogue-When valid signals are found, the system generates evolution experience for the relevant Skill. The next time that Skill is used, the experience is loaded automatically.+#### Round 1: Problem Discovery-+```+User: Help me read the test.txt file in the current directory+Assistant: Sure, I'll read the test.txt file in the current directory for you.+Tool: file-operations.read_file({+ "file_path": "test.txt"+})+Tool Response: Error: File not found: test.txt+Assistant: Sorry, I can't find the test.txt file. Could you provide the full path?+```-### Manual evolution+The system detects tool execution failure (`File not found`) and automatically triggers an evolution signal.-If a Skill just failed, behaved incorrectly, or needs a specific improvement, use:+#### Round 2: User Provides Full Path-```bash-/evolve <skill_name> [user_query]+```+User: It should be ./test.txt+Assistant: Sure, I'll read the ./test.txt file for you.+Tool: file-operations.read_file({+ "file_path": "./test.txt"+})+Tool Response: This is the content of the test.txt file.+Assistant: Successfully read the ./test.txt file. Here's the content:+This is the content of the test.txt file.```-Example:+#### Round 3: User Feedback-```bash-/evolve xlsx confirm detailed requirements before creating an invoice file+```+User: No, when I just provide the file name, you should automatically look in the current directory without me manually adding ./+Assistant: Thank you for your feedback. I'll optimize this feature so it automatically looks in the current directory when only a file name is provided.```-+The system detects user correction feedback ("No") and triggers another evolution signal.-In **Planning Mode**, the system first scans the current conversation for tool failures and user corrections. If no clear signal is detected, provide `user_query` to describe what should be improved.+### 3.3 Automatically Generated Evolution Records-In **Cluster Mode**, `/evolve <skill_name>` must include an evolution intent, for example:+The system automatically generates evolution records in the `evolutions.json` file under the `file-operations` skill directory.-```bash-/evolve pptx add recovery steps when team report export fails-```--### Inspect and organize evolution experience+### 3.4 Effect After Evolution-To inspect one Skill's evolution records and scores, use:+When the skill is called again, it automatically loads the evolution experience, and the improved functionality works as follows:-```bash-/evolve_list <skill_name> [--sort score]```--Example:--```bash-/evolve_list xlsx --sort score+User: Help me read the test.txt file in the current directory+Assistant: Sure, I'll read the test.txt file in the current directory for you.+Tool: file-operations.read_file({+ "file_path": "test.txt"+})+Tool Response: This is the content of the test.txt file.+Assistant: Successfully read the test.txt file. Here's the content:+This is the content of the test.txt file.```-In **Planning Mode**, bare `/evolve` still returns a pending-record summary for visible Skills. Cluster Mode does not support bare `/evolve`; it requires a Skill name and an evolution intent.+Now, when the user only provides a file name, the system automatically looks in the current directory without requiring the user to manually add the `./` prefix.-If a Skill's experience library becomes repetitive, too long, or unclear, generate a cleanup proposal:+## 4. Feature Interpretation: Principles and Mechanisms-```bash-/evolve_simplify <skill_name> [user_intent]-```+### 4.1 Core Components-Example:+#### 4.1.1 SkillCallOperator-```bash-/evolve_simplify xlsx merge duplicate export-failure records-```+SkillCallOperator is the core entry point for interaction between JiuwenSwarm and skills, responsible for unified management of skills:-The cleanup proposal is approval-gated. It is not written silently.+- Reads skill definitions (SKILL.md)+- Executes skill commands+- Automatically loads accumulated evolution experiences of skills-+When the system detects areas for improvement, these improvements are first stored in `evolutions.json`, and SkillCallOperator merges them before returning them to the Agent.-### Rebuild `SKILL.md`+#### 4.1.2 SkillOptimizer-When a Skill has accumulated enough evolution experience and you want to reorganize it into `SKILL.md`, use:+SkillOptimizer is the optimizer that drives the entire skill evolution process:-```bash-/evolve_rebuild <skill_name> [user_intent]-```+1. **Receive signals**: Receives exception signals from SignalDetector to understand what problems the current skill is encountering+2. **Analyze and judge**: Combines dialogue context to determine if the problem is worth recording+3. **Generate improvements**: Calls LLM to generate specific improvement suggestions+4. **Execute recording**: Writes generated improvement plans to evolution records-Example:+When you use the `/evolve` command, it's SkillOptimizer working behind the scenes.-```bash-/evolve_rebuild xlsx add fallback steps when required tools are missing-```+#### 4.1.3 SkillEvolutionManager-This command creates a follow-up task and continues as a normal Agent / Cluster Mode task. It is not a direct overwrite button for `SKILL.md`.+SkillEvolutionManager is the core manager of the evolution lifecycle, responsible for coordinating various stages of evolution work:-+- **Signal scanning**: Calls SignalDetector to extract events that require evolution+- **Record generation**: Calls LLM to convert signals into executable improvement plans+- **Storage management**: Maintains reading and writing of `evolutions.json` files+- **Content solidification**: Merges pending evolution records into the original SKILL.md-### Skill auto-creation+It connects SignalDetector, SkillOptimizer, and SkillCallOperator to form a complete evolution loop.-Existing Skill evolution improves Skills that already exist. If the current task exposes a missing capability, enable **Auto-suggest new skill creation** in **Self-Evolution Configuration**. If you manage settings through a config file, use:+#### 4.1.4 SignalDetector-```yaml-evolution:- skill_create: true-```+SignalDetector is the detector for evolution signals, continuously monitoring for anomalies in dialogue and execution results:-When enabled, the system registers `SkillCreateRail`. In Cluster Mode, it registers `TeamSkillCreateRail`. When the system judges that the task should become a reusable Skill, it proposes creation and completes it through follow-up work.+- Listens to every tool execution result, capturing error keywords+- Captures user correction feedback (such as "no", "should be", etc.)+- Determines which skill the signal should be attributed to and associates context-Notes:+SignalDetector works based on rules, does not require calling LLM, and therefore has fast response speed.-- `skill_create` is disabled by default.-- `SKILL_CREATE=true` overrides the config file.+### 4.2 Signal Detection Mechanism-### Supported modes+#### 4.2.1 Execution Exception Detection-| Mode | Support |-|---|---|-| Planning Mode `agent.plan` | Existing Skill evolution, inspection, cleanup, rebuild, and Skill auto-creation. |-| Cluster Mode `team` | Team Skill evolution, inspection, cleanup, and rebuild; `/evolve <skill_name>` requires an evolution intent. |-| Code mode / `agent.fast` | `/evolve` Skill self-evolution commands are not supported. |+The system automatically detects exceptions in tool execution, including:+- Tool call timeouts+- Interface return errors+- Exception interruptions during code execution-### Approval and status+Detection keywords include but are not limited to:+- General errors: `error`, `exception`, `failed`, `failure`, `timeout`+- Network-related: `connection error`, `econnrefused`, `enoent`+- Permission-related: `permission denied`, `command not found`-- `/evolve` and `/evolve_simplify` do not silently write changes. The backend pushes a confirmation question.-- Accepting persists or solidifies the generated records; rejecting discards the generated content.-- Accepted Cluster Mode Skill evolution syncs the team skill directory.-- While evolution or approval is pending, supplemental input is queued until evolution completes.+#### 4.2.2 User Correction Detection-### Manage evolution experience+The system identifies user correction feedback, which is often more valuable than error logs:-Evolution experience is stored in each Skill's `evolutions.json`. In normal use, prefer:+- Chinese patterns: `不对`, `不是这`, `错 了`, `应该 是`, `你搞错了`, `纠正一下`+- English patterns: `that's wrong`, `you're wrong`, `should be`, `actually`-- Web UI **View skill experience**: edit `change.content`, or delete an entry and save.-- `/evolve_list <skill_name>`: inspect records and scores.-- `/evolve_simplify <skill_name> [user_intent]`: clean up, merge, or remove low-value experience.-- `/evolve_rebuild <skill_name> [user_intent]`: reorganize experience into `SKILL.md`.+### 4.3 Evolution Process-Do not modify fields other than `change.content`, such as `id`, `source`, `timestamp`, `context`, `section`, `action`, `target`, `relevant`, or `applied`. These fields are generated and maintained by the system.+```text+User chat / tool run+ │+ ▼+┌───────────────────┐+│ SignalDetector │ Listens and identifies signals+│ Detects execution exceptions │+│ Detects user corrections │+└────────┬──────────┘+ │+ ▼+┌─────────────────────────────┐+│ SkillEvolutionManager │+│ .scan() │ Extracts evolution signals+└────────────┬───────────────┘+ │+ ▼+┌─────────────────────────────┐+│ SkillEvolutionManager │+│ .generate() │ LLM generates evolution records+└────────────┬───────────────┘+ │+ ▼+┌─────────────────────────────┐+│ evolutions.json │ Writes pending solidification records+│ (Under Skill directory) │+└────────────┬───────────────┘+ │+ ▼ (optional)+┌─────────────────────────────┐+│ .solidify() │ Merges into SKILL.md+└─────────────────────────────┘+```-Location:+### 4.4 Evolution Record Storage-```-~/.jiuwenswarm/workspace/agent/skills/<skill_name>/-├── SKILL.md-├── evolutions.json-└── ...-```+Evolution records are stored in the `evolutions.json` file under each skill directory:```json{+ "skill_id": "<skill_name>",+ "version": "1.0.0",+ "updated_at": "2024-01-15T10:30:00Z","entries": [{- "id": "ev_1cdbc3a5",+ "id": "ev_1234abcd","source": "execution_failure",- "timestamp": "2026-03-09T09:33:08Z",- "context": "Error context",+ "timestamp": "2024-01-15T10:30:00Z",+ "context": "API timeout after 30s","change": {"section": "Troubleshooting","action": "append",- "content": "Evolved content",- "relevant": true+ "content": "## FAQ\n- On API timeout..."},"applied": false}@@ -309,4 +295,6 @@ Location:}```-After saving in the frontend, the updated experience content is loaded automatically in the next conversation.+Where:+- `applied: false` indicates pending solidification status+- `applied: true` indicates already solidified into SKILL.md\ No newline at end of filediff --git a/docs/zh/SUMMARY.md b/docs/zh/SUMMARY.mdindex 68d87a03ef..80009ab4d3 100644--- a/docs/zh/SUMMARY.md+++ b/docs/zh/SUMMARY.md@@ -30,7 +30,7 @@- [记忆系统](记忆.md)- [自动记忆](自动记忆.md)- [经验记忆](经验记忆.md)- - [上下文压缩卸载](上下文压缩卸载.md)+ - [上下文压缩](上下文压缩.md)- [编码记忆](编码记忆.md)- [技能系统](技能.md)- [技能交响乐:技能检索、编排与分发](symphony-技能编排与分发.md)@@ -44,6 +44,7 @@- [打包 exe 指南](打包exe指南.md)- [ACP 插件使用](ACP插件使用.md)- [Windows 自动更新设计](windows自动更新设计.md)+ - [日志系统](日志.md)- [开发实践](开发实践/README.md)- [日报生成器开发实践](开发实践/JiuwenSwarm日报生成器开发实践.md)- [代码审查助手开发实践](开发实践/JiuwenSwarm代码审查助手开发实践.md)diff --git "a/docs/zh/Skill\350\207\252\346\274\224\350\277\233.md" "b/docs/zh/Skill\350\207\252\346\274\224\350\277\233.md"index fd3c763df9..6f3bf29e8c 100644--- "a/docs/zh/Skill\350\207\252\346\274\224\350\277\233.md"+++ "b/docs/zh/Skill\350\207\252\346\274\224\350\277\233.md"@@ -1,365 +1,293 @@# Skill 自演进-Agent 系统普遍存在一个问题:能力定义一旦写好,就基本不会再变了。工具调用出错,记录一条日志;用户反馈说理解有误,下次还是同样的逻辑。能力的上限,从部署那天就已经固定了。+## 1. 概念科普-JiuwenSwarm 基于 **openJiuwen 自演进框架**,以 `SkillCallOperator` 算子统一管理所有 Skills 的读写与演进分发。在此基础上,系统内置了一套演进信号检测机制,持续监听执行过程和对话内容,将真实使用中遇到的问题转化为 Skills 的改进输入。+### 1.1 Skill 自演进简介-## 核心组件+Skill 自演进是 JiuwenSwarm 基于 openJiuwen 自演进框架实现的一项核心功能,它打破了传统 Agent 系统能力固定的局限。传统 Agent 系统的能力定义一旦写好,就基本不会再变——工具调用出错仅记录日志,用户反馈理解有误但下次仍使用同样逻辑。能力的上限从部署那天就已固定。-### SkillCallOperator+JiuwenSwarm 的 Skill 自演进机制通过内置的演进信号检测系统,持续监听执行过程和对话内容,将真实使用中遇到的问题自动转化为 Skills 的改进输入。它让 Skills 不再是一次性的静态文档,而是随着真实使用持续迭代的活文档。-SkillCallOperator 是 JiuwenSwarm 基于 openJiuwen 框架实现的 Operator 算子,负责 Skills 的统一管理。+### 1.2 核心价值-作为 JiuwenSwarm 与 Skills 交互的核心入口,它承担以下职责:-- 读取 Skill 定义(SKILL.md)-- 执行 Skill 指令-- 自动加载 Skill 积累的演进经验--当系统检测到需要改进的地方,这些改进会先存入 `evolutions.json`,SkillCallOperator 会把它们合并后一起返回给 Agent。这意味着每次调用 Skill 时,都能获取到最新的演进经验。--### SkillOptimizer--SkillOptimizer 是 JiuwenSwarm 基于 openJiuwen 框架实现的 Optimizer 优化器,负责驱动整个 Skill 演进流程。--它的核心工作包括:-1. **接收信号**:从 SignalDetector 接收异常信号,理解当前 Skill 遇到了什么问题-2. **分析判断**:结合对话上下文,判断这个问题是否值得记录-3. **生成改进**:调用 LLM 生成具体的改进建议-4. **执行记录**:将生成的改进方案写入演进记录--当你使用 `/evolve` 命令时,背后就是 SkillOptimizer 在工作。--### SkillEvolutionManager--SkillEvolutionManager 是演进生命周期的核心管理者,负责协调各个阶段的演进工作:+Skill 自演进机制的核心价值在于:-- **信号扫描**:调用 SignalDetector 提取需要演进的事件-- **记录生成**:调用 LLM 将信号转化为可执行的改进方案-- **存储管理**:维护 `evolutions.json` 文件的读写-- **内容固化**:将待定演进记录合并到原始 SKILL.md+- **无需人工干预**:智能体在日常运转过程中自动完成对自身的改进+- **持续能力提升**:随着使用时间增加,Skills 的准确性和可靠性不断提高+- **自适应场景变化**:能够根据实际使用场景自动调整和优化+- **降低维护成本**:减少了手动更新和维护 Skills 的工作量-它衔接了 SignalDetector、SkillOptimizer 和 SkillCallOperator,形成完整的演进闭环。+## 2. 使用方法-### SignalDetector+### 2.1 自演进配置开关-SignalDetector 是演进信号的检测器,持续监听对话和执行结果中的异常。+Skill 自动演进功能通过在配置信息中开启自演进配置项 `evolution_auto_scan` 开关启用。-它基于规则工作,不需要调用 LLM,因此响应速度快:-- 监听每一次工具执行的结果,捕捉错误关键词-- 捕捉用户的纠正反馈(如"不对"、"应该"等)-- 判断信号应该归到哪个 Skill 并关联上下文-------## 识别哪些信号?+-信号来源主要分两类:+### 2.2 自动演进(无需干预)-### 执行异常+系统会在每次工具执行和对话结束后自动检测演进信号。当检测到执行异常或用户纠错时,会自动生成演进记录并存入 `evolutions.json`。-包括工具调用超时、接口返回报错、代码执行中的异常中断等。只要任务执行中出现明确的失败字样,系统会自动识别并将其归因到当前正在执行的 Skill 上。+你无需做任何操作,演进在后台静默进行。下次调用该 Skill 时,会自动加载包含演进经验的内容。-检测关键词包括但不限于:-- 通用错误:`error`、`exception`、`failed`、`failure`、`timeout`-- 网络相关:`connection error`、`econnrefused`、`enoent`-- 其他:`permission denied`、`command not found`+-### 用户纠错+### 2.3 手动触发演进-当你说“不对”、“应该换个方式”、“你理解错了”这类话语时,系统不会将其当作普通对话略过,而是会识别为一次有效的负反馈。这类信号往往比报错日志更有价值——它直接点出了 Skill 在理解或处理逻辑上的偏差。+如果希望立即为某个 Skill 触发演进,可以输入:-检测模式包括:-- 中文:`不对`、`不是这`、`错 了`、`应该 是`、`你搞错了`、`纠正一下`-- 英文:`that's wrong`、`you're wrong`、`should be`、`actually`+```bash+/evolve <skill_name>+```----+例如:-## 信号捕获之后做什么?+```bash+/evolve xlsx+```-系统会全程追踪当前活跃的 Skill 模块,确保每个信号都能准确对应到具体的 Skill 文档。具体的改写逻辑如下:+系统会扫描最近的对话和执行记录,为该 Skill 生成演进经验,并显示生成结果。-### 异常案例 → 排障建议+-执行失败的现场记录会被整理成具体的操作建议,补充进 Skills 的 `Troubleshooting`(已知问题与处理方式)部分。下次遇到相同场景,Skill 可以主动提示已知的风险点和应对方式。+### 2.4 查看演进状态-```text-原始信号:-Tool 'weather-check' returned: Error: API timeout after 30s+想知道哪些 Skill 有待固化的演进经验,可以输入:-演进为:-## Troubleshooting-- 遇到天气 API 超时错误时,优先检查网络连接,可考虑添加重试机制或降级策略。+```bash+/evolve list```-### 纠错交互 → 示例补充+系统会列出所有包含待演进记录的 Skill 及具体内容摘要。-用户纠错的对话片段会作为新的 `Example`(正确用法示例)写入 Skills 文档,让后续的调用更容易理解用户的真实意图。+-```text-原始信号:-User: 不对,我说的是查询上海不是北京+### 2.5 管理演进经验-演进为:-## Examples-- 用户说"查询上海天气"时应调用上海的经纬度参数,而非默认北京-```+演进经验存储在 Skill 目录下的 `evolutions.json` 文件中,你可以直接编辑该文件来管理演进经验:------## 演进流程--```text-用户对话 / 工具执行- │- ▼-┌───────────────────┐-│ SignalDetector │ 监听并识别信号-│ 检测执行异常 │-│ 检测用户纠错 │-└────────┬──────────┘- │- ▼-┌─────────────────────────────┐-│ SkillEvolutionManager │-│ .scan() │ 提取演进信号-└────────────┬───────────────┘- │- ▼-┌─────────────────────────────┐-│ SkillEvolutionManager │-│ .generate() │ LLM 生成演进记录-└────────────┬───────────────┘- │- ▼-┌─────────────────────────────┐-│ evolutions.json │ 写入待固化记录-│ (Skill 目录下) │-└────────────┬───────────────┘- │- ▼ (可选)-┌─────────────────────────────┐-│ .solidify() │ 合并到 SKILL.md-└─────────────────────────────┘+**目录位置:**```-------## 演进文件--演进记录存储在每个 Skill 目录下的 `evolutions.json` 文件中:--```json-{- "skill_id": "<skill_name>",- "version": "1.0.0",- "updated_at": "2024-01-15T10:30:00Z",- "entries": [- {- "id": "ev_1234abcd",- "source": "execution_failure",- "timestamp": "2024-01-15T10:30:00Z",- "context": "API timeout after 30s",- "change": {- "section": "Troubleshooting",- "action": "append",- "content": "## 常见问题\n- 遇到 API 超时错误时..."- },- "applied": false- }- ]-}+~/.jiuwenswarm/workspace/agent/skills/<skill_name>/+├── SKILL.md # Skill 源文档+├── evolutions.json # 演进经验记录 ← 在这里编辑+└── ...```-其中 `applied: false` 表示待固化状态,`applied: true` 表示已固化到 SKILL.md。-----+**常用操作:**+- 添加新记录:在 `entries` 数组中追加新对象+- 修改记录:编辑 `change.content` 字段来更新演进内容+- 删除记录:从数组中移除+- 标记已固化:将 `applied` 设为 `true`(系统在固化时也会自动切换此字段)-## 演进效果+⚠️ **注意**:不要修改系统管理字段,如 `id`、`source`、`timestamp`、`context`、`section`、`action`、`target`、`relevant`。这些字段由系统生成和维护。-这套机制让 Skills 不再是一次性的静态文档,而是随着真实使用持续迭代的活文档。不需要任何人工干预,智能体在日常运转过程中就完成了对自身的改进。+修改后在下次对话时会自动加载。-演进后的 Skill 在下次被调用时,会自动检查 Skill 目录下是否存在 `evolutions.json` 文件,存在时会自动加载演进经验的内容,从而:-- 主动提示已知的风险点和应对方式-- 更准确地理解用户的真实意图-- 持续优化自身的表现+## 3. 案例实践:通过文字对话字段触发代码修改----+### 3.1 场景背景-## 如何使用+假设我们有一个简单的 `file-operations` Skill,用于处理文件操作。该 Skill 包含一个 `read_file` 功能,用于读取文件内容。-使用 Skill 自演进时,可以先按下面顺序判断自己要做什么:+**初始 SKILL.md 定义:**+```markdown+# file-operations Skill-- 想让系统在后台自动发现并沉淀经验:开启自动扫描。-- 想立即针对某个已有 Skill 生成经验:使用 `/evolve` 系列命令。-- 想让系统在缺少合适 Skill 时自动提出新 Skill 创建建议:开启 Skill 自动创建。+## Functions-### 自演进配置开关+### read_file+- 功能:读取指定文件的内容+- 参数:+ - `file_path`: 文件路径+- 返回:文件内容-在配置页的 **自演进配置** 中,可以按需要开启:--- **自动检测可演进信号**:让系统在对话和工具执行后自动扫描失败、纠错等演进信号;对应配置 `evolution.auto_scan`,默认关闭。-- **自动建议创建新技能**:让系统在缺少合适 Skill 时提出新 Skill 创建建议;对应配置 `evolution.skill_create`,默认关闭。--如果通过配置文件管理,对应写法是:--```yaml-evolution:- auto_scan: false- skill_create: false+## Examples+- 读取文件:read_file({"file_path": "/path/to/file.txt"})```-- 环境变量 `EVOLUTION_AUTO_SCAN` 会覆盖 `auto_scan`,`SKILL_CREATE` 会覆盖 `skill_create`。----### 自动演进+### 3.2 对话触发演进过程-开启 **自动检测可演进信号** 后,系统会在工具执行和对话结束后自动检测演进信号。常见信号包括工具失败、执行报错、用户纠错和明确负反馈。+#### 第一轮对话:发现问题-如果检测到有效信号,系统会为相关 Skill 生成演进经验。下次调用该 Skill 时,这些经验会被自动加载,帮助 Agent 避免重复错误。--+```+User: 帮我读取当前目录下的 test.txt 文件+Assistant: 好的,我将为您读取当前目录下的 test.txt 文件。+Tool: file-operations.read_file({+ "file_path": "test.txt"+})+Tool Response: Error: File not found: test.txt+Assistant: 对不起,我找不到 test.txt 文件。请问文件的完整路径是什么?+```-### 手动触发已有 Skill 演进+系统检测到工具执行失败(`File not found`),自动触发演进信号。-如果你刚遇到某个 Skill 的失败、偏差或需要补充的经验,可以直接输入:+#### 第二轮对话:用户提供完整路径-```bash-/evolve <skill_name> [user_query]+```+User: 应该是 ./test.txt+Assistant: 好的,我将为您读取 ./test.txt 文件。+Tool: file-operations.read_file({+ "file_path": "./test.txt"+})+Tool Response: 这是 test.txt 文件的内容。+Assistant: 已成功读取 ./test.txt 文件,内容如下:+这是 test.txt 文件的内容。```-例如:+#### 第三轮对话:用户反馈-```bash-/evolve xlsx 创建发票文件前需要向我确定具体要求+```+User: 不对,当我只提供文件名时,你应该自动在当前目录查找,不需要我手动添加 ./+Assistant: 非常感谢您的反馈。我会优化这个功能,使其在只提供文件名时自动在当前目录查找。```---在**规划模式**下,系统会优先扫描当前会话中的工具失败和用户纠错信号。如果没有检测到明确演进信号,可以在命令后补充 `user_query`,直接说明希望 Skill 改进什么。+系统检测到用户纠错反馈("不对"),再次触发演进信号。-在**集群模式**下,`/evolve <skill_name>` 必须带上演进意图,例如:+### 3.3 自动生成的演进记录-```bash-/evolve pptx 让团队报告导出失败时给出可恢复步骤-```+系统自动在 `file-operations` Skill 目录下的 `evolutions.json` 文件中生成演进记录。-### 查看和整理演进经验+### 3.4 演进后的效果-想查看某个 Skill 的详细经验库和评分,可以输入:+当 Skill 再次被调用时,它会自动加载演进经验,改进后的功能如下:-```bash-/evolve_list <skill_name> [--sort score]```--例如:--```bash-/evolve_list xlsx --sort score+User: 帮我读取当前目录下的 test.txt 文件+Assistant: 好的,我将为您读取当前目录下的 test.txt 文件。+Tool: file-operations.read_file({+ "file_path": "test.txt"+})+Tool Response: 这是 test.txt 文件的内容。+Assistant: 已成功读取 test.txt 文件,内容如下:+这是 test.txt 文件的内容。```-在**规划模式**下,无参数 `/evolve` 仍会返回当前可见 Skill 的待处理演进记录摘要;Team 模式不支持裸 `/evolve`,必须提供 Skill 名称和演进意图。因此日常查看经验库时,建议使用 `/evolve_list <skill_name>`。+现在,当用户只提供文件名时,系统会自动在当前目录查找,无需用户手动添加 `./` 前缀。-如果某个 Skill 的经验库开始重复、过长或价值不清,可以让系统生成整理方案:+## 4. 特性解读:原理与机制-```bash-/evolve_simplify <skill_name> [user_intent]-```+### 4.1 核心组件-例如:+#### 4.1.1 SkillCallOperator-```bash-/evolve_simplify xlsx 合并重复的导出失败经验-```+SkillCallOperator 是 JiuwenSwarm 与 Skills 交互的核心入口,负责 Skills 的统一管理:-整理方案不会静默落盘。系统会弹出审批,确认后才执行,拒绝后会丢弃本次整理。----### 重建 Skill 文档+- 读取 Skill 定义(SKILL.md)+- 执行 Skill 指令+- 自动加载 Skill 积累的演进经验-当某个 Skill 积累了较多演进经验,希望把经验重新组织进 `SKILL.md` 时,可以输入:+当系统检测到需要改进的地方,这些改进会先存入 `evolutions.json`,SkillCallOperator 会把它们合并后一起返回给 Agent。-```bash-/evolve_rebuild <skill_name> [user_intent]-```+#### 4.1.2 SkillOptimizer-例如:+SkillOptimizer 是驱动整个 Skill 演进流程的优化器:-```bash-/evolve_rebuild xlsx 增加环境缺少工具时的应对策略-```+1. **接收信号**:从 SignalDetector 接收异常信号,理解当前 Skill 遇到的问题+2. **分析判断**:结合对话上下文,判断问题是否值得记录+3. **生成改进**:调用 LLM 生成具体的改进建议+4. **执行记录**:将生成的改进方案写入演进记录-这个命令会生成后续执行任务,并继续作为普通 Agent / Team 任务运行。它不是直接覆盖 `SKILL.md` 的快捷按钮,实际改动仍会通过任务执行和审批流程完成。+使用 `/evolve` 命令时,背后就是 SkillOptimizer 在工作。-+#### 4.1.3 SkillEvolutionManager-### Skill 自动创建+SkillEvolutionManager 是演进生命周期的核心管理者,负责协调各个阶段的演进工作:-已有 Skill 自演进解决的是“已有 Skill 怎么变好”。如果当前任务暴露出缺少合适 Skill 的问题,可以开启 Skill 自动创建:+- **信号扫描**:调用 SignalDetector 提取需要演进的事件+- **记录生成**:调用 LLM 将信号转化为可执行的改进方案+- **存储管理**:维护 `evolutions.json` 文件的读写+- **内容固化**:将待定演进记录合并到原始 SKILL.md-```yaml-evolution:- skill_create: true-```+它衔接了 SignalDetector、SkillOptimizer 和 SkillCallOperator,形成完整的演进闭环。-开启后,系统会注册 `SkillCreateRail`。在集群模式中,会注册 `TeamSkillCreateRail`。当系统判断当前任务需要沉淀成新 Skill 时,会提出创建建议,并通过后续任务完成 Skill 创建。+#### 4.1.4 SignalDetector-注意:+SignalDetector 是演进信号的检测器,持续监听对话和执行结果中的异常:-- `skill_create` 默认关闭,适合在希望主动沉淀新能力时开启。-- 环境变量 `SKILL_CREATE=true` 会覆盖配置文件。+- 监听每一次工具执行的结果,捕捉错误关键词+- 捕捉用户的纠正反馈(如"不对"、"应该"等)+- 判断信号应该归到哪个 Skill 并关联上下文-### 适用模式+SignalDetector 基于规则工作,不需要调用 LLM,因此响应速度快。-| 模式 | 支持情况 |-|---|---|-| 规划模式 `agent.plan` | 支持已有 Skill 演进、经验查看、整理、重建和 Skill 自动创建。 |-| 集群模式 `team` | 支持团队 Skill 演进、经验查看、整理、重建;`/evolve <skill_name>` 必须带演进意图。 |-| Code 模式 / `agent.fast` | 不支持 `/evolve` 系列 Skill 自演进命令。 |+### 4.2 信号检测机制-### 审批和状态+#### 4.2.1 执行异常检测-- `/evolve` 和 `/evolve_simplify` 生成变更后不会静默写入,会推送确认问题。-- 接受后,后端接受本次演进记录并写入或固化;拒绝后丢弃本次生成内容。-- Team 技能演进接受后会同步团队技能目录。-- 演进或审批未完成时,后续输入会先排队,等待演进完成后再发送。+系统会自动检测工具执行中的异常,包括:+- 工具调用超时+- 接口返回报错+- 代码执行中的异常中断-### 如何管理演进经验+检测关键词包括但不限于:+- 通用错误:`error`、`exception`、`failed`、`failure`、`timeout`+- 网络相关:`connection error`、`econnrefused`、`enoent`+- 权限相关:`permission denied`、`command not found`-演进经验存储在 Skill 目录下的 `evolutions.json` 文件中。日常建议优先使用:+#### 4.2.2 用户纠错检测-- Web 前端 **查看技能经验**:编辑经验内容 `change.content`,或删除整条经验后保存。-- `/evolve_list <skill_name>`:查看经验库和评分。-- `/evolve_simplify <skill_name> [user_intent]`:整理、合并、清理经验库。-- `/evolve_rebuild <skill_name> [user_intent]`:把经验重新组织进 `SKILL.md`。+系统会识别用户的纠错反馈,这类信号往往比报错日志更有价值:-不要修改 `change.content` 之外的字段,例如 `id`、`source`、`timestamp`、`context`、`section`、`action`、`target`、`relevant`、`applied`。这些字段由系统生成和维护。+- 中文模式:`不对`、`不是这`、`错 了`、`应该 是`、`你搞错了`、`纠正一下`+- 英文模式:`that's wrong`、`you're wrong`、`should be`、`actually`-**目录位置:**+### 4.3 演进流程-```-~/.jiuwenswarm/workspace/agent/skills/<skill_name>/-├── SKILL.md # Skill 源文档-├── evolutions.json # 演进经验记录-└── ...+```text+用户对话 / 工具执行+ │+ ▼+┌───────────────────┐+│ SignalDetector │ 监听并识别信号+│ 检测执行异常 │+│ 检测用户纠错 │+└────────┬──────────┘+ │+ ▼+┌─────────────────────────────┐+│ SkillEvolutionManager │+│ .scan() │ 提取演进信号+└────────────┬───────────────┘+ │+ ▼+┌─────────────────────────────┐+│ SkillEvolutionManager │+│ .generate() │ LLM 生成演进记录+└────────────┬───────────────┘+ │+ ▼+┌─────────────────────────────┐+│ evolutions.json │ 写入待固化记录+│ (Skill 目录下) │+└────────────┬───────────────┘+ │+ ▼ (可选)+┌─────────────────────────────┐+│ .solidify() │ 合并到 SKILL.md+└─────────────────────────────┘```-**演进记录示例:**+### 4.4 演进记录存储++演进记录存储在每个 Skill 目录下的 `evolutions.json` 文件中:```json{+ "skill_id": "<skill_name>",+ "version": "1.0.0",+ "updated_at": "2024-01-15T10:30:00Z","entries": [{- "id": "ev_1cdbc3a5",+ "id": "ev_1234abcd","source": "execution_failure",- "timestamp": "2026-03-09T09:33:08Z",- "context": "错误上下文",+ "timestamp": "2024-01-15T10:30:00Z",+ "context": "API timeout after 30s","change": {"section": "Troubleshooting","action": "append",- "content": "演进内容",- "relevant": true+ "content": "## 常见问题\n- 遇到 API 超时错误时..."},"applied": false}@@ -367,4 +295,6 @@ evolution:}```-前端保存后,下次对话会自动加载更新后的经验内容。+其中:+- `applied: false` 表示待固化状态+- `applied: true` 表示已固化到 SKILL.md\ No newline at end of filediff --git a/docs/zh/image.png b/docs/zh/image.pngnew file mode 100644index 0000000000..5f1774eefbBinary files /dev/null and b/docs/zh/image.png differdiff --git "a/docs/zh/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251.md" "b/docs/zh/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251.md"new file mode 100644index 0000000000..cc2fbff0f6--- /dev/null+++ "b/docs/zh/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251.md"@@ -0,0 +1,372 @@+# 上下文压缩++## 1. 概念科普++### 1.1 上下文的概念++在 AI 对话系统中,**上下文**指的是对话过程中产生的所有历史信息,包括用户的提问、AI 的回答、工具调用的结果等。这些信息共同构成了 AI 理解当前对话状态和提供准确回答的基础。++### 1.2 上下文窗口限制++尽管上下文对于 AI 理解对话至关重要,但所有 AI 模型都存在**上下文窗口限制**——即模型在单轮对话中能够处理的最大信息量(通常以 Token 数量衡量)。当对话超出这个限制时,AI 会出现以下问题:++- 响应速度显著变慢+- 早期关键信息被遗忘+- 回答准确性下降+- 系统资源消耗过大++### 1.3 上下文压缩的概念++**上下文压缩**是一种智能优化技术,通过对历史对话内容进行分析、筛选和精简,在保持对话连贯性的前提下,将上下文信息压缩到模型可处理的范围内。++其核心思想可以类比为:在阅读一本长篇小说时,我们不需要记住每一个细节,只需要记住关键情节和人物关系,就能理解故事的发展。++JiuwenSwarm 可以通过上下文压缩卸载机制,使用 `[[OFFLOAD:...]]` 格式的索引标记大工具消息的卸载内容,在显著减少上下文数据量的同时,保留大工具消息的检索能力。++> **注意**:普通压缩后的内容无法召回,只有被卸载的大工具消息内容可以通过 `[[OFFLOAD:...]]` 索引标记进行检索。++### 1.4 应用场景++上下文压缩技术适用于各种需要长时间对话的场景:++- **数据分析**:处理大量数据表格和分析结果+- **项目管理**:跨多天的项目跟进和讨论+- **代码开发**:长时间的代码编写和调试+- **文档创作**:长篇文档的协作编写+- **客户支持**:复杂问题的长时间解决过程++## 2. 基础使用++### 2.1 开启上下文压缩++上下文压缩功能默认是关闭的,您可以通过以下方式开启:++**方式一:通过配置文件开启**++编辑 `config.yaml` 配置文件,找到 `context_engine_config` 部分:++```yaml+ enabled: true # 将此设置为 true 开启上下文压缩+```++**方式二:通过前端界面开启**++在 JiuwenSwarm 客户端中,进入页面:++++- 点击左侧菜单栏的"配置信息"+- 选择"其他配置"+- 找到"上下文压缩"+- 点击开关将其开启++### 2.2 查看上下文压缩状态++开启上下文压缩后,您可以通过以下方式查看压缩状态:++**方式一:查看对话状态面板**++在对话界面的右下角,系统会实时显示上下文窗口的使用情况:++++状态面板包含以下信息:++- 当前使用的 Token 数+- 模型支持的最大 Token 数+- 当前占用比例++**方式二:通过 Slash 命令查看**++在对话输入框中输入以下命令可以查看详细的上下文压缩信息:++```bash+/context+```++++## 3. 案例实践++为便于演示上下文压缩效果,本案例将触发阈值调整为 40K(默认值为 100K)。当上下文长度达到 40K 时,系统自动触发压缩机制,可在较短对话中观察压缩过程。++开发者可根据接入模型和业务需求,通过修改 `config.yaml` 中各处理器的 `tokens_threshold` 参数自定义阈值。++开发者可根据接入模型和业务需求,通过修改 `config.yaml` 中各处理器的 `tokens_threshold` 参数自定义阈值。++### 3.1 无上下文压缩的情况++**场景**:用户与 AI 咨询北京3天旅行计划(单一请求)++**对话过程**:++```+User: 帮我规划一个下周去北京的3天旅行计划+Assistant: 好的,我来为您规划一个详细的北京3天旅行计划。+Tool: 正在查询北京天气和景点信息...+Tool Response: 返回了详细的天气数据和景点推荐+Assistant: 根据您的需求,我为您制定了以下旅行计划:++【北京3天深度游行程】++Day 1: 天安门广场 → 故宫 → 景山公园+- 上午:天安门广场看升旗+- 中午:故宫游览+- 下午:景山公园俯瞰故宫全景++Day 2: 八达岭长城 → 明十三陵+- 上午:八达岭长城+- 下午:明十三陵++Day 3: 颐和园 → 圆明园 → 南锣鼓巷+- 上午:颐和园+- 中午:圆明园+- 下午:南锣鼓巷感受老北京文化++美食推荐:北京烤鸭、炸酱面、涮羊肉++重要提醒:请提前预约故宫门票+```++**说明**:++- 图片中可看到:AI回复内容包含丰富的旅行信息+- 图片右下角状态面板显示:上下文窗口 41.3K/289.0K (20.6%)+- Token消耗主要来自:AI的详细回复内容 + 工具调用返回的数据++**最终结果**:++- 整个对话的上下文 Token 数已达到 41.3K,占用模型窗口的 20.6%+- 后续对话风险:如果用户继续追问细节或请求扩展计划,上下文会继续增长+- 潜在问题:随着对话深入,可能接近模型上下文窗口上限++++### 3.2 有上下文压缩的情况++**相同场景**:用户与 AI 咨询北京3天旅行计划(单一请求)++**相同任务**:获得详细且可用的北京3天旅行计划++**对话过程**:++```+User: 帮我规划一个下周去北京的3天旅行计划+Assistant: 好的,我来为您规划一个详细的北京3天旅行计划。+Tool: 正在查询北京天气和景点信息...+Tool Response: 返回了详细的天气数据和景点推荐+Assistant: 根据您的需求,我为您制定了以下旅行计划:++【北京3天深度游行程】++Day 1: 天安门广场 → 故宫 → 景山公园+...(系统自动压缩了详细行程内容)++[[OFFLOAD: 旅行计划详情已压缩,核心信息保留]]+```++**说明**:++- 图片中可看到:AI完成了完整的旅行计划任务+- 图片右下角状态面板显示:上下文窗口 40.7K/289.0K (28.3%)++**最终结果**:++- 整个对话的上下文 Token 数保持在 40.7K,占用模型窗口的 28.3%+- AI 保持核心信息记忆:能够处理后续的进一步请求+- 系统能够完成更多关联任务:如创建技能等扩展功能+- 用户体验优化:可以继续进行多轮交互和功能扩展++++### 3.3 实际效果说明++从两张示例图片的实际数据来看(基于40k阈值测试):++1. **上下文 Token 使用**:+ - 无压缩场景:41.3K Token+ - 有压缩场景:40.7K Token+ - 两者差异不大,说明在单次详细请求场景下,压缩主要优化的是信息结构而非简单减少Token数量+2. **系统功能表现**:+ - 两种场景均成功完成了旅行计划生成+ - 有压缩场景额外支持了技能创建等扩展功能+ - 内存占用稳定在362MB左右,系统资源消耗差异不明显+3. **实际价值体现**:+ - 上下文压缩通过优化信息结构,使系统能够更好地处理后续扩展请求+ - 保持核心信息完整性的同时,提升了系统的功能扩展性+4. **阈值说明**:+ - 当前示例基于40k Token触发阈值测试,便于快速观察压缩效果+ - 生产环境中可根据实际需求调整阈值参数(如100k及以上)++## 4. 特性解读++### 4.1 动态触发机制++上下文压缩不是固定的预处理步骤,而是根据对话状态动态触发的智能优化:++- **基于消息数量**:当对话轮次超过 `messages_threshold` 时触发(不同处理器有不同默认值)+- **基于 Token 数量**:当累计 Token 数超过 `tokens_threshold` 时触发(不同处理器有不同默认值)+- **基于轮次级别**:当对话轮次超过 `rounds_threshold` 时触发高级压缩+- **可配置性**:用户可以根据需要调整各个触发阈值++### 4.2 智能识别和压缩++系统采用先进的自然语言处理技术,能够:++- **区分消息类型**:自动识别用户消息、AI 回答和工具结果+- **识别重要性**:基于语义分析判断消息的重要程度+- **选择压缩方式**:对不同类型的内容采用不同的压缩策略+ - 对工具返回的冗长数据进行摘要+ - 对重复信息进行合并+ - 对不重要的内容进行过滤++### 4.3 关键信息保护++上下文压缩不会丢失重要信息,系统会:++- **保留最近消息**:通过 `messages_to_keep` 参数保留指定数量的最新消息+- **保留完整轮次**:启用 `keep_last_round` 确保最新一轮的用户-助手对话完整保留+- **识别关键内容**:通过语义分析自动识别并保留关键信息++### 4.4 检索能力保持++上下文压缩不会破坏对话的检索能力:++- **卸载标记**:部分处理器使用 `[[OFFLOAD:...]]` 格式标记被卸载的内容,便于未来按需加载+- **关联保留**:压缩后的信息仍然与原始上下文保持关联+- **按需加载**:在需要时可以通过卸载标记按需加载原始信息++### 4.5 性能优化++上下文压缩能够显著提升系统性能:++- **减少内存占用**:将上下文数据量减少 50%-80%+- **提高响应速度**:降低模型推理时间,提升用户体验+- **支持更长对话**:突破模型上下文窗口限制,支持长时间对话+- **降低成本**:减少 Token 消耗,降低使用成本++## 5. 进阶配置++JiuwenSwarm 的上下文压缩系统包含 **4 个独立的处理器**,每个都有自己的配置参数。以下是与代码完全一致的完整配置示例:++```yaml+context_engine_config:+ # 全局开关+ enabled: true # 启用上下文压缩(核心开关)+ enable_kv_cache_release: false # 启用 KV 缓存释放(算力优化)+ enable_reload: true # 启用重新加载++ # 1. 消息摘要卸载器 - 处理工具调用等特定类型消息+ message_summary_offloader_config:+ messages_threshold: null # 消息数阈值(null 表示不限制)+ tokens_threshold: 60000 # Token 数触发阈值+ large_message_threshold: 60000 # 大消息定义(超过此值视为大消息)+ offload_message_type: [ "tool" ] # 要压缩的消息类型(列表形式)+ protected_tool_names: ["read_file:*SKILL.md", "reload_original_context_messages"]+ messages_to_keep: null # 保留的消息数+ keep_last_round: false # 是否保留最后一轮对话+ customized_summary_prompt: null # 自定义摘要提示词+ enable_adaptive_compression: true # 启用自适应压缩+ summary_max_tokens: 900 # 摘要最大 Token 数+ enable_precise_step: false # 启用精确步骤模式+ step_summary_max_context_messages: 8 # 精确步骤模式下最大上下文消息数+ content_max_chars_for_compression: 200000 # 压缩内容最大字符数++ # 2. 对话压缩器 - 压缩整个对话历史+ dialogue_compressor_config:+ messages_threshold: null # 消息数阈值+ tokens_threshold: 100000 # Token 数触发阈值+ messages_to_keep: 10 # 保留最近 10 条消息+ keep_last_round: false # 是否保留最后一轮+ compression_target_tokens: 1800 # 压缩目标 Token 数+ offload_writeback_enabled: false # 是否启用卸载写回++ # 3. 当前轮次压缩器 - 压缩当前对话轮次+ current_round_compressor_config:+ tokens_threshold: 100000 # Token 数触发阈值+ messages_to_keep: 3 # 保留最近 3 条消息+ min_selected_tokens_for_compression: 20000 # 压缩最小 Token 数+ compression_target_tokens: 4000 # 压缩目标 Token 数+ summary_merge_target_tokens: 4000 # 摘要合并目标 Token 数+ accumulated_summary_token_limit: 20000 # 累积摘要 Token 限制+ summary_merge_min_blocks: 3 # 摘要合并最小块数+ prior_context_window_size: 10 # 先前上下文窗口大小+ offload_writeback_enabled: false # 是否启用卸载写回++ # 4. 轮次级别压缩器 - 多轮对话高级压缩+ round_level_compressor_config:+ rounds_threshold: 2 # 轮次阈值(超过此轮次触发)+ tokens_threshold: 230000 # Token 数触发阈值+ trigger_total_tokens: 230000 # 触发总 Token 数+ target_total_tokens: 160000 # 目标总 Token 数+ compression_call_max_tokens: 250000 # 压缩调用最大 Token 数+ keep_last_round: true # 保留最后一轮对话+ keep_recent_messages: 6 # 保留最近 6 条消息+ messages_to_keep: 6 # 保留消息数+ first_pass_target_tokens: 30000 # 第一轮压缩目标 Token 数+ second_pass_target_tokens: 20000 # 第二轮压缩目标 Token 数+ third_pass_target_tokens: 10000 # 第三轮压缩目标 Token 数+ truncate_head_ratio: 0.2 # 头部截断比例+ offload_writeback_enabled: false # 是否启用卸载写回+```++### 5.1 配置参数说明++#### 消息摘要卸载器(message_summary_offloader_config)++| 参数 | 说明 | 默认值 |+|------|------|--------|+| `tokens_threshold` | 触发压缩的 Token 阈值 | 60000 |+| `offload_message_type` | 要压缩的消息类型,支持 `["tool"]` | `["tool"]` |+| `enable_adaptive_compression` | 是否启用自适应压缩 | true |+| `summary_max_tokens` | 摘要最大 Token 数 | 900 |++#### 对话压缩器(dialogue_compressor_config)++| 参数 | 说明 | 默认值 |+|------|------|--------|+| `tokens_threshold` | 触发压缩的 Token 阈值 | 100000 |+| `messages_to_keep` | 保留的消息数 | 10 |+| `compression_target_tokens` | 压缩后的目标 Token 数 | 1800 |++#### 当前轮次压缩器(current_round_compressor_config)++| 参数 | 说明 | 默认值 |+|------|------|--------|+| `min_selected_tokens_for_compression` | 触发压缩的最小 Token 数 | 20000 |+| `summary_merge_target_tokens` | 摘要合并后的目标 Token 数 | 4000 |+| `prior_context_window_size` | 先前上下文窗口大小 | 10 |++#### 轮次级别压缩器(round_level_compressor_config)++| 参数 | 说明 | 默认值 |+|------|------|--------|+| `rounds_threshold` | 触发压缩的对话轮次阈值 | 2 |+| `trigger_total_tokens` | 触发压缩的总 Token 数 | 230000 |+| `first_pass_target_tokens` | 第一轮压缩目标 | 30000 |+| `second_pass_target_tokens` | 第二轮压缩目标 | 20000 |+| `third_pass_target_tokens` | 第三轮压缩目标 | 10000 |+| `truncate_head_ratio` | 头部截断比例 | 0.2 |++### 5.2 配置层级说明++配置文件中的完整层级结构如下:++```yaml+react: # 顶层 React 配置+ context_engine_config: # 上下文引擎配置+ enabled: true # 全局开关+ message_summary_offloader_config: {} # 处理器 1+ dialogue_compressor_config: {} # 处理器 2+ current_round_compressor_config: {} # 处理器 3+ round_level_compressor_config: {} # 处理器 4+```++### 5.3 配置注意事项++1. **处理器独立工作**:4 个处理器各自独立触发,互不依赖+2. **阈值配置**:建议根据实际业务场景调整 `tokens_threshold` 参数+3. **类型要求**:`offload_message_type` 必须是列表形式 `["tool"]`,不能是字符串 `"tool"`+4. **多级压缩**:`round_level_compressor_config` 提供三轮渐进式压缩,适合长对话场景++通过合理配置这些参数,用户可以根据自己的使用场景和需求,获得最佳的上下文压缩效果和对话体验。diff --git "a/docs/zh/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251\345\215\270\350\275\275.md" "b/docs/zh/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251\345\215\270\350\275\275.md"deleted file mode 100644index b8a8b0a085..0000000000--- "a/docs/zh/\344\270\212\344\270\213\346\226\207\345\216\213\347\274\251\345\215\270\350\275\275.md"+++ /dev/null@@ -1,21 +0,0 @@-# 上下文压缩卸载:为 AI“瘦身”,让长对话更流畅--在日常使用智能体的过程中,随着对话轮次的增加,用户往往会遇到一个典型问题:AI的“记忆力”似乎逐渐下降——响应变慢、忽略早期信息,甚至在处理财务账单等关键内容时出现错误。其根本原因在于技术层面的一个核心瓶颈:**上下文窗口的容量限制**。如同人类短期记忆的局限性,AI在单轮对话中可承载的信息量也是有限的。--为此,JiuwenSwarm 引入了基于 openJiuwen 的 **上下文卸载(Context Offload)机制**。其设计理念可以类比为“办公桌整理”:当桌面文件(消息数量)或纸张厚度(Token数量)超出预设阈值时,系统将自动识别并归档那些“大而次要”的内容,仅保留一份简要索引,从而为当前任务腾出更多“注意力”。这使得即便面对长时间的财务对账或数据分析任务,AI也能保持高度专注与连贯性。--## 如何配置上下文卸载机制?--为使系统能够灵活应对多样化的对话场景,JiuwenSwarm 提供了一套可动态调整的“上下文管理策略”,核心配置参数包括:--| 参数 | 说明 |-| :--- | :--- |-| **触发条件** | 当消息数量超过 `messages_threshold`(例如 3 条),或累计 Token 数超出 `tokens_threshold`(默认 20000)时,系统将自动启动上下文瘦身流程 |-| **识别超长消息** | 通过 `large_message_threshold`(例如 1000 Token)界定何为“大消息”,系统将优先对这些占用大量资源的消息进行处理 |-| **选择性归档** | 利用 `offload_message_type` 参数,可指定对某一角色消息进行压缩(例如仅压缩工具返回的冗长数据,保留用户与助手的核心对话) |-| **压缩方式** | 系统将通过采样或摘要的方式提取关键信息,并插入索引标记 `[[OFFLOAD:...]]`,在压缩内容的同时保留上下文检索能力 |-| **保护近期重要对话** | 可设置 `messages_to_keep` 强制保留最近若干条消息,或启用 `keep_last_round` 确保最新一轮的用户-助手对话完整保留 |--[演示视频](../assets/videos/compression.mp4)--通过这一动态上下文管理机制,JiuwenSwarm 实现了对 AI 上下文的智能调控——既保障关键信息(如财务账单、合同条款)不丢失,也有效排除冗余数据的干扰,确保长对话始终保持高效与连贯。无论是跨多日的项目跟进,还是反复核对的数据分析任务,JiuwenSwarm 的上下文瘦身机制都将为每一次交互提供稳定、流畅的体验。diff --git "a/docs/zh/\346\227\245\345\277\227.md" "b/docs/zh/\346\227\245\345\277\227.md"new file mode 100644index 0000000000..1f195466e9--- /dev/null+++ "b/docs/zh/\346\227\245\345\277\227.md"@@ -0,0 +1,214 @@+# 日志++JiuwenSwarm 提供了完善的日志系统,用于记录系统运行状态、调试信息和审计日志,帮助用户监控系统运行、排查问题和分析系统行为。++## 1. 日志基础++### 1.1 存储位置++默认情况下,JiuwenSwarm 的日志文件存储在以下位置:++```+~/.jiuwenswarm/agent/.logs/+```++### 1.2 日志文件分类++日志系统根据组件类型将日志分类存储到不同文件中:++| 日志文件 | 记录内容 |+|---------|---------|+| `gateway.log` | 网关相关日志,包括 `app`、`gateway`、`evolution`、`utils` 等模块 |+| `channel.log` | 渠道相关日志,包括所有 `channels` 下的模块 |+| `agent_server.log` | 智能体服务器日志,包括 `agents` 和 `.server` 下的模块 |+| `full.log` | 所有组件日志的汇总 |+| `desktop.log` | 桌面应用日志 |+| `permissions.log` | 权限相关日志 |+| `ws-dev.log` | Web 服务开发模式日志 |++### 1.3 日志内容类型++日志系统根据内容类型分为两种主要类型:++#### 1.3.1 普通日志++普通日志按组件分类,记录系统运行状态、错误信息、调试信息等:+- 使用标准的 Python logging 模块实现+- 根据组件类型存储到不同文件中(见1.2节)++#### 1.3.2 审计日志++审计日志以结构化 JSONL 格式记录沙箱操作详情,包括:+- 命令执行(`exec_command`)+- 文件传输(`file_transfer`)+- 网络请求(`network_request`)++每条审计日志包含操作类型、参数、结果、执行时间等信息。++## 2. 查看日志++### 2.1 前端查看日志++++### 2.2 实时查看日志++使用 `tail` 命令实时查看日志:++```bash+# 实时查看 full.log+$ tail -f ~/.jiuwenswarm/agent/.logs/full.log++# 实时查看特定组件日志+$ tail -f ~/.jiuwenswarm/agent/.logs/gateway.log+```++### 2.3 查看历史日志++使用 `cat` 查看日志++```bash+# 查看完整日志文件+$ cat ~/.jiuwenswarm/agent/.logs/full.log+```++## 3. 日志轮转策略++日志系统采用以下轮转策略:++- **大小限制**:默认每个日志文件最大 20MB(可通过 `max_bytes` 配置)+- **保留数量**:默认保留 20 个日志文件(可通过 `backup_count` 配置)+- **自动轮转**:当日志文件达到大小限制时,自动创建新文件并归档旧文件+- **命名格式**:归档文件命名为 `{filename}.{index}`,例如 `gateway.log.1`++## 4. 日志系统架构++### 4.1 核心模块++- **日志配置**:`jiuwenclaw/common/utils.py` 中的 `setup_logger` 函数+- **审计日志**:`jiuwenbox/src/jiuwenbox/server/audit_logger.py`+- **默认日志实现**:`openjiuwen/core/common/logging/default/default_impl.py`++### 4.2 日志流程++1. 各模块通过 `logging.getLogger(__name__)` 获取 logger+2. 根据 logger 名称自动分类到不同组件+3. 日志同时输出到控制台和对应组件的日志文件+4. 所有日志汇总到 `full.log`+5. 当日志文件达到大小限制时自动轮转++## 5. 日志配置++### 5.1 配置文件++日志级别主要通过 `config.yaml` 文件中的 `logging` 部分配置:++```yaml+logging:+ level: INFO # 默认日志级别+ console_level: INFO # 控制台日志级别+ gateway: INFO # 网关组件日志级别+ channel: INFO # 渠道组件日志级别+ agent_server: INFO # 智能体服务器日志级别+ full: INFO # 完整日志级别+ max_bytes: 20971520 # 日志文件大小限制(20MB)+ backup_count: 20 # 保留日志文件数量+```++### 5.2 环境变量++可以通过环境变量覆盖控制台日志级别:++```bash+LOG_LEVEL=DEBUG jiuwenswarm-start+```++### 5.3 命令行参数++启动服务时,可以通过参数指定日志级别:++```bash+jiuwenswarm-start --log-level DEBUG+```++## 6. 日志级别++JiuwenSwarm 支持标准的 Python 日志级别:++| 级别 | 描述 |+|------|------|+| DEBUG | 调试信息,用于开发和调试 |+| INFO | 一般信息,记录系统正常运行状态 |+| WARNING | 警告信息,记录潜在问题 |+| ERROR | 错误信息,记录系统错误 |+| CRITICAL | 严重错误信息,记录系统崩溃等严重问题 |++## 7. 日志格式++日志格式包含时间戳、日志级别、模块名和日志消息:++```+2026-05-19 15:30:45.123 INFO jiuwenclaw.app: Service started successfully+```++### 7.1 审计日志格式++审计日志使用结构化 JSON 格式:++```json+{+ "timestamp": "2026-05-19T15:30:45.123Z",+ "event_type": "exec_command",+ "sandbox_id": "9284a4bf-870",+ "command": "ls -la",+ "workdir": "/home/user",+ "ok": true,+ "exit_code": 0,+ "stdout": "total 40\ndrwxr-xr-x 5 user user 4096 May 19 15:30 .",+ "stderr": "",+ "duration_ms": 123+}+```++## 8. 常见问题与排查++### 8.1 日志文件过大++**问题**:日志文件增长过快,占用过多磁盘空间++**解决方案**:+- 降低日志级别以减少日志输出+- 减小 `max_bytes` 配置以减小单个日志文件大小+- 减小 `backup_count` 配置以减少保留的日志文件数量++### 8.2 无日志输出++**问题**:找不到日志文件或日志内容为空++**解决方案**:+- 检查日志目录权限是否正确+- 检查日志级别配置是否过高+- 检查服务是否正常启动++### 8.3 日志乱码++**问题**:日志文件包含乱码字符++**解决方案**:+- 确保系统编码设置正确(推荐使用 UTF-8)+- 使用支持 UTF-8 编码的文本编辑器查看日志++## 9. 最佳实践++1. **开发环境**:使用 DEBUG 级别获取详细调试信息+2. **生产环境**:使用 INFO 或 WARNING 级别减少日志输出+3. **定期清理**:定期清理过期日志文件,避免占用过多磁盘空间+4. **集中管理**:考虑使用日志收集工具(如 ELK Stack)进行日志集中管理+5. **敏感信息**:注意日志中可能包含的敏感信息,如 API 密钥、密码等++## 10. 相关配置文件++- 主配置文件:`~/.jiuwenswarm/config/config.yaml`+- 环境变量文件:`~/.jiuwenswarm/config/.env`+- 日志系统实现:`jiuwenclaw/common/utils.py`+- 审计日志实现:`jiuwenbox/src/jiuwenbox/server/audit_logger.py`\ No newline at end of filediff --git a/jiuwenswarm/resources/config.team.distributed.teammate.yaml b/jiuwenswarm/resources/config.team.distributed.teammate.yamlindex 6eed805b8c..9e0e996b5d 100644--- a/jiuwenswarm/resources/config.team.distributed.teammate.yaml+++ b/jiuwenswarm/resources/config.team.distributed.teammate.yaml@@ -101,7 +101,7 @@ memory:mem0:api_key: ${MEM0_API_KEY:-}user_id: ${MEM0_USER_ID:-jiuwenswarm-user}- agent_id: ${MEM0_AGENT_ID:-jiuwenswarm}+ agent_id: ${MEM0_AGENT_ID:-jiuwenclaw}rerank: true # 搜索结果重排序(更准但更慢)# -- OpenViking(字节上下文数据库)--@@ -114,57 +114,58 @@ memory:user: ${OPENVIKING_USER:-default}models:- default:- model_client_config:- api_base: ${API_BASE}- api_key: ${API_KEY}- model_name: ${MODEL_NAME:-xiaomi/mimo-v2-omni}- client_provider: ${MODEL_PROVIDER}- timeout: 1800- verify_ssl: false- custom_headers: {}- model_config_obj:- temperature: 0.95+ defaults:+ - model_client_config:+ api_base: ${API_BASE}+ api_key: ${API_KEY}+ model_name: ${MODEL_NAME:-xiaomi/mimo-v2-omni}+ client_provider: ${MODEL_PROVIDER}+ timeout: 1800+ verify_ssl: false+ custom_headers: {}+ model_config_obj:+ temperature: 0.95+ is_default: truevideo:- model_client_config:- api_base: ${VIDEO_API_BASE}- api_key: ${VIDEO_API_KEY}- model_name: ${VIDEO_MODEL_NAME:-xiaomi/mimo-v2-omni}- client_provider: ${VIDEO_PROVIDER}- timeout: 1800- verify_ssl: false- model_config_obj:- temperature: 0.95+ model_client_config:+ api_base: ${VIDEO_API_BASE}+ api_key: ${VIDEO_API_KEY}+ model_name: ${VIDEO_MODEL_NAME:-xiaomi/mimo-v2-omni}+ client_provider: ${VIDEO_PROVIDER}+ timeout: 1800+ verify_ssl: false+ model_config_obj:+ temperature: 0.95audio:- model_client_config:- api_base: ${AUDIO_API_BASE}- api_key: ${AUDIO_API_KEY}- model_name: ${AUDIO_MODEL_NAME:-openai/gpt-4o-audio-preview}- client_provider: ${AUDIO_PROVIDER}- verify_ssl: false- timeout: 1800- model_config_obj:- temperature: 0.95+ model_client_config:+ api_base: ${AUDIO_API_BASE}+ api_key: ${AUDIO_API_KEY}+ model_name: ${AUDIO_MODEL_NAME:-openai/gpt-4o-audio-preview}+ client_provider: ${AUDIO_PROVIDER}+ verify_ssl: false+ timeout: 1800+ model_config_obj:+ temperature: 0.95vision:- model_client_config:- api_base: ${VISION_API_BASE}- api_key: ${VISION_API_KEY}- model_name: ${VISION_MODEL_NAME:-bytedance-seed/seed-2.0-mini}- client_provider: ${VISION_PROVIDER}- verify_ssl: false- timeout: 1800- model_config_obj:- temperature: 0.95+ model_client_config:+ api_base: ${VISION_API_BASE}+ api_key: ${VISION_API_KEY}+ model_name: ${VISION_MODEL_NAME:-bytedance-seed/seed-2.0-mini}+ client_provider: ${VISION_PROVIDER}+ verify_ssl: false+ timeout: 1800+ model_config_obj:+ temperature: 0.95image_gen:- model_client_config:- api_base: ${IMAGE_GEN_API_BASE:-https://dashscope.aliyuncs.com/api/v1}- api_key: ${IMAGE_GEN_API_KEY}- model_name: ${IMAGE_GEN_MODEL_NAME:-qwen-image-max}- client_provider: ${IMAGE_GEN_PROVIDER:-DashScope}- verify_ssl: false- timeout: 1800- model_config_obj:- temperature: 0.95+ model_client_config:+ api_base: ${IMAGE_GEN_API_BASE:-https://dashscope.aliyuncs.com/api/v1}+ api_key: ${IMAGE_GEN_API_KEY}+ model_name: ${IMAGE_GEN_MODEL_NAME:-qwen-image-max}+ client_provider: ${IMAGE_GEN_PROVIDER:-DashScope}+ verify_ssl: false+ timeout: 1800+ model_config_obj:+ temperature: 0.95telemetry:enabled: false # 总开关(环境变量 OTEL_ENABLED 优先)@@ -173,7 +174,7 @@ telemetry:protocol: grpc # grpc / httpheaders: {} # 公共 OTLP headers,可被 traces/metrics 覆盖log_messages: true # 是否在 span event 中记录完整消息内容- service_name: jiuwenswarm+ service_name: jiuwenclawprovider_factory: # 自定义 provider factory,格式:module:functiontraces:exporter: # trace exporter,默认回退到 telemetry.exporter@@ -188,12 +189,15 @@ telemetry:react:agent_name: main_agent+ enable_task_loop: falsemax_iterations: 100model_name: ${MODEL_NAME:-deepseek-chat}skill_mode: all# code_agent / research_agent 默认不启用;只有显式配置 enabled: true 才会显示并可被 task_tool 调用# browser_agent 保持原行为,仍由浏览器 runtime 开关决定是否默认注册;这里只支持覆盖其参数subagents:+ general_agent:+ enabled: truecode_agent:enabled: false# max_iterations: 15@@ -209,9 +213,10 @@ react:enabled: truemessage_summary_offloader_config:messages_threshold: null- large_message_threshold: 15000+ tokens_threshold: 40000+ large_message_threshold: 60000offload_message_type: [ "tool" ]- protected_tool_names: [ "read_file" ]+ protected_tool_names: ["read_file:*SKILL.md", "reload_original_context_messages"]messages_to_keep: nullkeep_last_round: falsecustomized_summary_prompt: null@@ -221,14 +226,14 @@ react:step_summary_max_context_messages: 8content_max_chars_for_compression: 200000dialogue_compressor_config:- messages_threshold:- tokens_threshold: 100000+ messages_threshold: null+ tokens_threshold: 40000messages_to_keep: 10keep_last_round: falsecompression_target_tokens: 1800offload_writeback_enabled: falsecurrent_round_compressor_config:- tokens_threshold: 100000+ tokens_threshold: 40000messages_to_keep: 3min_selected_tokens_for_compression: 20000compression_target_tokens: 4000@@ -254,6 +259,7 @@ react:evolution:enabled: true # true = 启用在线 Skills 自演进auto_scan: false # true = 每轮对话后自动扫描(建议先用手动 /evolve)+ skill_create: false # true = 注册 SkillCreateRail(单 agent)及 TeamSkillCreateRail(leader)auto_save: false # true = 自演进审批无需用户点击自动通过(内部开关)skill_base_dir: "agent/skills" # Skill 根目录a2x_registry:@@ -267,10 +273,10 @@ react:role: "teammate"# When role=teammate, automatic blank-agent registration during agent# initialization calls AsyncA2XRegistryClient.register_blank_agent(...).- # Both dataset and endpoint must be configured explicitly; if either is- # missing, auto-registration is skipped and only a log is recorded.+ # endpoint may be omitted in distributed mode; it defaults to+ # team.transport.params.bootstrap_direct_addr when available.dataset: "team_pool"- endpoint: "tcp://127.0.0.1:28610"+ endpoint: ""tools:- todo@@ -306,7 +312,7 @@ gateway:session_map_scope: per_chat_botheartbeat:- # 心跳间隔(秒),默认 60+ # 心跳间隔(秒),默认 3600every: 3600# 心跳结果回传的 channel(如 "web"),target: web@@ -619,7 +625,7 @@ browser:updater:enabled: truerepo_owner: openJiuwen- repo_name: jiuwenswarm+ repo_name: jiuwenclawrelease_api_url: ""asset_name_pattern: "JiuwenSwarm-setup-{version}.exe"sha256_name_pattern: "JiuwenSwarm-setup-{version}.exe.sha256"@@ -632,12 +638,10 @@ extensions:team:- # Distributed teammate template. Copy this file to- # <TEAMMATE_HOME>/.jiuwenswarm/config/config.yaml and adjust registry/storage/ports.+ # 默认:单机 local + inprocess。双机 pyzmq 示例见 tmp/team-leader.yaml、tmp/team-teammate.yaml(与 .tmp/leader_home、.tmp/teammate_home 内 config 同步)。runtime:- mode: distributed- role: teammate- member_name: teammate_1+ mode: local+ role: leaderteam_name: jiuwen_teamlifecycle: persistent@@ -663,22 +667,12 @@ team:workspace:enabled: true- root_path: ${JIUWEN_TEAM_WORKSPACE_ROOT:-/tmp/jiuwenswarm/shared_workspace/jiuwen_team}- version_control: falsetransport:- type: pyzmq- params:- request_timeout: 20- direct_addr: tcp://0.0.0.0:28611- bootstrap_direct_addr: tcp://127.0.0.1:28610- pubsub_publish_addr: tcp://127.0.0.1:28556- pubsub_subscribe_addr: tcp://127.0.0.1:28557+ type: inprocessstorage:- type: postgresql- params:- connection_string: postgresql+asyncpg://postgres:[email protected]:5432/jiuwen_team+ type: sqlitemcp:servers: []@@ -719,13 +713,13 @@ modes:code:# 动态 Rails — 列表中出现的 = 启用;不出现的 = 不启用# 固定 Rails(以下 Rails 已在代码中固定挂载,无需在此配置):- # RuntimePromptRail, ResponsePromptRail, JiuSwarmStreamEventRail, SecurityRail,+ # RuntimePromptRail, ResponsePromptRail, JiuClawStreamEventRail, SecurityRail,# PermissionInterruptRail, SysOperationRail(FileSystemRail), LspRail,# ProjectMemoryRail, CodingMemoryRail, AgentModeRail, StructuredAskUserRail,# ConfirmInterruptRail, ContextProcessorRailrails:- - FileSystemRail- SkillUseRail+ - WorktreeRail# 动态 Tools — 列表中出现的 = 启用# send_file_to_user 由运行时 _update_session_tools 注册,不在此配置@@ -735,11 +729,12 @@ modes:- web_fetch_webpage- web_paid_search- user_todos+ - skill_toolkitembedding_config:- model_name:- base_url:- api_key:+ model_name: null+ base_url: null+ api_key: nullteam:jiuwen_team:team_name: jiuwen_team@@ -758,38 +753,12 @@ modes:stable_base: truemax_iterations: 200completion_timeout: 600.0- teammate:- workspace:- stable_base: true- max_iterations: 200- completion_timeout: 600.0workspace:enabled: true- root_path: ${JIUWEN_TEAM_WORKSPACE_ROOT:-/tmp/jiuwenswarm/shared_workspace/jiuwen_team}- version_control: falsetransport:- type: pyzmq- params:- request_timeout: 20- direct_addr: tcp://0.0.0.0:28611- bootstrap_direct_addr: tcp://127.0.0.1:28610- pubsub_publish_addr: tcp://127.0.0.1:28556- pubsub_subscribe_addr: tcp://127.0.0.1:28557+ type: inprocessstorage:- type: postgresql- params:- connection_string: postgresql+asyncpg://postgres:[email protected]:5432/jiuwen_team-- # ============================================================- # Team 级共享记忆(TeamMemoryConfig)- # ============================================================- memory:- enabled: false- scenario: "general"- auto_extract: true- shared_memory: true- member_memory_prompt_mode: "proactive"- timezone_offset_hours: 8.0+ type: sqlite