Skip to main content
Glama
Hive-Academy

π“‚€π“’π“‹Ήπ”Έβ„•π•Œπ”Ήπ•€π•Šπ“‹Ήπ“’π“‚€ - Intelligent Guidance for

by Hive-Academy

execute_transition

Facilitates role transitions by executing transitions, providing execution status, and essential details for next steps. Requires transition ID, task ID, and role ID inputs.

Instructions

Executes role transition and returns execution status with essential details for next steps.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
handoffMessageNoOptional handoff message
roleIdYesRole ID for transition context
taskIdYesTask ID for transition context
transitionIdYesTransition ID to execute

Implementation Reference

  • Zod input schema and inferred TypeScript type for the execute_transition tool.
    const ExecuteTransitionInputSchema = z.object({
      transitionId: z.string().describe('Transition ID to execute'),
      taskId: z.number().describe('Task ID for transition context'),
      roleId: z.string().describe('Role ID for transition context'),
      handoffMessage: z.string().optional().describe('Optional handoff message'),
    });
    type GetRoleTransitionsInput = z.infer<typeof GetRoleTransitionsInputSchema>;
    type ValidateTransitionInput = z.infer<typeof ValidateTransitionInputSchema>;
    type ExecuteTransitionInput = z.infer<typeof ExecuteTransitionInputSchema>;
  • Registration of the execute_transition MCP tool using @Tool decorator with name, description, and schema.
    @Tool({
      name: 'execute_transition',
      description: `Executes role transition and returns execution status with essential details for next steps.`,
      parameters:
        ExecuteTransitionInputSchema as ZodSchema<ExecuteTransitionInput>,
    })
  • Main handler function for execute_transition tool: processes input, calls RoleTransitionService.executeTransition, updates workflow context cache, and returns structured MCP response.
    async executeTransition(input: ExecuteTransitionInput) {
      try {
        const context = {
          taskId: input.taskId.toString(),
          roleId: input.roleId,
        };
    
        const result = await this.roleTransitionService.executeTransition(
          input.transitionId,
          context,
          input.handoffMessage,
        );
    
        // 🧠 UPDATE WORKFLOW CONTEXT CACHE
        // Store latest workflow state after successful transition
        if (result.success && result.newRoleId) {
          try {
            // Try to find existing cache entry to update
            const existingContext = this.workflowContextCache.findContextByTaskId(
              input.taskId,
            );
    
            const cacheKey = existingContext
              ? WorkflowContextCacheService.generateKey(
                  existingContext.executionId,
                  'transition',
                )
              : WorkflowContextCacheService.generateKey(
                  `task-${input.taskId}`,
                  'transition',
                );
    
            this.workflowContextCache.updateContext(cacheKey, {
              currentRoleId: result.newRoleId,
            });
          } catch (_cacheError) {
            // Don't fail transition if cache update fails
          }
        }
    
        // βœ… MINIMAL RESPONSE: Only essential execution data
        return this.buildResponse({
          transitionId: input.transitionId,
          success: result.success,
          status: result.success ? 'completed' : 'failed',
          message: result.message,
          newRoleId: result.newRoleId,
        });
      } catch (error) {
        return this.buildErrorResponse(
          'Failed to execute transition',
          getErrorMessage(error),
          'TRANSITION_EXECUTION_ERROR',
        );
      }
    }
  • Core helper service method implementing the transition logic: validates transition, records it, updates task ownership and workflow execution state.
    async executeTransition(
      transitionId: string,
      context: { roleId: string; taskId: string; projectPath?: string },
      handoffMessage?: string,
    ): Promise<{ success: boolean; message: string; newRoleId?: string }> {
      try {
        // First validate the transition
        const validation = await this.validateTransition(transitionId, context);
        if (!validation.valid) {
          return {
            success: false,
            message: `Transition validation failed: ${validation.errors.join(', ')}`,
          };
        }
    
        const transition =
          await this.workflowRoleRepository.findTransitionById(transitionId);
    
        if (!transition) {
          return { success: false, message: 'Transition not found' };
        }
    
        // Record the transition in the task workflow
        await this.recordTransition(transition, context, handoffMessage);
    
        // Update task ownership if needed
        await this.updateTaskOwnership(
          String(context.taskId),
          transition.toRole.name,
        );
    
        // πŸ”§ FIX: Update workflow execution state after role transition
        await this.updateWorkflowExecutionStateForTransition(
          context.taskId,
          transition.toRole.id,
          handoffMessage,
        );
    
        return {
          success: true,
          message: `Successfully transitioned from ${transition.fromRole.description} to ${transition.toRole.description}`,
          newRoleId: transition.toRole.id,
        };
      } catch (error) {
        return {
          success: false,
          message: `Transition execution failed: ${error.message}`,
        };
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions that the tool 'returns execution status with essential details for next steps,' this is insufficient for a mutation tool. It doesn't disclose what 'executes' entails (e.g., whether it's irreversible, requires specific permissions, has side effects, or involves rate limits), leaving critical behavioral traits undocumented.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise at one sentence that states the action and return value. It's front-loaded with the core action ('executes role transition') and wastes no words. However, it could be more structured by explicitly separating purpose from behavior, but it's efficient given its brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't adequately explain what 'role transition' means, what 'executes' entails behaviorally, or what the return 'execution status' and 'essential details' include. For a tool that likely changes system state, this leaves significant gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional semantic information about the parameters beyond what's already in the schema descriptions. It doesn't explain relationships between parameters (e.g., how roleId, taskId, and transitionId interact) or provide usage examples, so it meets the baseline but doesn't add value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'executes role transition' which provides a basic verb+resource combination, but it's vague about what 'role transition' actually means in this context. It doesn't distinguish this tool from sibling tools like 'validate_transition' or 'get_role_transitions', leaving the specific purpose unclear beyond the general action.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, appropriate contexts, or when other tools like 'validate_transition' or 'report_step_completion' might be more suitable. The agent receives no usage direction beyond the basic action described.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Hive-Academy/Anubis-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server