Skip to main content
Glama
Hive-Academy

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

by Hive-Academy

get_step_guidance

Delivers clear instructions and validation criteria for executing specific workflow steps, tailored to user roles and task context.

Instructions

Provides focused guidance for executing the current workflow step, including commands and validation checklist.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
executionIdNoExecution ID for context (optional if taskId provided)
roleIdYesRole ID for step guidance
stepIdNoOptional specific step ID
taskIdNoTask ID for context (optional if executionId provided)

Implementation Reference

  • Zod input schema for the get_step_guidance tool defining parameters: taskId, executionId, roleId, stepId with validation that either taskId or executionId is provided.
    const GetStepGuidanceInputSchema = z
      .object({
        taskId: z
          .number()
          .optional()
          .describe('Task ID for context (optional if executionId provided)'),
        executionId: z
          .string()
          .optional()
          .describe('Execution ID for context (optional if taskId provided)'),
        roleId: z.string().describe('Role ID for step guidance'),
        stepId: z.string().optional().describe('Optional specific step ID'),
      })
      .refine(
        (data) => data.taskId !== undefined || data.executionId !== undefined,
        {
          message: 'Either taskId or executionId must be provided',
          path: ['taskId', 'executionId'],
        },
      );
  • @Tool decorator that registers the get_step_guidance MCP tool with name, description, and input schema.
    @Tool({
      name: 'get_step_guidance',
      description: `Provides focused guidance for executing the current workflow step, including commands and validation checklist.`,
      parameters: GetStepGuidanceInputSchema as ZodSchema<GetStepGuidanceInput>,
    })
  • The primary handler for get_step_guidance tool. Resolves execution context, delegates to StepGuidanceService for core logic, updates workflow context cache, and returns formatted response or error.
    async getStepGuidance(input: GetStepGuidanceInput) {
      try {
        // πŸ”§ CRITICAL FIX: Enhanced to handle post-transition scenarios
        let currentStepId = input.stepId;
        let currentRoleId = input.roleId;
        let actualTaskId = input.taskId;
        let resolvedExecutionId = input.executionId;
    
        // Get execution context if needed
        if (!currentStepId || !actualTaskId) {
          const executionQuery =
            input.taskId !== undefined
              ? { taskId: input.taskId }
              : { executionId: input.executionId };
    
          const executionResult =
            await this.workflowExecutionOperationsService.getExecution(
              executionQuery,
            );
    
          if (!executionResult.execution) {
            return this.buildResponse({
              error: 'No active execution found',
              guidance: 'Please ensure workflow is properly initialized',
            });
          }
    
          const currentExecution = executionResult.execution;
    
          // πŸ”§ BOOTSTRAP FIX: Update context from execution - HANDLE BOOTSTRAP CASE
          if (currentExecution.taskId) {
            actualTaskId = actualTaskId || currentExecution.taskId;
          } else {
            // Bootstrap case: execution has no task yet
            actualTaskId = 0; // Signal bootstrap mode to resolveStepId
          }
          currentRoleId = currentExecution.currentRoleId;
    
          // πŸ”§ CRITICAL FIX: Don't require currentStepId - let guidance service auto-detect
          if (currentExecution.currentStepId) {
            currentStepId = currentExecution.currentStepId;
          }
    
          if (!currentRoleId) {
            return this.buildResponse({
              error: 'Missing execution context',
              details: {
                hasRoleId: Boolean(currentRoleId),
                hasTaskId: Boolean(actualTaskId),
                isBootstrapMode: actualTaskId === 0,
              },
            });
          }
          resolvedExecutionId = executionResult.execution.id;
        }
    
        // βœ… ENHANCED: Use transition-aware StepGuidanceService
        const guidance = await this.stepGuidanceService.getStepGuidance({
          taskId: actualTaskId,
          roleId: currentRoleId,
          executionId: resolvedExecutionId,
          stepId: currentStepId, // May be undefined - guidance service handles this
          validateTransitionState: true, // Enable transition state detection
        });
    
        // 🧠 UPDATE WORKFLOW CONTEXT CACHE
        // Store latest workflow state after successful guidance generation
        if (resolvedExecutionId) {
          try {
            const cacheKey = WorkflowContextCacheService.generateKey(
              resolvedExecutionId,
              'step_guidance',
            );
    
            // Get current execution to extract latest state
            const currentExecution =
              await this.workflowExecutionOperationsService.getExecution({
                executionId: resolvedExecutionId,
              });
    
            if (currentExecution.execution) {
              const execution = currentExecution.execution;
              this.workflowContextCache.storeContext(cacheKey, {
                executionId: resolvedExecutionId,
                taskId: execution.taskId || actualTaskId,
                currentRoleId: execution.currentRoleId || currentRoleId,
                currentStepId: execution.currentStepId || undefined,
                roleName: execution.currentRole?.name || 'Unknown',
                stepName: execution.currentStep?.name,
                taskName: execution.task?.name,
                projectPath: process.cwd(),
                source: 'step_completion',
              });
            }
          } catch (_cacheError) {
            // Don't fail the main operation if cache update fails
            // Silent fail to avoid disrupting workflow
          }
        }
    
        // Return clean guidance without artificial fields
        return this.buildResponse(guidance);
      } catch (error) {
        return this.buildErrorResponse(
          'Failed to get step guidance',
          getErrorMessage(error),
          'STEP_GUIDANCE_ERROR',
        );
      }
    }
  • Supporting helper service method implementing core guidance logic: auto-resolves step ID, queries step data, handles role transitions, generates quality checklist and step-by-step guidance.
    async getStepGuidance(
      context: StepGuidanceContext,
    ): Promise<StepGuidanceResult> {
      // πŸ”§ CRITICAL FIX: Auto-detect step if not provided (common after transitions)
      let stepId = context.stepId;
    
      if (!stepId || context.validateTransitionState !== false) {
        const resolvedStepId = await this.resolveStepId(context);
    
        if (!resolvedStepId) {
          throw new StepNotFoundError(
            'unknown',
            'StepGuidanceService',
            'getStepGuidance - could not resolve stepId for current context',
          );
        }
    
        stepId = resolvedStepId;
      }
    
      // Get step with MCP actions
      const step = await this.stepQueryService.getStepWithDetails(stepId);
    
      if (!step) {
        throw new StepNotFoundError(
          stepId,
          'StepGuidanceService',
          'getStepGuidance',
        );
      }
    
      // Validate step belongs to current role
      if (step.roleId !== context.roleId) {
        // Try to find correct step for current role
        const correctStep = await this.stepQueryService.getNextAvailableStep(
          context.taskId.toString(),
          context.roleId,
          { checkTransitionState: true },
        );
    
        if (correctStep) {
          return await this.getStepGuidance({
            ...context,
            stepId: correctStep.id,
            validateTransitionState: false, // Avoid infinite recursion
          });
        } else {
          throw new StepNotFoundError(
            stepId,
            'StepGuidanceService',
            `Step role mismatch: step belongs to ${step.roleId}, requested for ${context.roleId}`,
          );
        }
      }
    
      // Get guidance from database step data (fix type mismatch)
      const guidanceData = {
        stepGuidance:
          Array.isArray(step.stepGuidance) && step.stepGuidance.length > 0
            ? step.stepGuidance[0]
            : null,
        qualityChecks: step.qualityChecks,
      };
    
      const enhancedGuidance = extractStreamlinedGuidance(guidanceData);
    
      return {
        step: StepDataUtils.extractStepInfo({
          id: step.id,
          name: step.name,
          description: step.description,
          stepType: step.stepType,
          roleId: step.roleId,
          approach: step.approach,
          sequenceNumber: step.sequenceNumber,
          isRequired: step.isRequired,
          createdAt: new Date(), // Provide default dates
          updatedAt: new Date(),
        }),
        qualityChecklist: enhancedGuidance.qualityChecklist,
        stepByStep: enhancedGuidance.stepByStep,
        approach: step.approach,
        guidance: step.stepGuidance,
        transitionContext: {
          stepResolved: stepId !== context.stepId,
          originalStepId: context.stepId,
          resolvedStepId: stepId,
        },
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions what the tool provides ('guidance... including commands and validation checklist'), it doesn't cover important aspects like whether this is a read-only operation, if it requires specific permissions, what format the guidance comes in, or any rate limits. The description is insufficient for a tool with no annotation coverage.

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

Conciseness5/5

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

The description is a single, efficient sentence that clearly states the tool's purpose. It's appropriately sized and front-loaded with the core functionality, with no wasted words or unnecessary elaboration.

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?

For a guidance-providing tool with no annotations and no output schema, the description is incomplete. It doesn't explain what format the guidance comes in, whether it's actionable steps or just information, or how the output should be interpreted. Given the complexity implied by the parameter set and lack of structured output information, more context is needed.

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?

Schema description coverage is 100%, so the schema already documents all 4 parameters. The description doesn't add any meaningful parameter semantics beyond what's in the schema descriptions (e.g., explaining relationships between executionId and taskId). The baseline of 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Provides focused guidance for executing the current workflow step, including commands and validation checklist.' It specifies the verb ('provides guidance') and resource ('current workflow step'), though it doesn't explicitly differentiate from siblings like 'get_workflow_guidance' or 'get_next_available_step'.

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. With siblings like 'get_workflow_guidance' and 'get_next_available_step', there's no indication of how this tool differs in context or when it should be preferred over similar tools.

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