Skip to main content

Attributes

The Task system is configured through the Task class, which provides the following attributes:
AttributeTypeDefaultDescription
descriptionstr(required)A clear statement of what the task entails
attachmentsList[str] | NoneNoneList of file paths to attach to the task
toolslist[Any] | NoneNoneThe tools/resources the agent can use for this task
response_formatUnion[Type[BaseModel], type[str], None]strThe expected output format (string or Pydantic model)
response_langstr | None"en"Language for the response
contextAny | NoneNoneContext for this task (files, images, knowledge bases, etc.)
enable_thinking_toolbool | NoneNoneEnable thinking tool for complex reasoning
enable_reasoning_toolbool | NoneNoneEnable reasoning tool for multi-step analysis
guardrailCallable | NoneNoneFunction to validate task output before proceeding
guardrail_retriesint | NoneNoneMaximum number of retries when guardrail validation fails
enable_cacheboolFalseWhether to enable caching for this task
cache_methodstr"vector_search"Method to use for caching: ‘vector_search’ or ‘llm_call’
cache_thresholdfloat0.7Similarity threshold for cache hits (0.0-1.0)
cache_embedding_providerAny | NoneNoneEmbedding provider for vector search caching
cache_duration_minutesint60How long to cache results in minutes
durable_executionAny | NoneNoneDurableExecution instance for checkpoint recovery
vector_search_top_kint | NoneNoneNumber of top results to return from vector search (for RAG/knowledge base)
vector_search_alphafloat | NoneNoneHybrid search alpha parameter (0.0 = keyword only, 1.0 = vector only)
vector_search_fusion_methodLiteral[‘rrf’, ‘weighted’] | NoneNoneMethod to fuse vector and keyword search results
vector_search_similarity_thresholdfloat | NoneNoneMinimum similarity score threshold for vector search results
vector_search_filterDict[str, Any] | NoneNoneMetadata filters to apply to vector search results

Configuration Example

from upsonic import Agent, Task
from pydantic import BaseModel
from typing import List

# Define structured response format
class AnalysisResult(BaseModel):
    summary: str
    confidence: float
    recommendations: List[str]

# Create agent
agent = Agent("openai/gpt-4o")

# Create task with configuration
task = Task(
    description="Analyze the market trends for Q4 2024",
    response_format=AnalysisResult,
    enable_thinking_tool=True,
    enable_cache=True,
    cache_method="llm_call",
    cache_threshold=0.8,
    cache_duration_minutes=30
)

# Execute task
result = agent.do(task)
print(result.summary)
print(f"Confidence: {result.confidence}")
print(f"Recommendations: {result.recommendations}")