|
|
@@ -21,6 +21,7 @@ from opendevin.events.observation import (
|
|
|
CmdOutputObservation,
|
|
|
IPythonRunCellObservation,
|
|
|
)
|
|
|
+from opendevin.events.serialization.event import truncate_content
|
|
|
from opendevin.llm.llm import LLM
|
|
|
from opendevin.runtime.plugins import (
|
|
|
AgentSkillsRequirement,
|
|
|
@@ -60,7 +61,7 @@ def get_action_message(action: Action) -> dict[str, str] | None:
|
|
|
|
|
|
def get_observation_message(obs) -> dict[str, str] | None:
|
|
|
if isinstance(obs, CmdOutputObservation):
|
|
|
- content = 'OBSERVATION:\n' + truncate_observation(obs.content)
|
|
|
+ content = 'OBSERVATION:\n' + truncate_content(obs.content)
|
|
|
content += (
|
|
|
f'\n[Command {obs.command_id} finished with exit code {obs.exit_code}]'
|
|
|
)
|
|
|
@@ -75,28 +76,14 @@ def get_observation_message(obs) -> dict[str, str] | None:
|
|
|
' already displayed to user'
|
|
|
)
|
|
|
content = '\n'.join(splitted)
|
|
|
- content = truncate_observation(content)
|
|
|
+ content = truncate_content(content)
|
|
|
return {'role': 'user', 'content': content}
|
|
|
elif isinstance(obs, AgentDelegateObservation):
|
|
|
- content = 'OBSERVATION:\n' + truncate_observation(str(obs.outputs))
|
|
|
+ content = 'OBSERVATION:\n' + truncate_content(str(obs.outputs))
|
|
|
return {'role': 'user', 'content': content}
|
|
|
return None
|
|
|
|
|
|
|
|
|
-def truncate_observation(observation: str, max_chars: int = 10_000) -> str:
|
|
|
- """
|
|
|
- Truncate the middle of the observation if it is too long.
|
|
|
- """
|
|
|
- if len(observation) <= max_chars:
|
|
|
- return observation
|
|
|
- half = max_chars // 2
|
|
|
- return (
|
|
|
- observation[:half]
|
|
|
- + '\n[... Observation truncated due to length ...]\n'
|
|
|
- + observation[-half:]
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
# FIXME: We can tweak these two settings to create MicroAgents specialized toward different area
|
|
|
def get_system_message() -> str:
|
|
|
if ENABLE_GITHUB:
|