Mini Agent

repository·main·Indexed 25 days ago

https://github.com/minimax-ai/mini-agent

A professional demo project for building agents using the MiniMax M2.5 model. It features an Anthropic-compatible API, interleaved thinking, persistent memory, and Model Context Protocol (MCP) tool integration. The project includes a CLI, support for custom skills, and integration with the Zed editor via the Agent Communication Protocol (ACP).

Tokens
66.7K
Snippets
151
Records
299
Agent score
70%

What's inside mini-agent

  1. Test local web applications with webapp-testing

    main

    The webapp-testing skill provides a toolkit for interacting with and testing local web applications using Playwright. It supports verifying frontend functionality, debugging UI behavior, capturing screenshots, and viewing browser logs.

    Approach Selection

    • Static HTML: Read the HTML file directly to identify selectors, then write a Playwright script using file:// URLs.
    • Dynamic Webapps:
      • If the server is not running: Use the scripts/with_server.py helper to manage the server lifecycle.
      • If the server is running: Use a 'Reconnaissance-then-action' pattern (navigate, wait for networkidle, inspect DOM/screenshot, then execute actions).
  2. Write a 3P (Progress, Plans, Problems) update

    main

    A 3P update is a succinct summary designed for executives and leadership to be read in 30-60 seconds. It covers a specific team's work over a set time period (typically one week).

    Core Sections

    1. Progress: Accomplishments from the past week (e.g., shipped features, milestones achieved, tasks completed).
    2. Plans: High-priority objectives for the upcoming week.
    3. Problems: Blockers or issues slowing the team down (e.g., resource shortages, bugs, failed deals).

    Writing Guidelines

    • Granularity: Adjust detail based on team size. Large teams (e.g., entire company) should focus on high-level impact (e.g., "hired 20 people"), while small teams can be more specific.
    • Tone: Matter-of-fact and data-driven. Avoid heavy prose; use metrics where possible.
    • Length: Each section must be strictly 1-3 sentences.
    • Context: If the team name is not provided, ask for it before proceeding.
  3. Design Agent-Centric MCP Tools

    main

    When building MCP (Model Context Protocol) servers, design tools specifically for AI agents rather than simple API wrappers. Follow these principles:

    • Build for Workflows: Consolidate related operations into high-impact tools (e.g., a schedule_event tool that checks availability and creates the event) instead of exposing raw endpoints.
    • Optimize for Limited Context: Return high-signal information. Provide options for "concise" vs "detailed" responses and prefer human-readable identifiers (names) over technical IDs.
    • Design Actionable Error Messages: Errors should guide the agent. Instead of just diagnostic codes, suggest next steps like Try using filter='active_only' to reduce results.
    • Natural Task Subdivisions: Use tool names that reflect human task thinking and group related tools with consistent prefixes.
    • Use Evaluation-Driven Development: Create realistic evaluation scenarios early to let agent feedback drive tool improvements.
  4. Implement tool inputs with Pydantic models

    main

    Define tool input schemas using Pydantic BaseModel. FastMCP uses these models to automatically generate inputSchema and perform validation.

    Best Practices:

    • Use ConfigDict for configuration (e.g., str_strip_whitespace=True, extra='forbid').
    • Use Field to provide descriptions and constraints (e.g., min_length, ge, le).
    • Use field_validator (with @classmethod) for custom validation logic.
    from pydantic import BaseModel, Field, field_validator, ConfigDict
    from typing import Optional, List
    
    class ServiceToolInput(BaseModel):
        model_config = ConfigDict(
            str_strip_whitespace=True,
            validate_assignment=True,
            extra='forbid'
        )
    
        param1: str = Field(..., description="First parameter description", min_length=1, max_length=100)
        param2: Optional[int] = Field(default=None, description="Optional integer", ge=0, le=1000)
        tags: Optional[List[str]] = Field(default_factory=list, description="List of tags", max_items=10)
  5. Convert DOCX documents to images for visual analysis

    main

    To visually inspect a Word document, convert it to a PDF first, then convert the PDF pages into JPEG images.

    Step 1: Convert DOCX to PDF

    Use LibreOffice (soffice) in headless mode:

    soffice --headless --convert-to pdf document.docx

    Step 2: Convert PDF to JPEG

    Use pdftoppm from the poppler-utils package:

    pdftoppm -jpeg -r 150 document.pdf page

    pdftoppm Options:

    • -r 150: Sets resolution to 150 DPI.
    • -jpeg: Output format (use -png for PNG).
    • -f N: First page to convert.
    • -l N: Last page to convert.
    • page: Prefix for output files (e.g., page-1.jpg).
  6. Fill non-fillable PDF forms using annotations

    main

    If the PDF is flat (non-fillable), you must manually define bounding boxes for text annotations. Follow these steps exactly:

    1. Visual Analysis: Convert the PDF to PNGs to identify where data should go.

      python scripts/convert_pdf_to_images.py <file.pdf> <output_directory>

      Identify bounding boxes for both the label and the entry area. The label and entry boxes must not intersect. For checkboxes, the entry box should target only the small square, not the text label.

    2. Create fields.json: Define the layout in a JSON file. Example fields.json structure:

      {
        "pages": [
          { "page_number": 1, "image_width": 1000, "image_height": 1400 }
        ],
        "form_fields": [
          {
            "page_number": 1,
            "description": "The user's last name",
            "field_label": "Last name",
            "label_bounding_box": [30, 125, 95, 142],
            "entry_bounding_box": [100, 125, 280, 142],
            "entry_text": { "text": "Johnson", "font_size": 14, "font_color": "000000" }
          }
        ]
      }
    3. Generate and Validate Visuals:

      • Create validation images (red = entry, blue = label) for each page:
        python scripts/create_validation_image.py <page_number> <path_to_fields.json> <input_image_path> <output_image_path>
      • Run an automated intersection and height check:
        python scripts/check_bounding_boxes.py <JSON file>
      • CRITICAL: Manually inspect the validation images. Red rectangles must cover ONLY input areas and MUST NOT contain text. Blue rectangles should cover label text.
    4. Apply Annotations: Create the final PDF.

      python scripts/fill_pdf_form_with_annotations.py <input_pdf_path> <path_to_fields.json> <output_pdf_path>
    python scripts/convert_pdf_to_images.py <file.pdf> <output_directory>
    python scripts/create_validation_image.py <page_number> <path_to_fields.json> <input_image_path> <output_image_path>
    python scripts/check_bounding_boxes.py <JSON file>
    python scripts/fill_pdf_form_with_annotations.py <input_pdf_path> <path_to_fields.json> <output_pdf_path>
  7. Implement Pagination for Listing Tools

    main

    When implementing tools that list resources, use limit and offset parameters. The response should include pagination metadata to help the agent navigate results.

    Recommended Response Structure:

    const response = {
      total: number,           // Total number of items available
      count: number,          // Number of items in the current response
      offset: number,         // Current pagination offset
      items: Array<any>,      // The actual data
      has_more: boolean,      // Whether more results are available
      next_offset: number     // The offset for the next page (if has_more is true)
    };
  8. Customize the Agent's system prompt

    main

    The agent's behavior, guidelines, and communication style are defined in system_prompt.md. You can customize:

    • Core Capabilities: Modify tool descriptions.
    • Working Guidelines: Define custom workflows.
    • Domain-Specific Knowledge: Add specialized expertise.
    • Communication Style: Adjust interaction tone.
    • Task Priorities: Set task approach preferences.

    Note: You must restart the Agent for changes in system_prompt.md to take effect.