mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 14:04:50 +00:00
fix(agent): prevent agents from accessing disabled skills (#292)
Disabling a skill in the agent config dialog only removed it from the agent_skills join table, but the chat flow still advertised ALL team skills to the model in the <available_skills> system prompt section and the read_skill tool never checked per-agent enablement. - getAgentChatContextActivity / getAgentAutofillContextActivity now only return skills explicitly enabled for the agent (agent_skills), and expose enabledSkillIds in the execution context. - createReadSkillTool accepts enabledSkillIds and rejects read_skill calls for skills not enabled for the agent, even if the model knows the skill id from earlier conversation history. - Added unit tests for context filtering (chat + autofill), tool-level enforcement, and the zero-enabled-skills case.
This commit is contained in:
@@ -98,6 +98,7 @@ export interface CreateAgentSessionParams {
|
||||
modelId: string
|
||||
systemPrompt: string
|
||||
teamSkills: Array<{ id: string; name: string; description?: string | null }>
|
||||
enabledSkillIds?: string[]
|
||||
allowedDomains: string[]
|
||||
sessionId?: string
|
||||
userId?: string
|
||||
@@ -145,6 +146,7 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
|
||||
modelId,
|
||||
systemPrompt,
|
||||
teamSkills,
|
||||
enabledSkillIds,
|
||||
allowedDomains,
|
||||
sessionId,
|
||||
userId,
|
||||
@@ -313,7 +315,12 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
|
||||
next.map((t) => t.name),
|
||||
)
|
||||
}
|
||||
const readSkill = createReadSkillTool(userId, onEnvsAdded, restricted ? onSkillLoaded : undefined)
|
||||
const readSkill = createReadSkillTool(
|
||||
userId,
|
||||
onEnvsAdded,
|
||||
restricted ? onSkillLoaded : undefined,
|
||||
enabledSkillIds,
|
||||
)
|
||||
|
||||
const systemTools: AgentTool[] = []
|
||||
if (userId) {
|
||||
|
||||
Reference in New Issue
Block a user