Skip to main content
Glama
disler
by disler

aider_ai_code

Execute AI coding tasks by providing prompts and file paths for editing and context, enabling controlled code generation and modification.

Instructions

Run Aider to perform AI coding tasks based on the provided prompt and files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ai_coding_promptYesThe prompt for the AI to execute
relative_editable_filesYesLIST of relative paths to files that can be edited
relative_readonly_filesNoLIST of relative paths to files that can be read but not edited, add files that are not editable but useful for context
modelNoThe primary AI model Aider should use for generating code, leave blank unless model is specified in the request

Implementation Reference

  • The main handler function for the `aider_ai_code` tool, which initializes the Aider Coder and executes the requested AI coding task.
    def code_with_aider(
        ai_coding_prompt: str,
        relative_editable_files: List[str],
        relative_readonly_files: List[str] = [],
        model: str = DEFAULT_EDITOR_MODEL,
        working_dir: str = None,
    ) -> str:
        """
        Run Aider to perform AI coding tasks based on the provided prompt and files.
    
        Args:
            ai_coding_prompt (str): The prompt for the AI to execute.
            relative_editable_files (List[str]): List of files that can be edited.
            relative_readonly_files (List[str], optional): List of files that can be read but not edited. Defaults to [].
            model (str, optional): The model to use. Defaults to DEFAULT_EDITOR_MODEL.
            working_dir (str, required): The working directory where git repository is located and files are stored.
    
        Returns:
            Dict[str, Any]: {'success': True/False, 'diff': str with git diff output}
        """
        logger.info("Starting code_with_aider process.")
        logger.info(f"Prompt: '{ai_coding_prompt}'")
    
        # Working directory must be provided
        if not working_dir:
            error_msg = "Error: working_dir is required for code_with_aider"
            logger.error(error_msg)
            return json.dumps({"success": False, "diff": error_msg})
    
        logger.info(f"Working directory: {working_dir}")
        logger.info(f"Editable files: {relative_editable_files}")
        logger.info(f"Readonly files: {relative_readonly_files}")
        logger.info(f"Model: {model}")
    
        try:
            # Configure the model
            logger.info("Configuring AI model...")  # Point 1: Before init
            ai_model = Model(model)
            logger.info(f"Configured model: {model}")
            logger.info("AI model configured.")  # Point 2: After init
    
            # Create the coder instance
            logger.info("Creating Aider coder instance...")
            # Use working directory for chat history file if provided
            history_dir = working_dir
            abs_editable_files = [
                os.path.join(working_dir, file) for file in relative_editable_files
            ]
            abs_readonly_files = [
                os.path.join(working_dir, file) for file in relative_readonly_files
            ]
            chat_history_file = os.path.join(history_dir, ".aider.chat.history.md")
            logger.info(f"Using chat history file: {chat_history_file}")
    
            coder = Coder.create(
                main_model=ai_model,
                io=InputOutput(
                    yes=True,
                    chat_history_file=chat_history_file,
                ),
                fnames=abs_editable_files,
                read_only_fnames=abs_readonly_files,
                auto_commits=False,  # We'll handle commits separately
                suggest_shell_commands=False,
                detect_urls=False,
                use_git=True,  # Always use git
            )
            logger.info("Aider coder instance created successfully.")
    
            # Run the coding session
            logger.info("Starting Aider coding session...")  # Point 3: Before run
            result = coder.run(ai_coding_prompt)
            logger.info(f"Aider coding session result: {result}")
            logger.info("Aider coding session finished.")  # Point 4: After run
    
            # Process the results after the coder has run
            logger.info("Processing coder results...")  # Point 5: Processing results
            try:
                response = _process_coder_results(relative_editable_files, working_dir)
                logger.info("Coder results processed.")
            except Exception as e:
                logger.exception(
                    f"Error processing coder results: {str(e)}"
                )  # Point 6: Error
                response = {
                    "success": False,
                    "diff": f"Error processing files after execution: {str(e)}",
                }
    
        except Exception as e:
            logger.exception(
                f"Critical Error in code_with_aider: {str(e)}"
            )  # Point 6: Error
            response = {
                "success": False,
                "diff": f"Unhandled Error during Aider execution: {str(e)}",
            }
    
        formatted_response = _format_response(response)
        logger.info(
            f"code_with_aider process completed. Success: {response.get('success')}"
        )
        logger.info(
            f"Formatted response: {formatted_response}"
        )  # Log complete response for debugging
        return formatted_response
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Run Aider' implies execution and potential code modification, the description doesn't disclose critical behavioral traits: whether this tool makes permanent changes to files, what permissions are required, error handling, rate limits, or what happens when execution completes. For a tool that appears to modify code files, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence that efficiently communicates the core functionality. Every word earns its place with no redundancy or unnecessary elaboration. It's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that this appears to be a code execution/modification tool with no annotations, no output schema, and 4 parameters, the description is insufficiently complete. It doesn't explain what happens after execution, what the return values might be, error conditions, or safety considerations for a tool that presumably edits files. The single sentence description leaves too many important questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the input schema already documents all 4 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain relationships between parameters, provide examples, or clarify edge cases. The baseline of 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Run Aider to perform AI coding tasks based on the provided prompt and files'. It specifies the verb ('Run Aider') and resource ('AI coding tasks'), but doesn't differentiate from its only sibling 'list_models', which is a different type of tool. The purpose is clear but lacks sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, appropriate contexts, or exclusions. With a sibling tool 'list_models' available, there's no indication of when to choose one over the other or if they're complementary.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/disler/aider-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server