Store CodeAgent code outputs in ActionStep by aymeric-roucher · Pull Request #1463 · huggingface/smolagents (original) (raw)

albertvillanova

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just a question: why self.code_action is not included in self.to_messages?

Some suggested fixes below.

assert output == "got an error"
assert ' print("Failing due to unexpected indent")' in str(agent.memory.steps)
assert isinstance(agent.memory.steps[-2], ActionStep)
assert str(agent.memory.steps[-2].code_output) == str("""a = 2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use str() in both sides of the equality assertion?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really needed, but makes for a more compact code (ruff reformats the thing with a breakline when not adding str on the right side)