Skip to content

cited_ids extract failed for missing "memory" #1

@zsweet

Description

@zsweet
def _extract_cited_ids_from_history(self, history: Any) -> List[str]:
        """
        Extract cited bullet IDs from browser-use agent thoughts.

        Parses only the agent's reasoning (model_thoughts), filtering out
        tool calls, action results, and other noise.

        Args:
            history: Browser-use AgentHistoryList

        Returns:
            List of cited bullet IDs found in agent thoughts
        """
        if not history or not hasattr(history, "model_thoughts"):
            return []

        try:
            thoughts = history.model_thoughts()
            # Extract only the thinking/reasoning text (filter noise)
            thoughts_text = "\n".join(
                t.thinking for t in thoughts if hasattr(t, "thinking") and t.thinking
            )

            # Use public utility to extract IDs
            from ..roles import extract_cited_bullet_ids

            return extract_cited_bullet_ids(thoughts_text)
        except Exception:
            # Graceful degradation if extraction fails
            return []

I try run example in browser_use, but always failed to extract the cite_ids. Finally i found that in _extract_cited_ids_from_history, ids only extract from "thinking" field while this field almost MISSING but "momery" is not empty. Is this normal?

AgentOutput(thinking=None, evaluation_previous_goal=None, memory='The user wants me to compare the top 5 best-selling smartphones and analyze the price difference between the 1st and 2nd ranked phones.\nThe first step is to search for the ranking of the best-selling smartphones and their prices.\nI will use a search query in Chinese, matching the task language, following [search_strategies-00004].\nI will use the query "前5款最畅销智能手机价格" (Price of top 5 best-selling smartphones).', next_goal=None, action=[ActionModel(root=SearchActionModel(search=SearchAction(query='前5款最畅销智能手机价格', engine='duckduckgo')))])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions