MCPcopy Create free account
hub / github.com/Noumena-Network/code / executeForkedSkill

Function executeForkedSkill

src/tools/SkillTool/SkillTool.ts:123–290  ·  view source on GitHub ↗

* Executes a skill in a forked sub-agent context. * This runs the skill prompt in an isolated agent with its own token budget.

(
  command: Command & { type: 'prompt' },
  commandName: string,
  args: string | undefined,
  context: ToolUseContext,
  canUseTool: CanUseToolFn,
  parentMessage: AssistantMessage,
  onProgress?: ToolCallProgress<Progress>,
)

Source from the content-addressed store, hash-verified

121 * This runs the skill prompt in an isolated agent with its own token budget.
122 */
123async function executeForkedSkill(
124 command: Command & { type: 'prompt' },
125 commandName: string,
126 args: string | undefined,
127 context: ToolUseContext,
128 canUseTool: CanUseToolFn,
129 parentMessage: AssistantMessage,
130 onProgress?: ToolCallProgress<Progress>,
131): Promise<ToolResult<Output>> {
132 const startTime = Date.now()
133 const agentId = createAgentId()
134 const isBuiltIn = builtInCommandNames().has(commandName)
135 const isOfficialSkill = isOfficialMarketplaceSkill(command)
136 const isBundled = command.source === 'bundled'
137 const forkedSanitizedName =
138 isBuiltIn || isBundled || isOfficialSkill ? commandName : 'custom'
139
140 const wasDiscoveredField =
141 feature('EXPERIMENTAL_SKILL_SEARCH') &&
142 remoteSkillModules!.isSkillSearchEnabled()
143 ? {
144 was_discovered:
145 context.discoveredSkillNames?.has(commandName) ?? false,
146 }
147 : {}
148 const pluginMarketplace = command.pluginInfo
149 ? parsePluginIdentifier(command.pluginInfo.repository).marketplace
150 : undefined
151 const queryDepth = context.queryTracking?.depth ?? 0
152 const parentAgentId = getAgentContext()?.agentId
153 logEvent('ncode_skill_tool_invocation', {
154 command_name:
155 forkedSanitizedName as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
156 // _PROTO_skill_name routes to the privileged skill_name BQ column
157 // (unredacted, all users); command_name stays in additional_metadata as
158 // the redacted variant for general-access dashboards.
159 _PROTO_skill_name:
160 commandName as AnalyticsMetadata_I_VERIFIED_THIS_IS_PII_TAGGED,
161 execution_context:
162 'fork' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
163 invocation_trigger: (queryDepth > 0
164 ? 'nested-skill'
165 : 'claude-proactive') as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
166 query_depth: queryDepth,
167 ...(parentAgentId && {
168 parent_agent_id:
169 parentAgentId as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
170 }),
171 ...wasDiscoveredField,
172 ...(isInternalBuild() && {
173 skill_name:
174 commandName as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
175 skill_source:
176 command.source as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
177 ...(command.loadedFrom && {
178 skill_loaded_from:
179 command.loadedFrom as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
180 }),

Callers 1

callFunction · 0.85

Calls 15

createAgentIdFunction · 0.85
parsePluginIdentifierFunction · 0.85
getAgentContextFunction · 0.85
isInternalBuildFunction · 0.85
runAgentFunction · 0.85
normalizeMessagesFunction · 0.85
extractResultTextFunction · 0.85
logEventFunction · 0.70
logForDebuggingFunction · 0.70

Tested by

no test coverage detected