Skip to content

__name__ undefined when using CodeAgent #1229

@benediktstroebl

Description

@benediktstroebl

@albertvillanova @aymeric-roucher

I ran into the issue that when using CodeAgent on a task that requires the agent to produce Python code, it often attempts to test the code it generates not with the PythonInterpreter tool but by directly running it.

This seems fine but the CodeAgent implementation raises an error that variable __name__ is undefined when the agent includes the if __name__ == "__main__": clause in the code.

I am unsure why that is and whether there is any reason for that vs. it being a bug. I included a screenshot with the error message below.

Would love to hear your thoughts on this. Thanks!

Image

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions