Skip to content

πŸ™Œ OpenHands: AI-Driven Development

updating web read tool description to explain masking (#8294)

Calvin Smithc982bc6692ee
diff --git a/openhands/agenthub/codeact_agent/tools/web_read.py b/openhands/agenthub/codeact_agent/tools/web_read.py
index db67b7b463..a7fbf140c0 100644
--- a/openhands/agenthub/codeact_agent/tools/web_read.py
+++ b/openhands/agenthub/codeact_agent/tools/web_read.py
@@ -3,6 +3,8 @@ from litellm import ChatCompletionToolParam, ChatCompletionToolParamFunctionChun
_WEB_DESCRIPTION = """Read (convert to markdown) content from a webpage. You should prefer using the `web_read` tool over the `browser` tool, but do use the `browser` tool if you need to interact with a webpage (e.g., click a button, fill out a form, etc.) OR read a webpage that contains images.
You may use the `web_read` tool to read text content from a webpage, and even search the webpage content using a Google search query (e.g., url=`https://www.google.com/search?q=YOUR_QUERY`).
+
+Only the most recently read webpage will be available to read. This means you should not follow a link to a new page until you are done with the information on the current page.
"""
WebReadTool = ChatCompletionToolParam(
diff --git a/openhands/memory/condenser/impl/browser_output_condenser.py b/openhands/memory/condenser/impl/browser_output_condenser.py
index ed5e693e6b..56e7fad8cd 100644
--- a/openhands/memory/condenser/impl/browser_output_condenser.py
+++ b/openhands/memory/condenser/impl/browser_output_condenser.py
@@ -28,7 +28,7 @@ class BrowserOutputCondenser(Condenser):
):
results.append(
AgentCondensationObservation(
- f'Current URL: {event.url}\nContent Omitted'
+ f'Visited URL {event.url}\nContent omitted'
)
)
else:
diff --git a/openhands/server/session/session.py b/openhands/server/session/session.py
index d53bbb0033..790907621c 100644
--- a/openhands/server/session/session.py
+++ b/openhands/server/session/session.py
@@ -138,7 +138,7 @@ class Session:
# output, which should keep the summarization cost down.
default_condenser_config = CondenserPipelineConfig(
condensers=[
- BrowserOutputCondenserConfig(),
+ BrowserOutputCondenserConfig(attention_window=2),
LLMSummarizingCondenserConfig(
llm_config=llm.config, keep_first=4, max_size=80
),
diff --git a/tests/unit/test_condenser.py b/tests/unit/test_condenser.py
index 2ce90e407e..4eb3616c05 100644
--- a/tests/unit/test_condenser.py
+++ b/tests/unit/test_condenser.py
@@ -261,9 +261,9 @@ def test_browser_output_condenser_respects_attention_window():
assert len(result) == len(events)
cnt = 4
for event, condensed_event in zip(events, result):
- if isinstance(event, BrowserOutputObservation):
+ if isinstance(event, (BrowserOutputObservation, AgentCondensationObservation)):
if cnt > attention_window:
- assert 'Content Omitted' in str(condensed_event)
+ assert 'Content omitted' in str(condensed_event)
else:
assert event == condensed_event
cnt -= 1
@@ -768,11 +768,15 @@ def test_condenser_pipeline_chains_sub_condensers():
# to the number of browser outputs in the view, not the whole view or
# the event stream).
browser_outputs = [
- event for event in view if isinstance(event, BrowserOutputObservation)
+ event
+ for event in view
+ if isinstance(
+ event, (BrowserOutputObservation, AgentCondensationObservation)
+ )
]
for event in browser_outputs[:-ATTENTION_WINDOW]:
- assert 'Content Omitted' in str(event)
+ assert 'Content omitted' in str(event)
for event in browser_outputs[-ATTENTION_WINDOW:]:
- assert 'Content Omitted' not in str(event)
+ assert 'Content omitted' not in str(event)