Skip to content

Fix/conflict agent skill dev into main#6636

Draft
chanzhi82020 wants to merge 21 commits intolabring:mainfrom
chanzhi82020:fix/conflict-agent-skill-dev-into-main
Draft

Fix/conflict agent skill dev into main#6636
chanzhi82020 wants to merge 21 commits intolabring:mainfrom
chanzhi82020:fix/conflict-agent-skill-dev-into-main

Conversation

@chanzhi82020
Copy link
Copy Markdown
Contributor

@chanzhi82020 chanzhi82020 commented Mar 25, 2026

Summary

This PR introduces a comprehensive AgentSkill system for the FastGPT agent, enabling users to create, version, and invoke custom code skills within agent workflows via a managed sandbox environment. It also replaces the MinIO-based sync-agent with a new volume-manager service for PVC/volume lifecycle management.

Key Features

  • AgentSkill Management: Full CRUD API for agent skills, including versioning, import/export (ZIP), and archive support.
  • Permission System: Role-based permission control for AgentSkill resources (owner, collaborator, pro tiers).
  • Sandbox Lifecycle: Automated sandbox provisioning, warm-up, teardown, and instance limit enforcement per user/team.
  • Sandbox Tools Integration: Skills are compiled into sandbox tools callable by the agent's LLM at runtime, with usage logging and display in chat records.
  • Volume Manager Service: New projects/volume-manager microservice (Bun + TypeScript) managing Docker/K8s PVC volumes for sandbox file isolation; replaces the removed sandbox-sync-agent.
  • Docker/K8s Deployment: Updated docker-compose files and new k8s/volume-manager.yaml manifest.
  • Configuration: Added sandbox instance limits, volume management settings, and agent sandbox config to system env.

Breaking Changes

  • Removed projects/sandbox-sync-agent — replaced by projects/volume-manager.
  • Sandbox schema and controller updated; SandboxStatusEnum typo fixed.

Test Coverage

  • Unit and integration tests for: skill controller, sandbox config, ZIP builder, storage, versioning, sandbox skills dispatch, and volume manager drivers.
  • New API-level tests for skill debug sessions, export, and chat record retrieval.

@chanzhi82020 chanzhi82020 force-pushed the fix/conflict-agent-skill-dev-into-main branch from 7f8e771 to c137431 Compare March 25, 2026 06:58
ctlaltlaltc and others added 21 commits March 25, 2026 15:58
* feat: Add agent skill management features and API endpoints

* feat: Add skill version management and SKILL.md utilities

* feat: Add skill import functionality with YAML frontmatter parsing

* feat: Add skill sandbox management and cleanup functionality

* feat: Add save and deploy functionality for skills

* feat: standardize skill package ZIP structure

- Enforce a standardized ZIP structure for skill packages where all files are contained within a root folder named after the skill.
- Implement `standardizeSkillPackage` utility to normalize ZIP archives during creation, import, and deployment.
- Transition sandbox operations to a dedicated `workDirectory` (/workspace/projects) for improved isolation.
- Enhance `SKILL.md` detection to support case-insensitivity and single-level subfolder locations.
- Update creation, import, and save-deploy APIs to maintain structural consistency across the skill lifecycle.
- Update test suites to verify the new folder-based standardized structure.

* feat: implement agent skill execution in session sandboxes

- Introduce a suite of sandbox tools (`sandbox_read_file`, `sandbox_write_file`, `sandbox_edit_file`, `sandbox_execute`, `sandbox_search`) for LLM-driven skill execution.
- Implement session-runtime sandbox lifecycle management, including automated skill deployment, standardization, and cleanup.
- Enhance the Master Agent decision system with a dedicated "Skill Execution Mode" and progressive disclosure of skill documentation via `SKILL.md` loading.
- Update the agent workflow dispatch to support dynamic sandbox initialization and prompt injection based on selected skill IDs.
- Refactor sandbox-related logging and ensure consistent buffer handling for skill packaging.

* feat: introduce AgentCapability abstraction and refactor sandbox infrastructure

- Add AgentCapability interface to decouple agent tool contributions from sandbox internals
- Implement SandboxSkillsCapability as first capability, replacing direct AgentSandboxContext usage
- Refactor dispatchRunAgent to aggregate capabilities (systemPrompt, tools, handlers, dispose)
- Add provider field to SandboxProviderConfig and buildDockerSyncEnv() for Docker runtime MinIO sync
- Restructure createEditDebugSandbox into three phases: config resolution, pre-flight, sandbox ops
- Add downloadSkillPackage and standardizeSkillPackage steps before sandbox creation
- Add useEditDebugSandbox input param to agent node for explicit sandbox mode selection
- Extend storage, sandboxSchema, versionSchema with supporting fields
- Add version controller tests

* feat: add sandboxStatus and skillCall SSE events for sandbox lifecycle

Provide real-time progress feedback during sandbox cold-start for
both session-runtime and edit-debug sandboxes via new SSE events.

