agent_config.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  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. """
  16. function_calling: bool = True
  17. codeact_enable_browsing: bool = True
  18. codeact_enable_llm_editor: bool = False
  19. codeact_enable_jupyter: bool = True
  20. micro_agent_name: str | None = None
  21. memory_enabled: bool = False
  22. memory_max_threads: int = 3
  23. llm_config: str | None = None
  24. def defaults_to_dict(self) -> dict:
  25. """Serialize fields to a dict for the frontend, including type hints, defaults, and whether it's optional."""
  26. result = {}
  27. for f in fields(self):
  28. result[f.name] = get_field_info(f)
  29. return result