π OpenHands: AI-Driven Development
fix summaries (#191)
Robert Brennan134cc2bc8496
diff --git a/agenthub/langchains_agent/__init__.py b/agenthub/langchains_agent/__init__.pyindex f504b234c4..44d5a78b02 100644--- a/agenthub/langchains_agent/__init__.py+++ b/agenthub/langchains_agent/__init__.py@@ -66,9 +66,6 @@ INITIAL_THOUGHTS = []-MAX_OUTPUT_LENGTH = 5000-MAX_MONOLOGUE_LENGTH = 20000-class LangchainsAgent(Agent):_initialized = Falsediff --git a/agenthub/langchains_agent/utils/monologue.py b/agenthub/langchains_agent/utils/monologue.pyindex 74b2f8e97b..7bb2939646 100644--- a/agenthub/langchains_agent/utils/monologue.py+++ b/agenthub/langchains_agent/utils/monologue.py@@ -26,8 +26,10 @@ class Monologue:def condense(self, llm):try:prompt = prompts.get_summarize_monologue_prompt(self.thoughts)- response = llm.prompt(prompt)- self.thoughts = prompts.parse_summary_response(response)+ messages = [{"content": prompt,"role": "user"}]+ resp = llm.completion(messages=messages)+ summary_resp = resp['choices'][0]['message']['content']+ self.thoughts = prompts.parse_summary_response(summary_resp)except Exception as e:# Consider logging the error here instead of or in addition to raising an exceptionraise RuntimeError(f"Error condensing thoughts: {e}")diff --git a/agenthub/langchains_agent/utils/prompts.py b/agenthub/langchains_agent/utils/prompts.pyindex 0520cc6254..1c7f297d20 100644--- a/agenthub/langchains_agent/utils/prompts.py+++ b/agenthub/langchains_agent/utils/prompts.py@@ -22,6 +22,7 @@ from opendevin.action import (AgentRecallAction,AgentThinkAction,AgentFinishAction,+ AgentSummarizeAction,)from opendevin.observation import (CmdOutputObservation,@@ -36,6 +37,7 @@ ACTION_TYPE_TO_CLASS: Dict[str, Type[Action]] = {"write": FileWriteAction,"recall": AgentRecallAction,"think": AgentThinkAction,+ "summarize": AgentSummarizeAction,"finish": AgentFinishAction,}CLASS_TO_ACTION_TYPE: Dict[Type[Action], str] = {v: k for k, v in ACTION_TYPE_TO_CLASS.items()}diff --git a/opendevin/action/__init__.py b/opendevin/action/__init__.pyindex 814842cac5..9fe6f12354 100644--- a/opendevin/action/__init__.py+++ b/opendevin/action/__init__.py@@ -2,7 +2,7 @@ from .base import Action, NullActionfrom .bash import CmdRunAction, CmdKillActionfrom .browse import BrowseURLActionfrom .fileop import FileReadAction, FileWriteAction-from .agent import AgentRecallAction, AgentThinkAction, AgentFinishAction, AgentEchoAction+from .agent import AgentRecallAction, AgentThinkAction, AgentFinishAction, AgentEchoAction, AgentSummarizeAction__all__ = ["Action",@@ -16,4 +16,5 @@ __all__ = ["AgentThinkAction","AgentFinishAction","AgentEchoAction",+ "AgentSummarizeAction",]diff --git a/opendevin/action/agent.py b/opendevin/action/agent.pyindex c040ec93a8..13a4d2ec7d 100644--- a/opendevin/action/agent.py+++ b/opendevin/action/agent.py@@ -48,6 +48,13 @@ class AgentEchoAction(ExecutableAction):def message(self) -> str:return self.content+@dataclass+class AgentSummarizeAction(NotExecutableAction):+ summary: str++ @property+ def message(self) -> str:+ return self.summary@dataclassclass AgentFinishAction(NotExecutableAction):@@ -59,3 +66,4 @@ class AgentFinishAction(NotExecutableAction):@propertydef message(self) -> str:return "All done! What's next on the agenda?"+