- Add `sandboxStatus` and `skillCall` to SseResponseEventEnum
- Add SandboxStatusItemType, SandboxStatusPhase, SkillCallItemType types
- lifecycle.ts: accept onProgress callback, emit 7 lifecycle phases
- sandboxController.ts: accept onProgress callback, emit 5 lifecycle phases
- sandboxSkills.ts: wire workflowStreamResponse → onProgress; emit skillCall
  when sandbox_read_file detects a SKILL.md path
- agent/index.ts: pass workflowStreamResponse to createSandboxSkillsCapability
- edit.ts: convert REST endpoint to SSE stream; ready phase carries endpoint
- fetch.ts: route sandboxStatus to direct onMessage, skillCall to queue
- ChatBox: render sandboxStatus as loading bubble with phase label;
  render skillCall as stepTitle value item
- i18n: add sandbox_status_* and skill_calling keys (zh-CN, en, zh-Hant)

* refactor: Rename MongoAgentSkill to MongoAgentSkills and update references

* feat: Add support for extracting and handling various archive formats

* refactor: Remove markdown field from skill definitions

* refactor: Simplify skill handling and discovery in sandbox

* feat: Update storage and docker configurations for sandbox

* fix: Update storage key prefix in agentSkill module

* refactor: Rename agentSkill to agentSkills across codebase

* feat: Enhance agent skills API with validation and limits

* feat: Add skill size limits and improve package handling

* feat: Add support for custom entrypoints in sandbox configs

* feat: Renew sandbox expiration and support custom images

* feat: Add lazy sandbox init, fetch-user-file tool, and image file support

- Sandbox capability now initializes lazily (no container created until first
  tool call), reducing cold-start latency for conversations without tool usage
- Add sandbox_fetch_user_file tool to allow LLM to download user-uploaded
  files (documents and images) directly into sandbox filesystem
- Extend file input handling to include both document and image type files;
  introduce allFilesMap (all types) alongside filesMap (documents only)
- Preload skill metadata from SKILL.md in ZIP before sandbox creation, so
  system prompt is available without waiting for container startup
- Add executeWithRetry for silent sandbox rebuild on expiry/connection errors
- Add extractSkillMdInfoFromBuffer to read SKILL.md + path from ZIP in-memory
- Fix session artifact storage path: sessions/{id}/projects/ → agent-sessions/{id}/
- Add lazyInit phase to SandboxStatusPhase; pass skillName to
  download/upload/extract i18n keys for clearer progress display

* refactor: replace sandbox TTL lifecycle with status-based instance model

Redesign sandbox persistence layer: replace SkillSandboxSchemaType with
SandboxInstanceSchemaType (fields: appId, userId, chatId, status, lastActiveAt,
nested detail), rename collection from skill_sandbox_info to
agent_sandbox_instances, and add SandboxStatusEnum (running/stopped).

Remove expiry-driven cleanup: delete sandboxCleanup.ts and all TTL-related
fields (expiresAt, timeout, lastActivityTime) and API types (RenewSandbox*).
Add duplicate-name guard in importSkill. Update workflow dispatch, API routes,
tests, and mocks to align with the new schema.

* chore: add skill folder/directory support

* feat(agent-skills): integrate AI-assisted SKILL.md generation into create API

* refactor(sandbox): migrate to @fastgpt-sdk/sandbox-adapter and add multi-provider support

- Replace @anyany/sandbox_provider imports with @fastgpt-sdk/sandbox-adapter across
  sandboxController, lifecycle, and types
- Add SealosDevbox as a second supported provider alongside OpenSandbox,
  with discriminated-union typed configs (OpenSandboxProviderConfig /
  SealosDevboxProviderConfig)
- Centralize provider adapter construction in sandboxConfig:
  buildSandboxAdapter, connectToProviderSandbox,
  disconnectFromProviderSandbox, getProviderSandboxEndpoint,
  selectSandboxEntrypoint
- Migrate sandbox.resume() → sandbox.start() per updated SDK contract
- Add unit tests for new sandboxConfig provider helpers
- Fix vitest path aliases; add zip to sandbox-sync-agent Dockerfile

* feat(agent-skills): add skill export/download API

* feat(agent-skills): harden export API and add debug chat/session endpoints

- Replace authUserPer with authSkill + ReadPermissionVal in export handler
- Add EXPORT_SKILL audit event and i18n keys (en/zh-CN/zh-Hant)
- Add AGENT_SKILLS.EXPORT logger category
- Add debug chat and debug session (list/delete) API routes with tests
- Update export tests to match new authSkill-based error behavior

* feat(agent-skills): add skillId filter for apps and skill binding in chat agent form

* feat: Add skill debug session records API functionality

* refactor: Migrate agent skills API types to Zod schemas

* feat: Migrate agentSkills API to OpenAPI specification

* feat: Add internationalization support for agent skills

* refactor: Refactor sandbox tool descriptions and environment vars

* refactor: Rename version-related files and update imports

---------

Co-authored-by: chanzhi82020 <chenzhi@sangfor.com.cn>
Introduces a new standalone Bun/Hono microservice that manages sandbox
volumes across Docker and Kubernetes runtimes. Supports ensure/remove
operations via a REST API with bearer token auth, and includes unit tests
and K8s deployment manifest.
- Remove Dockerfile, Dockerfile.docker-runtime, build.sh, entrypoint scripts,
  http_server.py, supervisord.conf, sync.sh, pool-skill-sandbox.yaml
- Update base/Dockerfile: switch default USER from sandbox to root
- Remove MinIO/sync-agent data persistence dependency from sandbox lifecycle
- Integrate volume-manager HTTP API to create and mount PVC volumes per session
- Simplify SandboxDefaults.entrypoint from multi-key object to single string
- Replace buildDockerSyncEnv/selectSandboxEntrypoint with buildVolumeConfig/buildBaseContainerEnv
- Add VOLUME_MANAGER_URL/TOKEN/MOUNT_PATH env vars and AGENT_SANDBOX_ENTRYPOINT
- Add useServerProxy support for opensandbox provider config
- Relax volume-manager sessionId validation from 24-char hex to DNS label format
- Unset FastGPT runtime env vars in entrypoint.sh after reading
…grate to named volumes

- Add opensandbox-server service with TOML config (runtime, egress, docker security settings)
- Add volume-manager service for PVC/volume lifecycle management
- Rename sandbox container to fastgpt-code-sandbox for consistency
- Migrate all bind mounts (pg, mongo, redis, minio, aiproxy_pg) to Docker named volumes
- Add healthcheck for fastgpt-code-sandbox service
- Bump opensandbox-egress version from v1.0.1 to v1.0.3
- Update port comments to include opensandbox-server:8090 and volume-manager:3004
This commit introduces comprehensive support for managing and utilizing skills within the application, including:

**Skill Management:**
- **New Skill Module:** A dedicated module for creating, importing, exporting, and managing skills.
- **Skill CRUD Operations:** Implemented APIs for creating, reading, updating, deleting, and copying skills.
- **Folder Structure:** Support for organizing skills into folders with hierarchical navigation.
- **Permissions:** Basic permission settings for skills and folders.
- **AI-driven Skill Generation:** Enables AI to generate skill outlines and frameworks based on user requirements.
- **Import/Export:** Functionality to import skills from zip archives and export them.
- **Related App Tracking:** Displays the number of applications that reference a specific skill.
- **Skill Sandbox:** Integration with a sandbox environment for debugging and testing skills, providing real-time logs and an iframe for interaction.

**Workflow Integration:**
- **Agent Node Enhancement:** The Agent node in the workflow editor now supports selecting and configuring skills.
- **Input Type for Skills:** Introduced `selectSkill` as a new input type for workflow nodes, allowing users to select skills.
- **Skill Selection in UI:** Implemented UI components for selecting skills in both application editing and workflow node configuration.
- **Data Normalization:** Added a utility function `normalizeSkillIds` to handle different formats of skill input (string IDs vs. full objects).
- **API Updates:** Modified relevant APIs to accommodate skill selection and management.

**UI/UX Improvements:**
- **Dashboard Navigation:** Added "Skill" to the dashboard navigation.
- **App Detail Page:** Integrated skill selection into the Chat Agent configuration on the app detail page.
- **Workflow Node Templates:** Added the Agent node template to the workflow editor.
- **Publish Link Settings:** Added an option to display skill references in published apps.
- **Translation Updates:** Included new translations for skill-related features in multiple languages.
- Fix typo: SandboxStatusEnum.stoped -> SandboxStatusEnum.stopped
- Move SandboxStatusEnum to ai/sandbox/constants as canonical source
- Upgrade sandbox-adapter to ^0.0.31, rename Volume type to OpenSandboxVolume
- Add connect check before stopping opensandbox instance to prevent errors
- Fix dispatchRunAgent to include answerText in return data
- Update tests to reflect corrected status value
@chanzhi82020 chanzhi82020 force-pushed the fix/conflict-agent-skill-dev-into-main branch from bb931a5 to 2cd746b Compare March 25, 2026 08:02
@chanzhi82020 chanzhi82020 marked this pull request as ready for review March 25, 2026 08:09
@github-actions
Copy link
Copy Markdown

Build Successful - Preview sandbox Image for this PR:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:sandbox_2cd746bfde100a814f3481d211aa5c55e974c7db

@github-actions
Copy link
Copy Markdown

Build Successful - Preview fastgpt Image for this PR:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fastgpt_2cd746bfde100a814f3481d211aa5c55e974c7db

@github-actions
Copy link
Copy Markdown

Build Successful - Preview mcp_server Image for this PR:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:mcp_server_2cd746bfde100a814f3481d211aa5c55e974c7db

@chanzhi82020 chanzhi82020 marked this pull request as draft March 25, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants