feat(ai): Agent→Skill→Tool three-tier metadata protocol#1019
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…nt-Skill-Tool architecture) - Add ToolSchema, ToolCategorySchema, defineTool() in src/ai/tool.zod.ts - Add SkillSchema, SkillTriggerConditionSchema, defineSkill() in src/ai/skill.zod.ts - Add skills[] and permissions[] fields to AgentSchema (backward-compatible) - Register 'tool' and 'skill' in MetadataTypeSchema and DEFAULT_METADATA_TYPE_REGISTRY - Export defineTool, defineSkill, Tool, Skill from root and ai subpath - Add comprehensive tests for tool.test.ts and skill.test.ts - Update metadata-plugin and agent tests for new types - Update CHANGELOG.md Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/c58c45d8-c7be-4719-9ffb-cef702932ff7 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Introduces first-class Tool and Skill metadata protocols in packages/spec, and refactors the existing AI Agent metadata to primarily reference skills (Agent → Skill → Tool), while keeping legacy inline tools for backward compatibility.
Changes:
- Added new AI metadata schemas + factories:
ToolSchema/defineTool()andSkillSchema/defineSkill(), with unit tests. - Updated
AgentSchemato supportskills: string[](primary) andpermissions: string[], retaining legacytools. - Registered new metadata kinds (
tool,skill) in the kernel metadata type registry and exported them from@objectstack/specand@objectstack/spec/ai.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/kernel/metadata-plugin.zod.ts | Adds tool/skill to MetadataTypeSchema and DEFAULT_METADATA_TYPE_REGISTRY with load ordering. |
| packages/spec/src/kernel/metadata-plugin.test.ts | Updates tests to include the new metadata types and domain assertions. |
| packages/spec/src/index.ts | Re-exports defineTool, defineSkill, and Tool/Skill types at the root package entrypoint. |
| packages/spec/src/ai/tool.zod.ts | Introduces ToolSchema + ToolCategorySchema and defineTool() factory. |
| packages/spec/src/ai/tool.test.ts | Adds unit tests for tool schema validation and defaults. |
| packages/spec/src/ai/skill.zod.ts | Introduces SkillSchema + trigger condition schema and defineSkill() factory. |
| packages/spec/src/ai/skill.test.ts | Adds unit tests for skill schema validation and defaults. |
| packages/spec/src/ai/index.ts | Re-exports tool/skill schemas from the AI subpath. |
| packages/spec/src/ai/agent.zod.ts | Adds skills and permissions fields; documents skill-based architecture while keeping legacy tools. |
| packages/spec/src/ai/agent.test.ts | Adds coverage for agents using skills, hybrid skills+tools, and permissions. |
| packages/spec/CHANGELOG.md | Documents the new Agent/Skill/Tool protocol and exports. |
| /** | ||
| * References to tool names that belong to this skill. | ||
| * Tools must be registered as first-class metadata (type: 'tool'). | ||
| */ | ||
| tools: z.array(z.string()).describe('Tool names belonging to this skill'), | ||
|
|
There was a problem hiding this comment.
SkillSchema.tools is a list of tool name references, but it currently allows any string. Since ToolSchema.name enforces snake_case, this should validate the same pattern (or reuse a shared schema) so invalid references are caught at parse-time rather than failing later during tool resolution.
| tools: z.array(AIToolSchema).optional().describe('Available tools'), | ||
|
|
||
| /** Capabilities — Skill-based (primary) */ | ||
| skills: z.array(z.string()).optional().describe('Skill names to attach (Agent→Skill→Tool architecture)'), |
There was a problem hiding this comment.
AgentSchema.skills is intended to reference SkillSchema.name values (snake_case), but it currently allows any string. Validating the same snake_case pattern here would prevent invalid skill references from passing schema validation and failing later at runtime.
| skills: z.array(z.string()).optional().describe('Skill names to attach (Agent→Skill→Tool architecture)'), | |
| skills: z | |
| .array(z.string().regex(/^[a-z_][a-z0-9_]*$/)) | |
| .optional() | |
| .describe('Skill names to attach (Agent→Skill→Tool architecture)'), |
|
@copilot fix all |
- SkillSchema.tools now validates snake_case pattern for tool name references - AgentSchema.skills now validates snake_case pattern for skill name references - Added tests for snake_case enforcement on both references Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/5cefdc4a-fa65-4b56-876d-3ca34809f7b3 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Fixed both review comments in
|
Current
agent.zod.tstreats tools as inline references only. Industry standard (Salesforce Agentforce, Copilot Studio, ServiceNow) uses Agent→Skill→Tool: Tool as first-class metadata, Skill as reusable ability group, Agent as lightweight config referencing skills.New protocols
src/ai/tool.zod.ts—ToolSchemawith JSON Schema parameters/outputSchema, category enum, objectName binding, requiresConfirmation, permissions, builtIn flag.defineTool()factory.src/ai/skill.zod.ts—SkillSchemaaggregating tool references by domain. Supportsinstructions(injected into system prompt),triggerPhrases(intent matching),triggerConditions(programmatic activation via field/operator/value).defineSkill()factory.Agent refactoring
skills: string[]as primary capability modeltools: AIToolSchema[]retained as backward-compatible fallbackpermissions: string[]for access controlMetadata registry
toolandskilladded toMetadataTypeSchemaenum andDEFAULT_METADATA_TYPE_REGISTRY**/*.tool.{ts,yml},**/*.skill.{ts,yml}Usage