Skip to content

CodeExecutorAgent should be able to ignore certain languages #6471

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

Open
yidasanqian opened this issue May 6, 2025 · 3 comments
Open

CodeExecutorAgent should be able to ignore certain languages #6471

yidasanqian opened this issue May 6, 2025 · 3 comments

Comments

@yidasanqian
Copy link

yidasanqian commented May 6, 2025

What happened?

Describe the bug
code executor throw Unsupported language: echarts
To Reproduce

code_executor_agent = CodeExecutorAgent(
            name="code_executor", code_executor=code_executor
        )

        assistant_agent = AssistantAgent(
            name="coder_agent",
            model_client=self.model_client,
            system_message=DEFAULT_SYSTEM_MESSAGE,
            model_client_stream=True,
        )

        # The termination condition is a combination of text termination and max message termination, either of which will cause the chat to terminate.
        termination = TextMentionTermination("TERMINATE") | MaxMessageTermination(20)

        # The group chat will alternate between the assistant and the code executor.
        self.group_chat = RoundRobinGroupChat(
            [assistant_agent, code_executor_agent], termination_condition=termination
        )

When the model generates an ECharts code block in Markdown format (```echarts), the following exception is thrown:

    |     async for message in self.group_chat.run_stream(
    |   File "d:\Develop\conda\envs\ai_table\Lib\site-packages\autogen_agentchat\teams\_group_chat\_base_group_chat.py", line 518, in run_stream
    |     raise RuntimeError(str(message.error))
    | RuntimeError: ValueError: Unsupported language: echarts
    | Traceback:
    | Traceback (most recent call last):
    |
    |   File "d:\Develop\conda\envs\ai_table\Lib\site-packages\autogen_agentchat\teams\_group_chat\_chat_agent_container.py", line 79, in handle_request
    |     async for msg in self._agent.on_messages_stream(self._message_buffer, ctx.cancellation_token):
    |
    |   File "d:\Develop\conda\envs\ai_table\Lib\site-packages\autogen_agentchat\agents\_code_executor_agent.py", line 427, in on_messages_stream
    |     execution_result = await self.execute_code_block(code_blocks, cancellation_token)
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    |   File "d:\Develop\conda\envs\ai_table\Lib\site-packages\autogen_agentchat\agents\_code_executor_agent.py", line 576, in execute_code_block
    |     result = await self._code_executor.execute_code_blocks(code_blocks, cancellation_token=cancellation_token)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    |   File "d:\Develop\conda\envs\ai_table\Lib\site-packages\autogen_ext\code_executors\docker\_docker_code_executor.py", line 403, in execute_code_blocks
    |     return await self._execute_code_dont_check_setup(code_blocks, cancellation_token)
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    |   File "d:\Develop\conda\envs\ai_table\Lib\site-packages\autogen_ext\code_executors\docker\_docker_code_executor.py", line 344, in _execute_code_dont_check_setup
    |     command = ["timeout", str(self._timeout), lang_to_cmd(lang), filename]
    |                                               ^^^^^^^^^^^^^^^^^
    |
    |   File "d:\Develop\conda\envs\ai_table\Lib\site-packages\autogen_ext\code_executors\_common.py", line 171, in lang_to_cmd
    |     raise ValueError(f"Unsupported language: {lang}")
    |
    | ValueError: Unsupported language: echarts

Expected behavior
Unsupported code should not be executed.

Which packages was the bug in?

Python AgentChat (autogen-agentchat>=0.4.0)

AutoGen library version.

Python 0.5.6

Other library version.

No response

Model used

No response

Model provider

Azure OpenAI

Other model provider

No response

Python version

3.10

.NET version

None

Operating system

Windows

@jackgerrits
Copy link
Member

What is your scenario here? Are there other code blocks you need to execute that are generated in addition to the echarts one?

@yidasanqian
Copy link
Author

What is your scenario here? Are there other code blocks you need to execute that are generated in addition to the echarts one?

There are also Python and Shell code blocks, but the ECharts code block is used for frontend display. The code executor should not execute the ECharts code block.
Can the code executor skip unsupported code blocks instead of throwing errors?

@jackgerrits
Copy link
Member

Thanks for the info. I think the required fix here is that the CodeExecutorAgent should be able to specify either explicit languages to include or exclude.

Are you interested in contributing this change?

@jackgerrits jackgerrits changed the title ValueError: Unsupported language CodeExecutorAgent should be able to ignore certain languages May 7, 2025
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

No branches or pull requests

2 participants