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

ToolUseBlock.input returns string instead of object/dict #804

Open
mathislucka opened this issue Dec 27, 2024 · 0 comments
Open

ToolUseBlock.input returns string instead of object/dict #804

mathislucka opened this issue Dec 27, 2024 · 0 comments

Comments

@mathislucka
Copy link

I'm using Sonnet-3.5 with a tool similar to the file editor described here: https://www.anthropic.com/research/swe-bench-sonnet

I run into an issue where sometimes instead of returning an object as a key of the ToolUseBlock.input the client returns a string.

Specifically, the string contains a python multiline string expression for the file editor content, original, or replacement payload.

So ToolUseBlock.input might look something like this:

'{"path": "path_to_file", "content": """This is some file content""", "message": "fix: file"}'

As shown in the referenced blog post, I'm prompting the model to pay attention to whitespace, which is why it might add the multiline string here.

The schema for my tool is the following:

{
    "properties": {
        "command": {
            "type": "string",
            "enum": ["edit", "create", "delete", "undo"],
            "description": "Operation to perform on the file"
        },
        "payload": {
            "type": "object",
            "description": """Command-specific parameters:
            - edit command requires: path, message, original, replacement
            - delete command requires: path, message
            - create command requires: path, message, content""",
            "properties": {
                "path": {
                    "type": "string",
                    "description": "Path to the file to operate on"
                },
                "message": {
                    "type": "string",
                    "description": "Commit message for the operation"
                },
                "content": {
                    "type": "string",
                    "description": "Content for file creation"
                },
                "original": {
                    "type": "string",
                    "description": "Original text to replace when editing"
                },
                "replacement": {
                    "type": "string",
                    "description": "New text to replace the original with when editing"
                }
            },
            "enum": ["path", "message", "content", "original", "replacement"]
        }
    },
    "required": ["command", "payload"],
    "type": "object"
}

It would be great if this could be fixed.

Alternatively, any recommendations to avoid this by making changes to my prompt or tools?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant