Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Markdown output confuses aider if backtick fencing is used. #2424

Open
eugr opened this issue Nov 22, 2024 · 5 comments
Open

Generated Markdown output confuses aider if backtick fencing is used. #2424

eugr opened this issue Nov 22, 2024 · 5 comments
Labels
question Further information is requested

Comments

@eugr
Copy link

eugr commented Nov 22, 2024

Issue

Asked to generate README for my repository and caused a glitch in aider after the first closing backticks and resulted in it creating a bunch of unnecessary files instead, as the rest was treated not as actual Markdown file, but as guidance for aider itself.

Command: /architect create README describing scripts in this repository and how to use them (including how to set environment variables)

Output (redacted to remove sensitive information):

 # (title redacted)                                                                                                                                                                    
                                                                                                                                                                                                                
 This repository contains scripts to (redacted). The scripts are designed to be run in a Unix-like environment with access to the AWS CLI and jq.                         
                                                                                                                                                                                                                
 ## Prerequisites                                                                                                                                                                                               
                                                                                                                                                                                                                
 1. **AWS CLI**: Ensure that the AWS CLI is installed and configured on your machine.                                                                                                                           
 2. **jq**: Install `jq` for JSON processing. You can install it using:                                                                                                                                         
    ```sh                                                                                                                                                                                                       
    sudo apt-get install jq  # For Debian/Ubuntu                                                                                                                                                                
    brew install jq          # For macOS                                                                                                                                                                        
----------- (this is where it broke, the closing ticks were never displayed and the white background stopped here) ------------
    ```                     
                                                                                                                                                                                           
 3 IAM Permissions: Ensure that the IAM role or user running these scripts has the necessary permissions

Version and model info

Aider v0.63.2
Model: ollama/qwen2.5-coder-tools-14b-32768:latest with whole edit format
Git repo: .git with 6 files
Repo-map: using 1024 tokens, auto refresh
VSCode terminal detected, pretty output has been disabled.

@paul-gauthier
Copy link
Collaborator

Thanks for trying aider and filing this issue. This doc may be helpful:

https://aider.chat/docs/troubleshooting/edit-errors.html

@eugr
Copy link
Author

eugr commented Nov 22, 2024

Yes, but it doesn't address the issue. The main advice there is to try more capable model, but I also tried with GPT-4o and Claude Sonnet 3.5, and both produced the same result. It makes sense, because Aider relies on backticks as code blocks boundaries, and they work OK unless there are embedded backticks such as when generating Markdown.

I think it would be better to switch to XML tags and not rely on backticks to designate code blocks. Most models are trained on tool usage, and XML tags will give more flexibility to aider and will be more reliable at the end.

Another (probably simpler to implement) option would be to use more backticks to designate code blocks.

@paul-gauthier
Copy link
Collaborator

Aider uses a different set of fences when editing files with triple-backtick fences. Can you show me a clear example of output with a strong model like Sonnet that demonstrates the problem you are experiencing?

@eugr
Copy link
Author

eugr commented Nov 22, 2024

OK, here is output from my playground repo without pretty print using Sonnet:

$ aider --no-pretty

Aider v0.63.2
Main model: claude-3-5-sonnet-20241022 with diff edit format, infinite output
Weak model: claude-3-5-haiku-20241022
Git repo: .git with 10 files
Repo-map: using 1024 tokens, auto refresh
VSCode terminal detected, pretty output has been disabled.
Use /help <question> for help, run "aider --help" to see cmd line args

> /architect generate a README file describing scripts and their command line arguments

I'll help create a README.md file that documents the scripts and their usage. Based on the file summaries shown, here are the instructions:

Create a new file `README.md` with this content:

```markdown
# Email Processing Scripts

A collection of utilities for processing, summarizing, and managing emails.

## Scripts

### process_unread_emails.py
Process and summarize unread emails.

```bash
python process_unread_emails.py --maildir PATH --db PATH [--ollama-url URL] [--verbose]
```

Arguments:

Here is how it looks like on the screen with pretty print:

aider_markdown_screenshot

@eugr
Copy link
Author

eugr commented Nov 22, 2024

As you can see, it uses the same triple backtick fencing. After it sees the first closing backtick, it interprets the rest of output as general stream, and then proceeds to ask whether I want to create a bunch of files.

I think I know what happened. You said it uses different set of fences when EDITING files with fences, but in this case it creates a new file, so it doesn't really know.

@paul-gauthier paul-gauthier added the question Further information is requested label Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants