Skip to content

Conversation

@callmephilip
Copy link
Contributor

@callmephilip callmephilip commented Jul 26, 2025

The current action parser incorrectly parses actions that include nested bash commands in heredocs. Here's an example of this happening in the wild. This is problematic for documentation generation and probably some other spicy use cases.

This is an attempt at fixing this

@klieret
Copy link
Member

klieret commented Jul 26, 2025

Ah I see, yeah that's a bit problematic.
I appreciate you raising this and adding the PR!

However, my viewpoint is that the current implementation is correct, in that the model is told exactly what it has to expect and should realize itself what the problem is. It can still effectively do these edits in two steps (e.g., first inserting TRIPLEBACKTICKSbash and then following up with another sed command to turn them into real triple backticks).
Admittedly, that's not the most efficient way.

But I think this issue really points more towards maybe using a custom XML tag that is extremely unlikely to appear outside of this codebase.

@callmephilip
Copy link
Contributor Author

yeah, this sounds reasonable. i'll take a newer version for a spin to see if the new prompt works

@doehyunbaek
Copy link

Just in case anyone needs it, this is the only code you need to support custom xml based action parsing (with config change of format_error_template). It's a single line change of regex.

class DefaultAgentXML(DefaultAgent):
    def parse_action(self, response: dict) -> dict:
        """Parse the action from the message. Returns the action."""
        actions = re.findall(r"<mini_swe_agent_bash>\n(.*?)\n</mini_swe_agent_bash>", response["content"], re.DOTALL)
        if len(actions) == 1:
            return {"action": actions[0].strip(), **response}
        raise FormatError(self.render_template(self.config.format_error_template, actions=actions))

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

Successfully merging this pull request may close these issues.

3 participants