Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix delegator LLM config when config is set from UI (#2913)

Boxuan Lif249254ba4ef
diff --git a/opendevin/server/session/agent.py b/opendevin/server/session/agent.py
index 12f9f14e7d..2c76d6f19d 100644
--- a/opendevin/server/session/agent.py
+++ b/opendevin/server/session/agent.py
@@ -81,18 +81,25 @@ class AgentSession:
if value != ''
} # remove empty values, prevent FE from sending empty strings
agent_cls = args.get(ConfigType.AGENT, config.default_agent)
- llm_config = config.get_llm_config_from_agent(agent_cls)
- model = args.get(ConfigType.LLM_MODEL, llm_config.model)
- api_key = args.get(ConfigType.LLM_API_KEY, llm_config.api_key)
- api_base = llm_config.base_url
confirmation_mode = args.get(
ConfigType.CONFIRMATION_MODE, config.confirmation_mode
)
max_iterations = args.get(ConfigType.MAX_ITERATIONS, config.max_iterations)
- logger.info(f'Creating agent {agent_cls} using LLM {model}')
- llm = LLM(model=model, api_key=api_key, base_url=api_base)
+ # override default LLM config
+ default_llm_config = config.get_llm_config()
+ default_llm_config.model = args.get(
+ ConfigType.LLM_MODEL, default_llm_config.model
+ )
+ default_llm_config.api_key = args.get(
+ ConfigType.LLM_API_KEY, default_llm_config.api_key
+ )
+
+ # TODO: override other LLM config & agent config groups (#2075)
+
+ llm = LLM(llm_config=config.get_llm_config_from_agent(agent_cls))
agent = Agent.get_cls(agent_cls)(llm)
+ logger.info(f'Creating agent {agent.name} using LLM {llm}')
if isinstance(agent, CodeActAgent):
if not self.runtime or not (
isinstance(self.runtime, ServerRuntime)