The task context serves as the central objective that guides the entire prompt. It appears prominently in the final prompt structure and provides clear direction for the AI model. This method is essential for creating focused, goal-oriented prompts that produce relevant and actionable responses.
Parameters
context:str
Clear, specific description of what needs to be accomplished. Should be action-oriented and provide sufficient detail for the AI to understand the expected scope and deliverables.
priority:Priority=Priority.CRITICAL
Attention priority level for task placement in the final prompt. Defaults to Priority.CRITICAL to ensure the main task receives prominent positioning and maximum attention.
Returns
PromptBuilder
Self for method chaining, allowing combination with other prompt building methods.
Prompt Positioning
Task context is typically placed early in the prompt structure (after persona and critical constraints) to establish clear expectations. The default CRITICAL priority ensures the task receives prominent attention placement.
Best Practices
Follow these guidelines for effective task definition:
use clear, specific language that defines measurable outcomes
focus on action-oriented descriptions (“analyze”, “review”, “create”)
avoid vague or ambiguous task descriptions
include scope boundaries when appropriate
Examples
Basic task definition
Set a clear, focused task for the prompt:
import talk_box as tb# Simple task contextbuilder = ( tb.PromptBuilder() .persona("data analyst") .task_context("analyze the customer churn data to identify key patterns"))print(builder)
You are a data analyst.
TASK: analyze the customer churn data to identify key patterns
Task with custom priority
Use different priority levels for task positioning. Here is an example of a high priority task that is important but not critical:
builder = ( tb.PromptBuilder() .persona("software architect") .critical_constraint("focus only on security vulnerabilities") .task_context("review the authentication system architecture", priority=tb.Priority.HIGH ))print(builder)
You are a software architect.
CRITICAL REQUIREMENTS:
- focus only on security vulnerabilities
TASK: review the authentication system architecture
Detailed task with scope boundaries
Create comprehensive task descriptions with clear boundaries:
# Detailed task with specific scopebuilder = ( tb.PromptBuilder() .persona("technical writer", "API documentation") .task_context("create comprehensive API documentation for the user management endpoints, ""including authentication requirements, request/response examples, ""and error handling procedures" ) .core_analysis(["document each endpoint's purpose and functionality","provide complete request/response schemas","include practical usage examples" ]))print(builder)
You are a technical writer with expertise in API documentation.
TASK: create comprehensive API documentation for the user management endpoints, including
authentication requirements, request/response examples, and error handling procedures
CORE ANALYSIS (Required):
- document each endpoint's purpose and functionality
- provide complete request/response schemas
- include practical usage examples