agent_config.py 975 B

123456789101112131415161718192021222324252627
  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. micro_agent_name: The name of the micro agent to use for this agent.
  8. memory_enabled: Whether long-term memory (embeddings) is enabled.
  9. memory_max_threads: The maximum number of threads indexing at the same time for embeddings.
  10. llm_config: The name of the llm config to use. If specified, this will override global llm config.
  11. """
  12. micro_agent_name: str | None = None
  13. memory_enabled: bool = False
  14. memory_max_threads: int = 3
  15. llm_config: str | None = None
  16. def defaults_to_dict(self) -> dict:
  17. """Serialize fields to a dict for the frontend, including type hints, defaults, and whether it's optional."""
  18. result = {}
  19. for f in fields(self):
  20. result[f.name] = get_field_info(f)
  21. return result