oraios/serena · error · ValueError
Cannot use interactive mode with asynchronous auto-generatio
Error message
Cannot use interactive mode with asynchronous auto-generation
What it means
ProjectConfig.autogenerate() can run interactively (asking the user questions via CLI) or asynchronously (determining languages in a background thread). These modes are mutually exclusive because background initialization cannot prompt the user, so passing both interactive=True and asynchronous=True raises this ValueError immediately.
Source
Thrown at src/serena/config/serena_config.py:438
interactive: bool = False,
asynchronous: bool = False,
) -> Self:
"""
Autogenerate a project configuration for a given project root.
:param project_root: the path to the project root
:param serena_config: the global Serena configuration
:param project_name: the name of the project; if None, the name of the project will be the name of the directory
containing the project
:param languages: the languages of the project; if None, they will be determined automatically
:param save_to_disk: whether to save the project configuration to disk
:param interactive: whether to run in interactive CLI mode, asking the user for input where appropriate
:param asynchronous: whether to run in asynchronous mode, where time-consuming configuration parts (currently only the
determination of the list of programming languages) are determined in a background thread and initialised as empty
:return: the project configuration
"""
if interactive and asynchronous:
raise ValueError("Cannot use interactive mode with asynchronous auto-generation")
project_root = Path(project_root).resolve()
if not project_root.exists():
raise FileNotFoundError(f"Project root not found: {project_root}")
with LogTime("Project configuration auto-generation", logger=log):
log.info("Project root: %s", project_root)
project_folder_name = project_root.name
project_name = project_name or project_folder_name
use_asynchronous_language_determination = False
if languages is None:
if asynchronous:
use_asynchronous_language_determination = True
languages_to_use = [] # temporarily empty, will be determined in background thread
else:
determined_languages = cls._determine_project_language_servers(
str(project_root), interactive=interactive, serena_config=serena_config
)
languages_to_use = [l.value for l in determined_languages]
else:View on GitHub (pinned to 7fcbca7e62)
Solutions
- Set asynchronous=False if you want the interactive Q&A flow (language detection happens synchronously).
- Set interactive=False (accept defaults) if you want fast asynchronous auto-generation.
- If you call autogenerate from your own wrapper, make the two flags mutually exclusive before invoking it.
- Resolve the project_root beforehand and confirm it exists, since autogenerate also raises FileNotFoundError otherwise.
Example fix
// before config = ProjectConfiguration.autogenerate(project_root, interactive=True, asynchronous=True) // after config = ProjectConfiguration.autogenerate(project_root, interactive=True, asynchronous=False)
Defensive patterns
Strategy: validation
Validate before calling
def validate_autogenerate_args(interactive: bool, asynchronous: bool) -> None:
if interactive and asynchronous:
raise ValueError("interactive and asynchronous are mutually exclusive; pick one.")
# call before autogenerate:
validate_autogenerate_args(interactive, asynchronous) Type guard
def is_valid_autogenerate_mode(interactive: bool, asynchronous: bool) -> bool:
return not (interactive and asynchronous) Try / catch
try:
config = ProjectConfiguration.autogenerate(project_root, interactive=interactive, asynchronous=asynchronous)
except ValueError as e:
if "interactive" in str(e):
config = ProjectConfiguration.autogenerate(project_root, interactive=True, asynchronous=False)
else:
raise Prevention
- Treat interactive and asynchronous as mutually exclusive flags in wrappers/CLIs.
- Default to asynchronous=False for CLI tools where prompting is expected.
- Resolve and verify project_root exists before calling autogenerate (it also raises FileNotFoundError).
- Centralize flag parsing so conflicting boolean options are rejected at argument-parse time.
When it happens
Trigger: Calling ProjectConfiguration.autogenerate(project_root, interactive=True, asynchronous=True), or a code path (e.g. _create_project) that enables interactivity while async auto-generation was requested, including via serena's project creation CLI flags combining an interactive prompt with async generation.
Common situations: Scripting project creation with async generation enabled while also passing an interactive flag; combining CLI options like --interactive with an async setting in tooling that wraps autogenerate(); copying a call example and adding a second option.
Related errors
- Context file not found: {path.resolve()}
- Cannot use both fixed_tools and excluded_tools/included_opti
- Unknown language backend '{backend_str}': valid values are {
- Invalid line_ending: {value!r}. Valid values are: {valid}
- Project root not found: {project_root}
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/fb1b9573e72199e4.
Report an issue: GitHub.