You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for specifying the languages to parse from the CodeExecutorAgent response (#6592)
## 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
- [x] I've included any doc changes needed for
<https://microsoft.github.io/autogen/>. See
<https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to
build and test documentation locally.
- [x] I've added tests (if relevant) corresponding to the changes
introduced in this PR.
- [x] I've made sure all auto checks have passed.
---------
Signed-off-by: Abhijeetsingh Meena <abhijeet040403@gmail.com>
Co-authored-by: Victor Dibia <victordibia@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
+15-1Lines changed: 15 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,7 @@ class CodeExecutorAgentConfig(BaseModel):
54
54
system_message: str|None=None
55
55
model_client_stream: bool=False
56
56
model_context: ComponentModel|None=None
57
+
supported_languages: List[str] |None=None
57
58
58
59
59
60
classRetryDecision(BaseModel):
@@ -110,6 +111,8 @@ class CodeExecutorAgent(BaseChatAgent, Component[CodeExecutorAgentConfig]):
110
111
This is only used if `model_client` is not provided.
111
112
max_retries_on_error (int, optional): The maximum number of retries on error. If the code execution fails, the agent will retry up to this number of times.
112
113
If the code execution fails after this number of retries, the agent will yield a reflection result.
114
+
supported_languages (List[str], optional): List of programming languages that will be parsed and executed from agent response;
115
+
others will be ignored. Defaults to DEFAULT_SUPPORTED_LANGUAGES.
113
116
114
117
115
118
.. note::
@@ -329,6 +332,7 @@ async def main() -> None:
329
332
DEFAULT_AGENT_DESCRIPTION="A Code Execution Agent that generates and executes Python and shell scripts based on user instructions. It ensures correctness, efficiency, and minimal errors while gracefully handling edge cases."
330
333
DEFAULT_SYSTEM_MESSAGE="You are a Code Execution Agent. Your role is to generate and execute Python code and shell scripts based on user instructions, ensuring correctness, efficiency, and minimal errors. Handle edge cases gracefully. Python code should be provided in ```python code blocks, and sh shell scripts should be provided in ```sh code blocks for execution."
331
334
NO_CODE_BLOCKS_FOUND_MESSAGE="No code blocks found in the thread. Please provide at least one markdown-encoded code block to execute (i.e., quoting code in ```python or ```sh code blocks)."
0 commit comments