Skip to content

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

Conversation

Ethan0456
Copy link
Contributor

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

…sponse (microsoft#6471)

Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com>
@Ethan0456 Ethan0456 changed the title Add support for specifying the languages to parse from the CodeExecutorAgent response (#6471) Add support for specifying the languages to parse from the CodeExecutorAgent response May 25, 2025
@victordibia victordibia requested a review from Copilot May 27, 2025 22:28
Copy link
Contributor

@Copilot Copilot AI left a 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]*?)```")

Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.54%. Comparing base (03394a4) to head (3f8b673).
Report is 1 commits behind head on main.

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           
Flag Coverage Δ
unittests 79.54% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Ethan0456 and others added 4 commits May 28, 2025 19:21
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>
@victordibia victordibia self-assigned this May 28, 2025
@victordibia victordibia self-requested a review May 28, 2025 21:03
@victordibia victordibia merged commit 955f4f9 into microsoft:main May 28, 2025
64 checks passed
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.

CodeExecutorAgent should be able to ignore certain languages
2 participants