agent_config.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from dataclasses import dataclass, fields
  2. from openhands.core.config.config_utils import get_field_info
  3. @dataclass
  4. class AgentConfig:
  5. """Configuration for the agent.
  6. Attributes:
  7. function_calling: Whether function calling is enabled. Default is True.
  8. codeact_enable_browsing: Whether browsing delegate is enabled in the action space. Default is False. Only works with function calling.
  9. codeact_enable_llm_editor: Whether LLM editor is enabled in the action space. Default is False. Only works with function calling.
  10. codeact_enable_jupyter: Whether Jupyter is enabled in the action space. Default is False.
  11. micro_agent_name: The name of the micro agent to use for this agent.
  12. memory_enabled: Whether long-term memory (embeddings) is enabled.
  13. memory_max_threads: The maximum number of threads indexing at the same time for embeddings.
  14. llm_config: The name of the llm config to use. If specified, this will override global llm config.
  15. use_microagents: Whether to use microagents at all. Default is True.
  16. disabled_microagents: A list of microagents to disable. Default is None.
  17. """
  18. codeact_enable_browsing: bool = True
  19. codeact_enable_llm_editor: bool = False
  20. codeact_enable_jupyter: bool = True
  21. micro_agent_name: str | None = None
  22. memory_enabled: bool = False
  23. memory_max_threads: int = 3
  24. llm_config: str | None = None
  25. use_microagents: bool = True
  26. disabled_microagents: list[str] | None = None
  27. def defaults_to_dict(self) -> dict:
  28. """Serialize fields to a dict for the frontend, including type hints, defaults, and whether it's optional."""
  29. result = {}
  30. for f in fields(self):
  31. result[f.name] = get_field_info(f)
  32. return result