Skip to content

Conversation

@aditisingh02
Copy link

@aditisingh02 aditisingh02 commented Jan 20, 2026

Why are these changes needed?

This PR addresses a TODO in autogen/code_utils.py to make the infer_lang() function more robust.

The previous implementation relied on a simple heuristic that only detected shell code if it started strictly with python , pip, or python3 . This missed many common shell scenarios and shebang-based scripts.

Improvements included in this PR:

  • Shebang Detection: Added support for checking shebang lines (e.g., #!/bin/bash, #!/usr/bin/python) to accurately identify the language
  • Expanded Shell Patterns: Significantly expanded the list of shell command patterns to include common commands like cd, ls, mkdir, git, npm, curl, wget, grep, etc.
  • Robustness: Added handling for empty input and whitespace stripping before pattern matching
  • Documentation: Added a proper docstring with Args and Returns

Related issue number

Note: This enhancement was originally proposed in the FLAML repository. As per @thinkall's guidance, raising it here since autogen has moved to this repository.

Checks

@aditisingh02 aditisingh02 changed the base branch from main to 0.2 January 20, 2026 18:26
@aditisingh02 aditisingh02 changed the title 0.2 feat: improve infer_lang() robustness with shebang and shell pattern detection Jan 20, 2026
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.

1 participant