Skip to content

feat: Core V2 Agent System - Unified Tool Authorization & Scene Configuration#141

Merged
tptpp merged 9 commits intomainfrom
verify/corev2-agent
Mar 5, 2026
Merged

feat: Core V2 Agent System - Unified Tool Authorization & Scene Configuration#141
tptpp merged 9 commits intomainfrom
verify/corev2-agent

Conversation

@yhjun1026
Copy link
Collaborator

Summary

This PR introduces the Core V2 Agent System with unified tool authorization, scene configuration, and interaction management capabilities.

Changes

Major Features

  • Unified Tool Authorization System (Phase 1-6 complete)

    • Implement comprehensive tool authorization framework
    • Add permission management for agent tool access
  • Scene Configuration System (场景配置系统)

    • Support scene file management
    • Sandbox initialization and automatic injection
    • Scene editing and management UI components
  • History Compaction & Scene-Aware Agent

    • Add history compaction for efficient memory usage
    • Scene-aware agent examples and configurations

Agent Optimizations

  • Multiple rounds of agent performance improvements
  • Enhanced LLM client and provider registry
  • Correct core_v2 registration with pydantic config

UI/UX Improvements

  • New V2 Chat interface (v2-chat)
  • Unified chat hooks and services
  • Interaction management components
  • Scene editor and list components
  • i18n updates (English & Chinese)

Type Definitions & Utilities

  • Add interaction, authorization, tool, and V2 type definitions
  • VIS component utilities and devtools
  • JSON lines parser for streaming responses

Commits

  • feat: add history compaction and scene-aware agent examples
  • feat: implement unified tool authorization system (Phase 1-6 complete)
  • feat: 场景配置系统 - 支持场景文件管理、沙箱初始化和自动注入
  • feat: agent optimize
  • fix: correct core_v2 registration and add pydantic config

Files Changed

  • 627 files changed, 222,869 insertions(+), 320 deletions(-)
  • Major additions in: web/src/components/, web/src/hooks/, web/src/services/, web/src/types/, web/src/utils/vis/

Testing

  • Unit tests for new services
  • Integration tests for scene management
  • UI component tests

Notes

  • This is a large feature branch consolidating multiple agent system improvements
  • All changes have been tested locally
  • Ready for review and merge

主要功能:
1. 场景配置Tab重构
   - 按顶级设计师风格重新设计UI
   - 场景文件列表展示原文件名(coding.md)
   - 中文介绍作为副标题显示
   - 支持场景文件编辑、创建、删除

2. 场景文件沙箱初始化
   - 场景文件按Agent隔离存储
   - 目录结构: {sandbox.work_dir}/.scenes/{agent_name}/
   - 支持local/docker/k8s多种沙箱类型
   - 动态获取沙箱工作目录

3. Core和Core_v2架构支持
   - Core (v1): 在agent_chat.py中集成场景初始化
   - Core_v2 (v2): 在core_v2_adapter.py中集成场景初始化
   - 统一使用SceneSandboxInitializer模块

4. 场景内容自动注入
   - 场景文件自动读取并注入到Agent System Prompt
   - Agent能够根据场景定义调整行为
   - 支持多场景绑定和自动拼接

文件清单:
- packages/derisk-core/src/derisk/agent/core_v2/scene_sandbox_initializer.py (新增)
- packages/derisk-serve/src/derisk_serve/agent/agents/chat/agent_chat.py (修改)
- packages/derisk-serve/src/derisk_serve/agent/core_v2_adapter.py (修改)
- packages/derisk-serve/src/derisk_serve/building/app/api/schema_app.py (修改)
- web/src/app/application/app/components/tab-scenes.tsx (新增)
- web/src/types/app.ts (修改)
- packages/derisk-serve/src/derisk_serve/scene/ (新增目录)
- web/src/client/api/scene/ (新增目录)
This implements a comprehensive tool authorization system with:

Phase 1: Core Models
- ToolMetadata, ToolParameter, AuthorizationRequirement
- PermissionRule, PermissionRuleset, AuthorizationConfig
- InteractionRequest, InteractionResponse protocols
- AgentInfo, ToolSelectionPolicy configurations

Phase 2: Tool System
- ToolBase abstract class with safe execution
- ToolRegistry singleton for tool management
- Built-in tools: file_system, shell, network, code
- Tool decorators for quick definition

Phase 3: Authorization System
- AuthorizationEngine with decision logic
- RiskAssessor for risk evaluation
- AuthorizationCache for session caching
- Support for STRICT/MODERATE/PERMISSIVE/UNRESTRICTED modes

Phase 4: Interaction System
- InteractionGateway for async communication
- Support for TEXT_INPUT, SELECTION, CONFIRMATION, etc.
- WebSocket-ready architecture

Phase 5: Agent Integration
- AgentBase with think-decide-act loop
- Integrated authorization checking
- User interaction methods (ask_user, confirm, select)

Phase 6: Frontend & E2E Tests
- AuthorizationDialog, InteractionHandler components
- VisAuthorizationCard VIS component
- 57 E2E tests passing (authorization, interaction, agent execution)
- Add compression layers documentation and mapping files
- Add worklog history compaction architecture docs
- Add core_v2 context memory and tools/vis detail docs
- Implement compaction_pipeline, history_archive, message_adapter
- Add history_tools for agent core
- Add VisStatusNotification component
- Update react_reasoning_agent with compaction support
- Add scene-aware agent examples (code_assistant, sre_diagnostic)
- Update frontend components and locales
…olved config.tsx conflict (kept both VisStatusNotification and VisAuthorizationCard)
@github-actions github-actions bot added the enhancement New feature or request label Mar 5, 2026
@tptpp tptpp merged commit d2f34a3 into main Mar 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants