-
Notifications
You must be signed in to change notification settings - Fork 7k
Add support for specifying the languages to parse from the CodeExecutorAgent
response
#6592
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
Add support for specifying the languages to parse from the CodeExecutorAgent
response
#6592
Conversation
…sponse (microsoft#6471) Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com>
CodeExecutorAgent
response (#6471)CodeExecutorAgent
response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR lets users specify which languages to parse from CodeExecutorAgent
responses to prevent executing unsupported code blocks.
- Added
supported_languages
to the agent config with a default of["python", "bash"]
- Built a dynamic regex from
supported_languages
to filter Markdown code fences - Persisted
supported_languages
in_to_config
and_from_config
Comments suppressed due to low confidence (1)
python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py:603
- No tests cover scenarios where code blocks have unsupported languages or no language tag. Add tests to verify these cases are properly ignored.
pattern = re.compile(rf"```(?:\s*({self._supported_languages_regex}))\n([\s\S]*?)```")
python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
Outdated
Show resolved
Hide resolved
python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
Outdated
Show resolved
Hide resolved
python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
Show resolved
Hide resolved
python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6592 +/- ##
=======================================
Coverage 79.53% 79.54%
=======================================
Files 225 225
Lines 16656 16662 +6
=======================================
+ Hits 13248 13254 +6
Misses 3408 3408
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com>
…NGUAGES` constant Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com>
Why are these changes needed?
The
CodeExecutorAgent
can generate code blocks in various programming languages, some of which may not be supported by the executor environment. Adding support for specifying languages to be parsed helps users ignore unnecessary code blocks, preventing potential execution errors.Related issue number
Closes #6471
Checks