Skip to content

feat(skill): add per-skill auto_sync toggle to control git sync on startup#156

Open
niiish32x wants to merge 7 commits intoderisk-ai:mainfrom
niiish32x:fix/nsh_skill_sync_20260311
Open

feat(skill): add per-skill auto_sync toggle to control git sync on startup#156
niiish32x wants to merge 7 commits intoderisk-ai:mainfrom
niiish32x:fix/nsh_skill_sync_20260311

Conversation

@niiish32x
Copy link
Contributor

Description

feat(skill): add per-skill auto_sync toggle to control git sync on startup
This change allows users to disable automatic git synchronization for
individual skills, which is particularly useful for users in regions
with slow access to GitHub (e.g., China).

Backend Changes:

  • Add auto_sync column to skill table (Boolean, default: true)
  • Update SkillRequest/SkillResponse schemas to include auto_sync field
  • Add POST /{skill_code}/auto_sync endpoint to toggle auto_sync setting
  • Update sync logic to skip skills with auto_sync=false (unless force_update)
  • Add global enable_default_skill_sync config to disable all auto-sync
  • Preserve existing auto_sync settings when updating skills from git

Frontend Changes:

  • Add updateSkillAutoSync API client method
  • Add toggle switch to skill cards in agent-skills page
  • Show cloud sync icon (blue when enabled, gray when disabled)
  • Only show toggle for skills from git repositories

Database Migration:

  • Add Alembic migration: 20260310201723_add_auto_sync_to_skill.py
  • Provide SQL script for manual migration

Usage:

  • Per-skill: Toggle "Auto Sync" switch in Agent Skills page
  • Global: Set enable_default_skill_sync = false in config

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Snapshots:

Include snapshots for easier review.

Checklist:

  • My code follows the style guidelines of this project
  • I have already rebased the commits and make the commit message conform to the project standard.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

越鸿 and others added 6 commits March 9, 2026 17:52
Root cause: when the LLM responded with plain text (no tool_calls) in a
function-calling session, the next iteration still built history pairs of
  assistant(tool_calls=null) → tool(tool_call_id=...)
which violates the OpenAI-compatible API contract and produces:
  "messages with role 'tool' must be a response to a preceeding message
   with 'tool_calls'"

Fix (base_agent.py):
- `function_callning_reply_messages`: skip appending tool-result messages
  when the preceding assistant message has no tool_calls, preventing the
  invalid sequence from being produced in the first place.
- `_sanitize_tool_messages`: new helper that scrubs any remaining orphaned
  tool messages from the final LLM message list immediately before the API
  call, acting as a last-resort safety net.
… creation

  When an MCP resource is rebound (deleted and recreated with a new code/name),
  the old resource instance remains registered but no longer matches the new
  configuration. Previously, this caused a ValueError to be thrown, breaking
  the entire agent initialization.

  Changes:
  - When registered instances exist but none match the requested resource,
    fall back to dynamic resource creation using the configuration value
  - Properly catch MCPNotFoundError in both matching and dynamic creation
    paths, returning None to allow graceful degradation
  - Filter out None entries in build_resource() and a_build_resource() to
    prevent unavailable MCPs from breaking agent loading

  This ensures that when an MCP is rebound, the agent can still initialize
  by creating a new resource instance from the updated configuration.
…tartup

  This change allows users to disable automatic git synchronization for
  individual skills, which is particularly useful for users in regions
  with slow access to GitHub (e.g., China).

  Backend Changes:
  - Add `auto_sync` column to skill table (Boolean, default: true)
  - Update SkillRequest/SkillResponse schemas to include auto_sync field
  - Add POST /{skill_code}/auto_sync endpoint to toggle auto_sync setting
  - Update sync logic to skip skills with auto_sync=false (unless force_update)
  - Add global `enable_default_skill_sync` config to disable all auto-sync
  - Preserve existing auto_sync settings when updating skills from git

  Frontend Changes:
  - Add updateSkillAutoSync API client method
  - Add toggle switch to skill cards in agent-skills page
  - Show cloud sync icon (blue when enabled, gray when disabled)
  - Only show toggle for skills from git repositories

  Database Migration:
  - Add Alembic migration: 20260310201723_add_auto_sync_to_skill.py
  - Provide SQL script for manual migration

  Usage:
  - Per-skill: Toggle "Auto Sync" switch in Agent Skills page
  - Global: Set `enable_default_skill_sync = false` in config
yhjun1026
yhjun1026 previously approved these changes Mar 11, 2026
Copy link
Collaborator

@yhjun1026 yhjun1026 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

Copy link
Contributor

@csunny csunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR introduces a per-skill auto_sync toggle feature and includes two additional bug fixes.

Key Changes

1. Feature: Per-skill auto_sync toggle (d688cbb)

  • Backend: Adds auto_sync column to skill table with new POST /{skill_code}/auto_sync endpoint
  • Frontend: Toggle switch in Agent Skills page with visual sync icon indicators
  • Config: Global enable_default_skill_sync option to disable all auto-sync

2. Bug Fix: Orphaned tool-role message (a838338)

  • Fixes API 400 errors when LLM responds without tool_calls in function-calling sessions
  • Adds _sanitize_tool_messages() helper to scrub orphaned tool messages

3. Bug Fix: MCP rebind handling (6ff3f81)

  • Gracefully handles MCP resource rebind scenarios (deleted/recreated with new code)
  • Returns None instead of crashing on unavailable MCPs

Minor Suggestions (Non-blocking)

Area Issue
Logging Excessive logger.info() statements in _base_dao.py should be removed or changed to debug level
Code Duplication update_auto_sync endpoint manually copies 15+ fields - consider using model_dump(exclude_none=True)

Verdict

Approved - The feature is well-structured and addresses a real user pain point (slow GitHub access). Bug fixes are solid and defensive.

Copy link
Collaborator

@yhjun1026 yhjun1026 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants