mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
(enh) Improve CodeActAgent's file editing reliability (#3610)
* improve file editing prompts and unit test converted most raise calls to a _output_error call in file_ops.py * tweaks in test_agent_skill.py wrt to SEP separator * tweaked the separator * remove server runtime remnants and TEST_RUNTIME references * restore use of TEST_RUNTIME args and variables * fix integration tests * added hint to properly escape docstrings * revert latest prompt change --------- Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
This commit is contained in:
@@ -47,7 +47,7 @@ class AgentSession:
|
||||
start_event: The start event data (optional).
|
||||
"""
|
||||
if self.controller or self.runtime:
|
||||
raise Exception(
|
||||
raise RuntimeError(
|
||||
'Session already started. You need to close this session and start a new one.'
|
||||
)
|
||||
await self._create_security_analyzer(config.security.security_analyzer)
|
||||
@@ -87,7 +87,7 @@ class AgentSession:
|
||||
if self.runtime is not None:
|
||||
raise Exception('Runtime already created')
|
||||
|
||||
logger.info(f'Using runtime: {runtime_name}')
|
||||
logger.info(f'Initializing runtime `{runtime_name}` now...')
|
||||
runtime_cls = get_runtime_cls(runtime_name)
|
||||
self.runtime = runtime_cls(
|
||||
config=config,
|
||||
@@ -107,9 +107,11 @@ class AgentSession:
|
||||
):
|
||||
"""Creates an AgentController instance."""
|
||||
if self.controller is not None:
|
||||
raise Exception('Controller already created')
|
||||
raise RuntimeError('Controller already created')
|
||||
if self.runtime is None:
|
||||
raise Exception('Runtime must be initialized before the agent controller')
|
||||
raise RuntimeError(
|
||||
'Runtime must be initialized before the agent controller'
|
||||
)
|
||||
|
||||
logger.info(f'Agents: {agent_configs}')
|
||||
logger.info(f'Creating agent {agent.name} using LLM {agent.llm.config.model}')
|
||||
@@ -135,3 +137,4 @@ class AgentSession:
|
||||
logger.info(f'Restored agent state from session, sid: {self.sid}')
|
||||
except Exception as e:
|
||||
logger.info(f'Error restoring state: {e}')
|
||||
logger.info('Agent controller initialized.')
|
||||
|
||||
Reference in New Issue
Block a user