Agent Development Tutorial

Build sophisticated AI agents using the Fiberwise platform. Learn to create content generation agents, integrate LLM providers, and deploy intelligent automation workflows.

โฑ๏ธ 45 minutes ๐Ÿ“š Intermediate ๐Ÿค– Agent Development

๐Ÿ“‹ What You'll Build

A content generation agent that:

  • โœ… Creates blog posts, social media content, and emails
  • โœ… Integrates with multiple LLM providers (OpenAI, Anthropic)
  • โœ… Supports different tones and content lengths
  • โœ… Includes workflow automation and error handling

Final Result: A production-ready AI agent installed to your Fiberwise platform (no UI - pure agent functionality).

๐Ÿ“‹ Prerequisites: Your Setup Checklist

Before you begin, you need a fully configured Fiberwise environment. This is the foundation for building any app on the platform.

๐Ÿ”ง Required Setup

โœ… All Set?

Once all boxes are checked, you are ready to proceed. If not, please complete the linked guides first.

Step 1: Create Your Agent App

Initialize Agent Project

# Create and enter project directory
mkdir content-generator-agent
cd content-generator-agent

# Initialize basic app structure
fiber init

# The CLI creates:
# โ”œโ”€โ”€ app_manifest.yaml     # App configuration
# โ”œโ”€โ”€ agents/               # Agent implementations
# โ”‚   โ””โ”€โ”€ content_generator.py
# โ””โ”€โ”€ index.js             # App entry point

Create Content Generator Agent

Edit agents/content_generator.py:

from fiberwise_sdk import FiberAgent

class ContentGenerator(FiberAgent):
    """Generates marketing content with AI assistance"""
    
    def run_agent(self, input_data: dict, llm_provider: LLMProviderService):
        topic = input_data.get('topic', '')
        content_type = input_data.get('type', 'blog_post')
        tone = input_data.get('tone', 'professional')
        length = input_data.get('length', 'medium')
        
        if not topic:
            return {'status': 'error', 'message': 'Topic is required'}
        
        # Generate content based on type
        if content_type == 'blog_post':
            return self._generate_blog_post(topic, tone, length, llm_provider)
        elif content_type == 'social_media':
            return self._generate_social_media(topic, tone, llm_provider)
        elif content_type == 'email':
            return self._generate_email(topic, tone, llm_provider)
        else:
            return {'status': 'error', 'message': f'Unknown content type: {content_type}'}
    
    def _generate_blog_post(self, topic, tone, length, llm_provider):
        """Generate a blog post"""
        length_guide = {
            'short': 'about 300-500 words',
            'medium': 'about 800-1200 words', 
            'long': 'about 1500-2000 words'
        }
        
        prompt = f"""
        Write a {tone} blog post about {topic}.
        Length: {length_guide.get(length, 'medium length')}
        
        Include:
        - Engaging title
        - Introduction that hooks the reader
        - 3-4 main sections with subheadings
        - Conclusion with call-to-action
        - SEO-friendly structure
        
        Format as markdown.
        """
        
        try:
            content = llm_provider.complete(prompt)
            return {
                'status': 'success',
                'content': content,
                'content_type': 'blog_post',
                'metadata': {
                    'topic': topic,
                    'tone': tone,
                    'length': length,
                    'word_count': len(content.split()),
                    'generated_at': self.get_current_time()
                }
            }
        except Exception as e:
            return {'status': 'error', 'message': f'Generation failed: {str(e)}'}
    
    def _generate_social_media(self, topic, tone, llm_provider):
        """Generate social media posts"""
        prompt = f"""
        Create 3 different social media posts about {topic} in a {tone} tone.
        
        Format:
        1. Twitter/X post (280 characters max)
        2. LinkedIn post (professional, 1-2 paragraphs)
        3. Instagram caption (engaging, with hashtags)
        
        Each should be engaging and platform-appropriate.
        """
        
        try:
            content = llm_provider.complete(prompt)
            return {
                'status': 'success',
                'content': content,
                'content_type': 'social_media',
                'metadata': {
                    'topic': topic,
                    'tone': tone,
                    'platforms': ['twitter', 'linkedin', 'instagram'],
                    'generated_at': self.get_current_time()
                }
            }
        except Exception as e:
            return {'status': 'error', 'message': f'Generation failed: {str(e)}'}
    
    def _generate_email(self, topic, tone, llm_provider):
        """Generate marketing email"""
        prompt = f"""
        Write a marketing email about {topic} in a {tone} tone.
        
        Include:
        - Compelling subject line
        - Personal greeting
        - Clear value proposition
        - Call-to-action
        - Professional signature placeholder
        
        Keep it concise and actionable.
        """
        
        try:
            content = llm_provider.complete(prompt)
            return {
                'status': 'success',
                'content': content,
                'content_type': 'email',
                'metadata': {
                    'topic': topic,
                    'tone': tone,
                    'generated_at': self.get_current_time()
                }
            }
        except Exception as e:
            return {'status': 'error', 'message': f'Generation failed: {str(e)}'}
    
    def get_current_time(self):
        """Get current timestamp"""
        from datetime import datetime
        return datetime.now().isoformat()

๐Ÿงช Step 2: Test Your Agent Locally

Test Basic Content Generation

# Test blog post generation
fiber activate agents/content_generator.py --input-data '{
    "topic": "AI automation for small businesses",
    "type": "blog_post",
    "tone": "friendly",
    "length": "medium"
}'

# Expected output:
# โœ… Agent activated successfully
# โœ… Content generated: ~800 word blog post
# โœ… Metadata includes generation timestamp

Test Different Content Types

# Generate social media posts
fiber activate agents/content_generator.py --input-data '{
    "topic": "productivity tips for remote work",
    "type": "social_media",
    "tone": "casual"
}'

# Generate marketing email
fiber activate agents/content_generator.py --input-data '{
    "topic": "new product launch",
    "type": "email",
    "tone": "professional"
}'

Expected Results

  • โœ… Successful execution - No Python errors or exceptions
  • โœ… Generated content - Content appears in response JSON
  • โœ… Proper formatting - Content follows requested tone and structure
  • โœ… Metadata tracking - Response includes generation timestamp and provider info

๐Ÿš€ Step 3: Install Your Agent

Configure App Manifest

# Content Generator Agent App
app:
  name: Content Generator
  app_slug: content-generator-agent
  version: 1.0.0
  description: AI-powered content generation agent
  icon: fas fa-pen-fancy
  category: ai-tools
  minPlatformVersion: 1.6.0

# Agent definitions
agents:
  - name: content_generator
    description: Generates marketing content with AI assistance
    agent_type: content-generation
    system_prompt: "You are a professional content creator..."
    capabilities: ["blog_posts", "social_media", "email_marketing"]

Install to Platform

# Install your agent app
fiber install app .

# The CLI will:
# 1. โœ… Validate app_manifest.yaml
# 2. โœ… Create agent in platform database
# 3. โœ… Upload agent implementation
# 4. โœ… Make agent available for use

Verify Installation

# List installed agents
fiber agent list
# Should show: content_generator - active

# Test installed agent
fiber agent activate content_generator --input-data '{
    "topic": "AI in marketing",
    "type": "blog_post",
    "tone": "professional"
}'
# Should generate content using installed agent

๐Ÿ“Š Step 4: Explore Your Agent's Data

Data Explorer API Integration Flow

                graph TD
                    A[๐Ÿ”ง app-data-explorer.js] --> B[๐ŸŒ API Calls to Platform]
                    
                    B --> C[๐Ÿ“ GET /api/apps/:appId/:modelSlug]
                    C --> D[๐Ÿ“Š Fetch Activations Data]
                    
                    B --> E[๐Ÿ“ GET /api/apps/:appId/models]
                    E --> F[๐Ÿ“‹ Get Available Data Models]
                    
                    D --> G[๐Ÿ“„ Parse JSON Responses]
                    F --> G
                    
                    G --> H[๐ŸŽจ Render Data Tables]
                    H --> I[๐Ÿ“ฑ Interactive UI Components]
                    
                    I --> J[๐Ÿ” Filter by Content Type]
                    I --> K[๐Ÿ“… Sort by Date]
                    I --> L[๐Ÿ‘๏ธ View Full Content]
                    I --> M[๐Ÿ“ Export to CSV]
                    
                    classDef component fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
                    classDef api fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
                    classDef data fill:#fff3e0,stroke:#f57c00,stroke-width:2px
                    classDef ui fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
                    classDef features fill:#e0f2f1,stroke:#00796b,stroke-width:2px
                    
                    class A component
                    class B,C,E api
                    class D,F,G data
                    class H,I ui
                    class J,K,L,M features
                

Enhanced Data Explorer & Dynamic Model Flow

                        graph TD
                            AA[๐Ÿค– Agent Activation] --> AB[๐Ÿ†• Create Dynamic Model (modelSlug)]
                            AB --> AC[๐Ÿ—„๏ธ app_models Table]
                            AB --> AD[๐Ÿ—„๏ธ app_model_fields Table]
                            AA --> AE[โšก Create Activation Record]
                            AE --> AF[๐Ÿ—„๏ธ app_model_items Table]
                            AF --> AG[๐Ÿ“„ data: {field1, field2, ...}]
                    
                            AH[๐Ÿ”ง app-data-explorer.js] --> AI[๐ŸŒ GET /api/apps/:appId/models]
                            AI --> AJ[๐Ÿ“‹ List Models (with modelSlug)]
                            AH --> AK[๐ŸŒ GET /api/apps/:appId/:modelSlug/fields]
                            AK --> AL[๐Ÿ“‹ List Model Fields]
                            AH --> AM[๐ŸŒ GET /api/apps/:appId/:modelSlug]
                            AM --> AN[๐Ÿ“Š Fetch Model Data]
                            AN --> AO[๐Ÿ“„ Parse JSON Records]
                            AL --> AO
                            AO --> AP[๐ŸŽจ Render Table: Dynamic Fields]
                            AP --> AQ[๐Ÿ“ฑ Interactive UI: Filter, Sort, View]
                    
                            classDef agent fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
                            classDef db fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
                            classDef api fill:#fff3e0,stroke:#f57c00,stroke-width:2px
                            classDef data fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
                            classDef ui fill:#e0f2f1,stroke:#00796b,stroke-width:2px
                    
                            class AA,AE agent
                            class AB,AC,AD,AF db
                            class AH,AI,AK,AM api
                            class AJ,AL,AN,AO data
                            class AP,AQ ui
                        

Agent Activation Data Structure Flow

                graph TD
                    A[๐Ÿค– Content Generator Agent] --> B[๐Ÿ“Š Creates Activation Records]
                    B --> C[๐Ÿ—„๏ธ app_model_items Table]
                    
                    C --> D[๐Ÿ“ item_id: UUID]
                    C --> E[๐Ÿ“… created_at: Timestamp]
                    C --> F[๐Ÿ‘ค created_by: User ID]
                    C --> G[๐Ÿ“„ data: JSON Content]
                    
                    G --> H[๐ŸŽฏ status: success/error]
                    G --> I[๐Ÿ“ content_type: blog_post/social_media/email]
                    G --> J[๐ŸŽจ topic: User Input]
                    G --> K[๐ŸŽญ tone: professional/casual/friendly]
                    G --> L[๐Ÿ“ word_count: Generated Count]
                    G --> M[๐Ÿ“„ content: Generated Text]
                    
                    H --> N[๐Ÿ” Data Explorer Display]
                    I --> N
                    J --> N
                    K --> N
                    L --> N
                    M --> N
                    
                    classDef agent fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
                    classDef database fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
                    classDef metadata fill:#fff3e0,stroke:#f57c00,stroke-width:2px
                    classDef content fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
                    classDef display fill:#e0f2f1,stroke:#00796b,stroke-width:2px
                    
                    class A agent
                    class B,C database
                    class D,E,F,G metadata
                    class H,I,J,K,L,M content
                    class N display
                

Start Your Platform

Let's see the data your agent has been creating by starting the Fiberwise platform and using the built-in data explorer:

# Start your Fiberwise platform
fiber start

# Platform will be available at:
# http://localhost:8000

Access the Data Explorer

Navigate to your app's data explorer to see all the content your agent has generated:

  1. Open your browser: Go to http://localhost:8000
  2. Navigate to Apps: Click on "Apps" in the main navigation
  3. Find your agent app: Look for "Content Generator" in the apps list
  4. Open Data Explorer: Click "Data" next to your app name

๐Ÿ“Š What You'll See

The data explorer will show you:

  • Activations Model - All agent executions and their results
  • Generated Content - Blog posts, social media content, emails
  • Metadata - Topics, tones, timestamps, content types
  • Performance Data - Success rates, generation times

Explore Your Agent's Output

In the data explorer, you can:

๐Ÿ” Browse Generated Content

View all blog posts, social media content, and emails your agent has created

๐Ÿ“ˆ Analyze Performance

See success rates, response times, and content quality metrics

๐Ÿ—‚๏ธ Filter by Type

Sort content by type (blog_post, social_media, email) or tone

๐Ÿ“ฑ View Details

Click "View" on any item to see full content and metadata

Export Your Data

Download your agent's generated content for analysis or backup:

Data Export & CLI Integration Flow

                graph TD
                    A[๐Ÿ’ป fiber data export Command] --> B[๐Ÿ” Identify App & Model]
                    B --> C[๐ŸŒ GET /api/apps/:appId/:modelSlug]
                    C --> D[๐Ÿ“Š Fetch All Activation Records]
                    
                    D --> E{๐Ÿ“„ Export Format?}
                    E -->|csv| F[๐Ÿ“Š Convert to CSV Format]
                    E -->|json| G[๐Ÿ“ฑ Convert to JSON Format]
                    
                    F --> H[๐Ÿ“ Create CSV Headers]
                    H --> I[๐Ÿ”ง Map Data Fields]
                    I --> J[๐Ÿ’พ Write CSV File]
                    
                    G --> K[๐Ÿ”ง Structure JSON Data]
                    K --> L[๐Ÿ’พ Write JSON File]
                    
                    J --> M[โœ… Export Complete]
                    L --> M
                    
                    classDef cli fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
                    classDef api fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
                    classDef format fill:#fff3e0,stroke:#f57c00,stroke-width:2px
                    classDef csv fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
                    classDef json fill:#e0f2f1,stroke:#00796b,stroke-width:2px
                    classDef complete fill:#ffebee,stroke:#d32f2f,stroke-width:2px
                    
                    class A,B cli
                    class C,D api
                    class E format
                    class F,H,I,J csv
                    class G,K,L json
                    class M complete
                

CSV Export Data Transformation Flow

    graph TD
    A[๐Ÿ—„๏ธ Raw Database Records] --> B[๐Ÿ“Š JSON Data Extraction]
    B --> C[๐Ÿ”ง Field Mapping Process]

    C --> D[๐Ÿ†” activation_id โ† item_id]
    C --> E[๐Ÿ“Š status โ† data.status]
    C --> F[๐ŸŽฏ content_type โ† data.content_type]
    C --> G[๐Ÿ“ topic โ† data.metadata.topic]
    C --> H[๐ŸŽญ tone โ† data.metadata.tone]
    C --> I[๐Ÿ“ word_count โ† data.metadata.word_count]
    C --> J[๐Ÿ“… generated_at โ† data.metadata.generated_at]
    C --> K[๐Ÿ“„ content โ† data.content (truncated)]

    D --> L[๐Ÿ“Š CSV Row Generation]
    E --> L
    F --> L
    G --> L
    H --> L
    I --> L
    J --> L
    K --> L

    L --> M[๐Ÿ’พ Final CSV File]

    classDef database fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
    classDef extraction fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
    classDef mapping fill:#fff3e0,stroke:#f57c00,stroke-width:2px
    classDef csv fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    classDef output fill:#e0f2f1,stroke:#00796b,stroke-width:2px

    class A database
    class B extraction
    class C,D,E,F,G,H,I,J,K mapping
    class L csv
    class M output
                
# Export activations data to CSV
fiber data export content-generator-agent activations --format csv --output agent-content.csv

# Export with specific date range
fiber data export content-generator-agent activations \
  --format csv \
  --start-date "2025-01-01" \
  --end-date "2025-12-31" \
  --output agent-content-2025.csv

# Export as JSON for programmatic use
fiber data export content-generator-agent activations --format json --output agent-data.json

CSV Structure

Your exported CSV will contain columns like:

activation_id status content_type topic tone word_count generated_at content
act_123456 success blog_post AI automation professional 842 2025-08-15T10:30:00Z # AI Automation for Modern...
act_123457 success social_media productivity tips casual 156 2025-08-15T11:15:00Z ๐Ÿš€ Boost your productivity...

๐Ÿ’ก Use Your Exported Data For:

  • Content Analysis - Analyze word counts, topics, and performance
  • Quality Review - Review and edit generated content
  • Publishing Workflows - Import into CMS or social media schedulers
  • Training Data - Use successful outputs to improve prompts
  • Reporting - Show content generation metrics to stakeholders

๐Ÿš€ Next Steps

