Building Task Attachments in Astreus
Attach files, images, and data to agent tasks. Process documents, analyze images, work with structured data.
What Are Task Attachments?
Task attachments enable you to attach multiple file types to tasks for comprehensive analysis within the Astreus framework. Instead of manually extracting content or describing files in prompts, you can pass files directly to agents equipped with vision and processing capabilities. This transforms agents from text processors into sophisticated document analyzers.
Getting Started
You can either clone the complete example repository or install the package independently. Both approaches give you access to the task attachment functionality.
Alternatively, install just the package:
Create a .env file with your configuration:
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db
Creating an Agent with Vision
To process attachments, especially images, create an agent with vision capabilities enabled. The vision model handles image analysis while the main model processes text and code.
This configuration enables the agent to process both text-based files and visual content. The vision: true flag activates multimodal processing capabilities.
Attachment Structure
Each attachment requires specific properties to identify and process the file correctly. The type field categorizes the content, while path provides the location and name gives it a display identifier.
Supported types include code, image, json, and markdown. For code files, specify the language to enable syntax-aware analysis.
Creating Tasks with Multiple Attachments
Tasks accept an array of attachments, allowing you to provide all necessary context in a single request. The agent can reason across different file types simultaneously.
This creates a task that processes code, design mockups, dependencies, and documentation together. The agent analyzes all materials and provides unified insights.
Executing Tasks
Once created, execute tasks by their ID to get the analysis results. The agent processes all attachments and returns a structured response.
The execution is asynchronous, allowing you to process multiple tasks concurrently. Results include the agent's analysis of all attached materials.
Running Your Implementation
For cloned repositories, use the provided dev script to run examples:
For standalone implementations, create an index.ts file with your code and execute with tsx:
Processing Code Files
Code attachments support language specification for syntax-aware analysis. The agent understands programming constructs and can identify patterns, issues, and improvements.
The language parameter helps the agent apply language-specific best practices and identify common vulnerabilities in that ecosystem.
Image Analysis
Image attachments enable visual analysis when you have design mockups, screenshots, or diagrams. Vision-capable models process these directly without requiring text descriptions.
The agent can identify UI elements, assess layout quality, and provide feedback on visual hierarchy and user experience principles.
Structured Data Processing
JSON attachments are useful for analyzing configuration files, API responses, or structured data. The agent understands the data structure and can validate or extract information.
This enables automated dependency audits, configuration validation, and data quality checks without manual inspection.
Documentation Analysis
Markdown attachments allow you to include documentation, specifications, or written content. The agent can assess completeness, clarity, and accuracy.
The agent understands markdown structure and can identify missing sections, unclear explanations, or inconsistencies in documentation.
Cross-File Analysis
The real power emerges when combining multiple file types in a single task. The agent correlates information across attachments to provide comprehensive insights.
This enables requirement traceability, design-implementation verification, and comprehensive quality assurance in a single operation.
Task Metadata
Metadata helps organize and categorize tasks for filtering, prioritization, and workflow management. Use it to track task types, priorities, or custom classifications.
Metadata doesn't affect processing but provides context for task management systems and reporting tools.
Best Practices
Keep prompts specific about what to analyze in the attachments. Generic instructions lead to generic results, while focused questions produce actionable insights.
Clear prompts guide the agent's focus and ensure you get relevant, detailed feedback on the aspects that matter most.
When analyzing related files, use descriptive names to help the agent understand relationships. This improves the quality of cross-file analysis.
Descriptive names provide context that helps the agent understand each file's role in the analysis.
Error Handling
Handle task execution errors gracefully to build robust applications. Check for file access issues, format problems, or processing failures.
Proper error handling prevents application crashes and provides clear feedback when attachments can't be processed.
Real-World Use Cases
Task attachments enable sophisticated workflows like automated code reviews. Attach source files and let the agent identify issues, suggest improvements, and verify best practices.
This automates repetitive review tasks and ensures consistent quality standards across your codebase.
Design-Implementation Verification
Verify that implementations match design specifications by attaching both design mockups and code. The agent identifies discrepancies and missing features.
This catches design drift early and ensures the final product matches stakeholder expectations.
Documentation Quality Assurance
Ensure documentation stays synchronized with code by analyzing both together. The agent identifies outdated examples, missing documentation, or incomplete coverage.
Automated documentation checks maintain quality without manual cross-referencing between docs and code.
Security Audits
Perform security audits by attaching relevant code files and asking the agent to identify vulnerabilities. This complements traditional security tools with contextual analysis.
The agent understands security principles and can identify issues that pattern-matching tools might miss.
Working with the Repository
The complete example repository demonstrates all features with runnable code. Explore different attachment types and processing patterns.
Repository: github.com/astreus-ai/astreus
The examples show real-world patterns you can adapt to your specific use cases. Each example includes comments explaining the approach and expected outcomes.
Key Features Summary
Task attachments support diverse file formats including code, images, structured data, and documentation. Language specification enables syntax-aware analysis for code files. Metadata organization facilitates task categorization and workflow management. Integration with vision-capable LLMs enables image processing without manual description.
These capabilities transform agents from text processors into comprehensive document analyzers that understand multiple content types and their relationships.
Future Possibilities
As Astreus evolves, task attachments will support additional file types and larger context windows. Future enhancements may include video processing, audio transcription, and more sophisticated multi-file reasoning. The attachment system provides a foundation for increasingly sophisticated document processing workflows.
This experiment is written for Astreus v0.5.37. Please ensure you are using a compatible version.