Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/core/src/subagents/subagent-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,15 @@ export class SubagentManager {
tools: toolNames,
};
}
if (config.skills && config.tools.length > 0){
if(toolConfig){
toolConfig.skills = config.skills
}else{
toolConfig = {
skills: config.skills
}
}
}

return {
promptConfig,
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/subagents/subagent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ToolConfirmationOutcome,
ToolCallConfirmationDetails,
} from '../tools/tools.js';
import {type SkillTool} from '../tools/skill.js'
import { getInitialChatHistory } from '../utils/environmentContext.js';
import type {
Content,
Expand Down Expand Up @@ -287,8 +288,10 @@
// If no explicit toolConfig or it contains "*" or is empty, inherit all tools.
const toolsList: FunctionDeclaration[] = [];
if (this.toolConfig) {
let visible_skills = this.toolConfig.skills?.length>0;

Check failure on line 291 in packages/core/src/subagents/subagent.ts

View workflow job for this annotation

GitHub Actions / Lint

'visible_skills' is never reassigned. Use 'const' instead

const asStrings = this.toolConfig.tools.filter(
(t): t is string => typeof t === 'string',
(t): t is string => typeof t === 'string' && (!visible_skills || t !== SkillTool.Name),
);
const hasWildcard = asStrings.includes('*');
const onlyInlineDecls = this.toolConfig.tools.filter(
Expand All @@ -305,6 +308,10 @@
toolsList.push(
...toolRegistry.getFunctionDeclarationsFiltered(asStrings),
);

if (visible_skills){
toolsList.push(SkillTool(this.runtimeContext, visible_skills).schema)
}
}
toolsList.push(...onlyInlineDecls);
} else {
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/subagents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
*/
tools?: string[];

/**
* Optional list of skills names that this subagent is allowed to use.
* If omitted, the subagent inherits all avaiable skills.
*/
skills?: string[];

/**
* System prompt content that defines the subagent's behavior.
* Supports ${variable} templating via ContextState.
Expand Down Expand Up @@ -230,6 +236,10 @@
* that the subagent is permitted to use.
*/
tools: Array<string | FunctionDeclaration>;
/**
* If skills is specified seperately, ignore skills in tools, but take `skills` field to be visible for the subagent.
*/
skills: Array<string>;

Check failure on line 242 in packages/core/src/subagents/types.ts

View workflow job for this annotation

GitHub Actions / Lint

Array type using 'Array<string>' is forbidden for simple types. Use 'string[]' instead
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/tools/skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
private skillManager: SkillManager;
private availableSkills: SkillConfig[] = [];

constructor(private readonly config: Config) {
constructor(private readonly config: Config, private readonly visible_skills?: Array<string>) {

Check failure on line 34 in packages/core/src/tools/skill.ts

View workflow job for this annotation

GitHub Actions / Lint

Array type using 'Array<string>' is forbidden for simple types. Use 'string[]' instead
// Initialize with a basic schema first
const initialSchema = {
type: 'object',
Expand Down Expand Up @@ -100,6 +100,7 @@
'No skills are currently configured. Skills can be created by adding directories with SKILL.md files to .qwen/skills/ or ~/.qwen/skills/.';
} else {
skillDescriptions = this.availableSkills
.filter((skill) => (self.visible_skills?.length>0) ? self.visible_skills.includes(skill.name) : true)
.map(
(skill) => `<skill>
<name>
Expand Down
Loading