Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: fix some skill issues (#42389)
wangxiaolei0825e6ca515e
diff --git a/api/services/skill_management_service.py b/api/services/skill_management_service.pyindex cb2df162927..b0731b82f3f 100644--- a/api/services/skill_management_service.py+++ b/api/services/skill_management_service.py@@ -60,6 +60,7 @@ from models.account import Accountfrom models.agent import (Agent,AgentConfigDraft,+ AgentConfigDraftType,AgentConfigSnapshot,AgentKind,AgentScope,@@ -2638,36 +2639,35 @@ class SkillManagementService:)))- configured_names: set[str] = set()- snapshot = session.scalar(- select(AgentConfigSnapshot).where(- AgentConfigSnapshot.tenant_id == tenant_id,- AgentConfigSnapshot.agent_id == agent_id,- AgentConfigSnapshot.id- == select(Agent.active_config_snapshot_id)- .where(Agent.tenant_id == tenant_id, Agent.id == agent_id)- .scalar_subquery(),- )- )- if snapshot is not None:- configured_names.update(- skill.name- for skill in AgentSoulConfig.model_validate(snapshot.config_snapshot_dict).config_skills- if not skill.is_missing- )- drafts = session.scalars(+ # Bindings are edited against the normal draft, including unpublished removals.+ config: AgentConfigDraft | AgentConfigSnapshot | None = session.scalar(select(AgentConfigDraft).where(AgentConfigDraft.tenant_id == tenant_id,AgentConfigDraft.agent_id == agent_id,+ AgentConfigDraft.draft_type == AgentConfigDraftType.DRAFT,+ AgentConfigDraft.account_id.is_(None),))- for draft in drafts:- configured_names.update(+ if config is None:+ config = session.scalar(+ select(AgentConfigSnapshot).where(+ AgentConfigSnapshot.tenant_id == tenant_id,+ AgentConfigSnapshot.agent_id == agent_id,+ AgentConfigSnapshot.id+ == select(Agent.active_config_snapshot_id)+ .where(Agent.tenant_id == tenant_id, Agent.id == agent_id)+ .scalar_subquery(),+ )+ )+ configured_names = (+ {skill.name- for skill in AgentSoulConfig.model_validate(draft.config_snapshot_dict).config_skills+ for skill in AgentSoulConfig.model_validate(config.config_snapshot_dict).config_skillsif not skill.is_missing- )-+ }+ if config is not None+ else set()+ )conflicts = sorted(set(selected_skill_names) & (configured_names - current_bound_names))if conflicts:raise SkillManagementServiceError(diff --git a/api/tests/unit_tests/services/test_skill_management_service.py b/api/tests/unit_tests/services/test_skill_management_service.pyindex 8bdb7503dcc..951c7147a36 100644--- a/api/tests/unit_tests/services/test_skill_management_service.py+++ b/api/tests/unit_tests/services/test_skill_management_service.py@@ -1150,6 +1150,80 @@ def test_replace_agent_bindings_rejects_skill_name_conflict_with_agent_config_skassert exc_info.value.details == {"names": ["finance-sop"]}+ ("snapshot_has_skill", "draft_has_skill", "debug_has_skill", "expect_conflict"),+ [+ (True, False, False, False),+ (True, False, True, False),+ (False, True, False, True),+ (True, True, False, True),+ (False, None, True, False),+ (True, None, True, True),+ ],+)+def test_replace_agent_bindings_checks_editable_config(+ snapshot_has_skill: bool,+ draft_has_skill: bool | None,+ debug_has_skill: bool,+ expect_conflict: bool,+) -> None:+ service = SkillManagementService(tool_file_manager=_FakeToolFileManager())+ created = service.create_skill(tenant_id=TENANT, user_id=USER, payload=SkillCreatePayload(name="finance-sop"))+ skill_ref = AgentConfigSkillRefConfig(name="finance-sop", description="Embedded skill.", file_id="tool-file-1")+ with session_factory.create_session() as session:+ snapshot = AgentConfigSnapshot(+ tenant_id=TENANT,+ agent_id=AGENT,+ version=1,+ config_snapshot=AgentSoulConfig(config_skills=[skill_ref] if snapshot_has_skill else []),+ created_by=USER,+ )+ session.add(snapshot)+ session.flush()+ agent = session.get(Agent, AGENT)+ assert agent is not None+ agent.active_config_snapshot_id = snapshot.id+ if draft_has_skill is not None:+ session.add(+ AgentConfigDraft(+ tenant_id=TENANT,+ agent_id=AGENT,+ draft_type=AgentConfigDraftType.DRAFT,+ account_id=None,+ draft_owner_key="",+ base_snapshot_id=snapshot.id,+ config_snapshot=AgentSoulConfig(config_skills=[skill_ref] if draft_has_skill else []),+ created_by=USER,+ )+ )+ if debug_has_skill:+ session.add(+ AgentConfigDraft(+ tenant_id=TENANT,+ agent_id=AGENT,+ draft_type=AgentConfigDraftType.DEBUG_BUILD,+ account_id=USER,+ draft_owner_key=USER,+ base_snapshot_id=snapshot.id,+ config_snapshot=AgentSoulConfig(config_skills=[skill_ref]),+ created_by=USER,+ )+ )+ session.commit()++ if expect_conflict:+ with pytest.raises(SkillManagementServiceError) as exc_info:+ service.replace_agent_bindings(tenant_id=TENANT, user_id=USER, agent_id=AGENT, skill_ids=[created["id"]])+ assert exc_info.value.code == "agent_skill_name_conflict"+ assert exc_info.value.details == {"names": ["finance-sop"]}+ else:+ result = service.replace_agent_bindings(+ tenant_id=TENANT, user_id=USER, agent_id=AGENT, skill_ids=[created["id"]]+ )+ assert result["skill_ids"] == [created["id"]]+ assert service.list_agent_bindings(tenant_id=TENANT, agent_id=AGENT)["data"][0]["id"] == created["id"]++def test_replace_agent_bindings_allows_existing_bound_workspace_skill_name_in_agent_config() -> None:service = SkillManagementService(tool_file_manager=_FakeToolFileManager())created = service.create_skill(tenant_id=TENANT, user_id=USER, payload=SkillCreatePayload(name="finance-sop"))diff --git a/web/features/skills/detail/skill-metadata.tsx b/web/features/skills/detail/skill-metadata.tsxindex 16a167c9d81..461d7e895a2 100644--- a/web/features/skills/detail/skill-metadata.tsx+++ b/web/features/skills/detail/skill-metadata.tsx@@ -564,7 +564,12 @@ function SkillReferenceItem({}/></span>- <span className="max-w-63 min-w-0 flex-1 truncate system-sm-regular text-text-secondary">+ <span+ className={cn(+ 'min-w-0 flex-1 truncate system-sm-regular text-text-secondary',+ !compact && 'max-w-63',+ )}+ >{workflowName}</span><spandiff --git a/web/service/console/client.spec.ts b/web/service/console/client.spec.tsindex 17b7cc7ccf8..d065ba52279 100644--- a/web/service/console/client.spec.ts+++ b/web/service/console/client.spec.ts@@ -2017,3 +2017,69 @@ describe('consoleQuery apiBasedExtension mutation defaults', () => {expect(queryClient.getQueryData(listKey)).toEqual([remainingExtension])})})++describe('workspace skill deletion cache', () => {+ it.each([true, false])('refreshes agent bindings after deletion (active: %s)', async (active) => {+ const consoleQuery = await loadConsoleQuery()+ const client = new QueryClient({+ defaultOptions: { queries: { staleTime: Infinity, retry: false } },+ })+ const input = { params: { agent_id: 'agent-1' } }+ const queryKey = consoleQuery.workspaces.current.agents.byAgentId.skills.get.queryKey({ input })+ const previousBindings = { agent_id: 'agent-1', skill_ids: ['skill-1'], data: [] }+ const emptyBindings = { agent_id: 'agent-1', skill_ids: [], data: [] }+ client.setQueryData(queryKey, previousBindings)+ const queryFn = vi.fn(async () => emptyBindings)+ const observer = new QueryObserver(client, { queryKey, queryFn })+ let unsubscribe = active ? observer.subscribe(() => {}) : undefined+ const onSuccess = vi.fn()+ const mutation = new MutationObserver(+ client,+ consoleQuery.workspaces.current.skills.bySkillId.delete.mutationOptions({+ mutationFn: async () => ({ id: 'skill-1', deleted: true }),+ onSuccess,+ }),+ )++ try {+ await mutation.mutate({+ params: { skill_id: 'skill-1' },+ body: { confirmation_name: 'Skill' },+ })+ if (!active) unsubscribe = observer.subscribe(() => {})+ await vi.waitFor(() => expect(observer.getCurrentResult().data).toEqual(emptyBindings))+ expect(queryFn).toHaveBeenCalledTimes(1)+ expect(onSuccess).toHaveBeenCalledTimes(1)+ } finally {+ unsubscribe?.()+ client.clear()+ }+ })++ it('preserves cached bindings when deletion fails', async () => {+ const consoleQuery = await loadConsoleQuery()+ const client = new QueryClient()+ const queryKey = consoleQuery.workspaces.current.agents.byAgentId.skills.get.queryKey({+ input: { params: { agent_id: 'agent-1' } },+ })+ const bindings = { agent_id: 'agent-1', skill_ids: ['skill-1'], data: [] }+ client.setQueryData(queryKey, bindings)+ const mutation = new MutationObserver(+ client,+ consoleQuery.workspaces.current.skills.bySkillId.delete.mutationOptions({+ mutationFn: async () => {+ throw new Error('Deletion failed')+ },+ }),+ )+ try {+ await expect(mutation.mutate({ params: { skill_id: 'skill-1' }, body: {} })).rejects.toThrow(+ 'Deletion failed',+ )+ expect(client.getQueryData(queryKey)).toEqual(bindings)+ expect(client.getQueryState(queryKey)?.isInvalidated).toBe(false)+ } finally {+ client.clear()+ }+ })+})diff --git a/web/service/console/query-policies.ts b/web/service/console/query-policies.tsindex 48f35dc0e72..4838d3e9282 100644--- a/web/service/console/query-policies.ts+++ b/web/service/console/query-policies.ts@@ -15,6 +15,20 @@ export function createConsoleQuery(consoleClient: ConsoleClient) {experimental_defaults: {workspaces: {current: {+ skills: {+ bySkillId: {+ delete: {+ mutationOptions: {+ onSettled: (_data, error, _variables, _result, context) => {+ if (error) return+ return context.client.invalidateQueries({+ queryKey: consoleQuery.workspaces.current.agents.byAgentId.skills.get.key(),+ })+ },+ },+ },+ },+ },rbac: {accessPolicies: {post: {