API Reference

getContext()

API reference for requesting motivation-aware context.

Method Signature

amp.getContext(params: GetContextParams): Promise<MotivationContext>

Parameters

interface GetContextParams {
  // Required
  userId: string;              // Unique user identifier
  task: string;                // Task description

  // Optional
  complexity?: 'low' | 'medium' | 'high';
  taskType?: string;           // e.g., 'coding', 'debugging', 'writing'
  metadata?: Record<string, any>;
}

Response

interface MotivationContext {
  requestId: string;
  suggestedFraming: 'achievement' | 'learning' | 'micro_task' | 'challenge';
  communicationStyle: 'brief_directive' | 'detailed_explanatory' | 'conversational' | 'technical';
  complexity: 'full_solution' | 'break_into_steps' | 'hints_only' | 'high_level';
  encouragement: 'high' | 'moderate' | 'minimal' | 'none';
  confidence: number;          // 0-1
  rationale: string;
  metadata: {
    profilePhase: 'cold_start' | 'learning' | 'optimised';
    interactionCount: number;
    explorationMode: boolean;
  };
}

Examples

Basic Usage

const context = await amp.getContext({
  userId: 'user_123',
  task: 'build a login form'
});

console.log(context.suggestedFraming);  // 'micro_task'
console.log(context.confidence);         // 0.87

With Optional Parameters

const context = await amp.getContext({
  userId: 'user_123',
  task: 'fix authentication bug',
  complexity: 'high',
  taskType: 'debugging',
  metadata: {
    source: 'slack',
    priority: 'urgent'
  }
});

Error Codes

  • INVALID_USER_ID - User ID is missing or invalid
  • INVALID_TASK - Task description is missing or invalid
  • RATE_LIMIT_EXCEEDED - Too many requests
  • UNAUTHORIZED - Invalid API key

💡 Best Practice: Always save the requestId to use in reportOutcome().

See Also