Skip to content

get_file_contents tool should have non-base64 option #372

Description

@ashwin-ant

Describe the feature or problem you’d like to solve

The get_file_contents tool currently returns file contents in base64. This matches the backing API, but it'd be nice to have a non-base64 option for this. The corresponding create_or_update_file tool accept plaintext, even though the backing API only allows base64.

Proposed solution

This would create interface consistency and probably lead to better model performance with the tool.

Additional context

I'm happy to send a PR for this if there's a recommended approach I should take!

Activity

  1. bratorange commented on May 7, 2025

    @bratorange

    +1

  2. Coffee-Boyy commented on May 9, 2025

    @Coffee-Boyy

    I seriously thought I was going crazy when gpt-4o-mini was making up example code after knowingly reading the file contents and I explicitly instructed it to reference code from the repo. Turns out this was the problem. Made a fix locally and it works as expected now.

    For reference, I changed the following:

    var result interface{}
    if fileContent != nil {
    result = fileContent
    } else {
    result = dirContent
    }

    to:

    var result interface{}
    if fileContent != nil {
        result, err = fileContent.GetContent()
        if err != nil {
            return nil, fmt.Errorf("failed to get file content: %w", err)
        }
    } else {
        result = dirContent
    }
    
  3. dijonkitchen commented on May 9, 2025

    @dijonkitchen

    Does having it in base64 also increase the token usage?

  4. rdmueller commented on Jun 2, 2025

    @rdmueller

    Does having it in base64 also increase the token usage?

    yes. The model has to write code in which it reproduces the base64 file. This code will then produce the original file. This is 3x token usage.

  5. added a commit that references this issue on Jun 10, 2025
    ab8eb71
  6. SamMorrowDrums commented on Jun 12, 2025

    @SamMorrowDrums
    Collaborator

    Binary content is meant to be base64 encoded, and text content should not be. I have fixed this by using the raw API properly. It's been a TODO for me for ages, finally got round to it: #505

    Things should be faster, and less brittle too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions