MCPcopy Create free account
hub / github.com/github/gh-aw / loadMissingToolMessages

Function loadMissingToolMessages

actions/setup/js/handle_agent_failure.cjs:1269–1302  ·  view source on GitHub ↗

* Load missing_tool messages from agent output. * Returns an empty array when the output file doesn't exist, cannot be parsed, or has no missing_tool items. * @param {Array } [items] - Optional pre-loaded agent output items. When provided, avoids re-reading the output file. * @returns {Array<

(items)

Source from the content-addressed store, hash-verified

1267 * @returns {Array<{tool: string|null, reason: string, alternatives?: string|null, denied_commands: Array<string>}>} Array of missing tool messages
1268 */
1269function loadMissingToolMessages(items) {
1270 try {
1271 let resolvedItems = items;
1272 if (!resolvedItems) {
1273 const { loadAgentOutput } = require("./load_agent_output.cjs");
1274 const agentOutputResult = loadAgentOutput();
1275 if (!agentOutputResult.success || !agentOutputResult.items) {
1276 return [];
1277 }
1278 resolvedItems = agentOutputResult.items;
1279 }
1280
1281 const missingToolMessages = [];
1282 for (const item of resolvedItems) {
1283 if (item.type === "missing_tool") {
1284 if (item.reason) {
1285 const deniedCommandsFromItem = Array.isArray(item.denied_commands) ? item.denied_commands.filter(cmd => typeof cmd === "string" && cmd.trim()) : [];
1286 const deniedCommands = deniedCommandsFromItem.length > 0 ? deniedCommandsFromItem : extractDeniedCommandsFromAlternatives(item.alternatives);
1287 missingToolMessages.push({
1288 tool: item.tool || null,
1289 reason: item.reason,
1290 alternatives: item.alternatives || null,
1291 denied_commands: deniedCommands,
1292 });
1293 }
1294 }
1295 }
1296
1297 return missingToolMessages;
1298 } catch (error) {
1299 core.warning(`Failed to load missing_tool messages: ${getErrorMessage(error)}`);
1300 return [];
1301 }
1302}
1303
1304/**
1305 * Determine whether a missing_tool message represents permission denial.

Callers 2

buildMissingToolContextFunction · 0.85

Calls 3

loadAgentOutputFunction · 0.85
getErrorMessageFunction · 0.70

Tested by

no test coverage detected