fix(tools): return structured error objects from skill tool validation failures

Convert Error throws and plain-string returns in skill-mcp and call-omo-agent tools into structured objects with { output, metadata: { kind } }.

call-omo-agent uses 'unsupported_agents_action' kind for agent validation errors.
skill-mcp uses 'unsupported_mcp_action' kind for MCP operation validation errors.

This enables callers to distinguish error responses from successful ones by checking metadata.kind rather than parsing error strings.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-25 10:56:51 +09:00
parent 4906d9207a
commit 19ed1b9b83
4 changed files with 139 additions and 73 deletions
+12 -3
View File
@@ -141,7 +141,10 @@ export function createCallOmoAgent(
);
if (typeof args.subagent_type !== "string" || args.subagent_type.trim() === "") {
return "Error: subagent_type is required."
return {
output: "Error: subagent_type is required.",
metadata: { kind: "unsupported_agents_action" },
}
}
const callableAgents = await resolveCallableAgents(ctx.client);
@@ -153,7 +156,10 @@ export function createCallOmoAgent(
(name) => name.toLowerCase() === strippedAgentType.toLowerCase(),
)
) {
return `Error: Invalid agent type "${args.subagent_type}". Only ${callableAgents.join(", ")} are allowed.`;
return {
output: `Error: Invalid agent type "${args.subagent_type}". Only ${callableAgents.join(", ")} are allowed.`,
metadata: { kind: "unsupported_agents_action" },
}
}
const normalizedAgent = strippedAgentType.toLowerCase();
@@ -161,7 +167,10 @@ export function createCallOmoAgent(
// Check if agent is disabled
if (disabledAgents.some((disabled) => stripInvisibleAgentCharacters(disabled).toLowerCase() === normalizedAgent)) {
return `Error: Agent "${normalizedAgent}" is disabled via disabled_agents configuration. Remove it from disabled_agents in your ${CONFIG_BASENAME}.json to use it.`
return {
output: `Error: Agent "${normalizedAgent}" is disabled via disabled_agents configuration. Remove it from disabled_agents in your ${CONFIG_BASENAME}.json to use it.`,
metadata: { kind: "unsupported_agents_action" },
}
}
const { model: resolvedModel, fallbackChain } = resolveModelAndFallbackChain({