Skip to content

Separate planned queries from executed queries #153

Description

@rbeaudet-dlg

Description of the feature request:

If I understand correctly, currently both generate_query and web_research nodes write to the same search_query key in OverallState, which is declared as:

search_query: Annotated[list, operator.add]

Because of the operator.add reducer, this causes search_query to accumulate both the original planned queries and the queries that have been executed, leading to duplication.

We should probably separate the concepts of planned queries and executed queries in state management.

What problem are you trying to solve with this feature?

This design makes len(state["search_query"]) misleading, since it double-counts queries (planned + executed).

In the current flow:

  1. generate_query sets search_query = ["q1", "q2", "q3"]

  2. Each web_research branch appends its own query: ["q1", "q2", "q3", "q1", "q2", "q3"]

  3. Reflection calculates: number_of_ran_queries = len(state["search_query"]) (6, but only 3 actually ran)

  4. This inflated number is used to offset IDs for follow-up queries. Although because IDs remain unique, the count is actually incorrect. It works but any future logic relying on an accurate count will be wrong.

Any other information you'd like to share?

Two possible solutions:

1) Separate state keys

  • planned_queries: Annotated[list[str], operator.add] -> updated by generate_query and follow-up generation

  • executed_queries: Annotated[list[str], operator.add] -> updated by web_research

  • number_of_ran_queries = len(state.get("executed_queries", []))

2) Keep one list but stop re-adding in web_research

  • Remove search_query write from web_research

  • Add a ran_count: Annotated[int, operator.add] counter instead

  • Reflection uses ran_count

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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