Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions web_hacker/agents/guide_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ def _add_chat(
self._thread.chat_ids.append(chat.id)
self._thread.updated_at = int(datetime.now().timestamp())

# Track response_id to chat index for O(1) lookup
if llm_provider_response_id:
# Track response_id to chat index for O(1) lookup (only for ASSISTANT messages)
if llm_provider_response_id and role == ChatRole.ASSISTANT:
self._response_id_to_chat_index[llm_provider_response_id] = len(self._thread.chat_ids) - 1

# Persist thread if callback provided
Expand Down Expand Up @@ -846,7 +846,8 @@ def _tool_request_user_browser_recording(self, tool_arguments: dict[str, Any]) -
"- A new browser tab will open\n"
"- Navigate to <WEBSITE>\n"
"- Perform the following: <STEPS>\n"
"- Ensure requested data is located in the browser tab."
"- Ensure requested data is located in the browser tab.",
"DO NOT SAY ANYTHING ELSE! JUST WHAT TO DO IN BROWSER AND THATS IT!"
),
}

Expand Down Expand Up @@ -901,6 +902,14 @@ def _tool_suggest_routine_edit(self, tool_arguments: dict[str, Any]) -> dict[str

def _tool_request_routine_discovery(self, tool_arguments: dict[str, Any]) -> dict[str, Any]:
"""Execute request_routine_discovery tool."""
# Check if CDP captures vectorstore is available
if self._data_store is None or self._data_store.cdp_captures_vectorstore_id is None:
raise ValueError(
"No CDP captures available. Request a browser recording first to capture network data. "
"If already requested, wait for user to finish recording. "
"You will get a system message to tell you when it is done."
)

data_output = tool_arguments.get("data_output", "")
parameters = tool_arguments.get("parameters", "")
website = tool_arguments.get("website", "")
Expand Down Expand Up @@ -1313,7 +1322,6 @@ def _run_agent_loop(self) -> None:
ChatRole.TOOL,
f"Tool '{tool_name}' result: {result_str}",
tool_call_id=call_id,
llm_provider_response_id=response.response_id,
)
tools_executed = True

Expand Down