Complete Agent Development & Deployment Lifecycle

                graph TD
                    A[๐Ÿ’ป Local Development] --> B[๐Ÿงช Local Testing]
                    B --> C[๐Ÿš€ Platform Installation]
                    C --> D[๐ŸŒ Production Usage]
                    D --> E[๐Ÿ“Š Data Analysis]
                    E --> F[๐Ÿ”„ Iteration & Improvement]
                    F --> A
                    
                    A --> A1[๐Ÿ—๏ธ fiber init]
                    A --> A2[๐Ÿค– Agent Implementation]
                    A --> A3[โš™๏ธ Manifest Configuration]
                    
                    B --> B1[โšก fiber activate]
                    B --> B2[๐Ÿ” Validation & Debugging]
                    B --> B3[โœ… Local Success]
                    
                    C --> C1[๐Ÿ“ฆ fiber install app]
                    C --> C2[๐Ÿ—„๏ธ Database Integration]
                    C --> C3[๐ŸŒ API Endpoints]
                    
                    D --> D1[๐Ÿ“ฑ Web Interface]
                    D --> D2[๐Ÿ”ง FIBER.agents.activate]
                    D --> D3[๐Ÿ“Š Real-time Results]
                    
                    E --> E1[๐Ÿ” app-data-explorer]
                    E --> E2[๐Ÿ“ CSV Export]
                    E --> E3[๐Ÿ“ˆ Performance Analysis]
                    
                    F --> F1[๐Ÿ”ง Code Updates]
                    F --> F2[๐Ÿ“ฆ fiber app update]
                    F --> F3[๐Ÿš€ Re-deployment]
                    
                    classDef phase fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
                    classDef dev fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
                    classDef test fill:#fff3e0,stroke:#f57c00,stroke-width:2px
                    classDef deploy fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
                    classDef usage fill:#e0f2f1,stroke:#00796b,stroke-width:2px
                    classDef analysis fill:#ffebee,stroke:#d32f2f,stroke-width:2px
                    classDef iterate fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
                    
                    class A,B,C,D,E,F phase
                    class A1,A2,A3 dev
                    class B1,B2,B3 test
                    class C1,C2,C3 deploy
                    class D1,D2,D3 usage
                    class E1,E2,E3 analysis
                    class F1,F2,F3 iterate
                

End-to-End Agent Execution Flow with FIBER SDK

                graph TD
                    A[๐Ÿ‘ค User Request] --> B[๐ŸŒ Web Interface/CLI]
                    B --> C[๐Ÿ”ง FIBER.agents.activate]
                    C --> D[๐ŸŒ POST /api/v1/activations]
                    
                    D --> E[๐Ÿ—„๏ธ Create Activation Record]
                    E --> F[๐Ÿค– Load Agent Code]
                    F --> G[๐Ÿ’‰ Dependency Injection]
                    G --> H[๐Ÿง  LLMProviderService]
                    G --> I[๐Ÿ“Š FiberApp SDK]
                    G --> J[๐Ÿ—„๏ธ DatabaseService]
                    
                    H --> K[๐ŸŽฏ Agent.run_agent Method]
                    I --> K
                    J --> K
                    
                    K --> L[๐Ÿง  llm_provider.complete]
                    L --> M[๐Ÿ“„ Generated Content]
                    M --> N[๐Ÿ“Š Create Metadata]
                    N --> O[๐Ÿ’พ Update Activation]
                    
                    O --> P[โšก WebSocket Event]
                    P --> Q[๐ŸŒ Real-time UI Update]
                    
                    O --> R[๐Ÿ” Data Explorer View]
                    R --> S[๐Ÿ“ CSV Export]
                    
                    classDef user fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
                    classDef interface fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
                    classDef api fill:#fff3e0,stroke:#f57c00,stroke-width:2px
                    classDef platform fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
                    classDef agent fill:#e0f2f1,stroke:#00796b,stroke-width:2px
                    classDef llm fill:#ffebee,stroke:#d32f2f,stroke-width:2px
                    classDef result fill:#f1f8e9,stroke:#558b2f,stroke-width:2px
                    
                    class A user
                    class B,Q interface
                    class C,D api
                    class E,F,G,H,I,J platform
                    class K,M,N agent
                    class L llm
                    class O,P,R,S result
                

Immediate Next Steps

  1. Experiment with prompts - Try different content types and tones
  2. Add error logging - Implement comprehensive error tracking
  3. Create agent variations - Build specialized content agents
  4. Update your agent - Make changes and redeploy:
    # Update deployed agent
    fiber app update .

Continue Learning

๐Ÿ† Congratulations!

You've successfully:

  • โœ… Built an AI-powered content generation agent
  • โœ… Integrated with LLM providers securely
  • โœ… Implemented error handling and metadata tracking
  • โœ… Installed a production-ready agent (no UI needed)
  • โœ… Learned agent development best practices

You're now ready to build even more powerful AI agents!