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:
Yiling-J
2026-08-10 17:33:40 +08:00
committed by GitHub
parent 49ef48a74a
commit 1daeaf51ef
6 changed files with 361 additions and 12 deletions
+8 -1
View File
@@ -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) {