|
My Project
|
Functions | |
| WebSearchHelperOutput | format_web_output (WebSearchHelperState state) |
| tool_route (WebSearchHelperState state) | |
Variables | |
| PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
| CONFIG_PATH = os.path.join(PARENT_DIR, "config.json") | |
| CONFIG = json.load(f) | |
| LOOP_CONFIG = CONFIG["loop_limits"] | |
| tool_node = ToolNode(web_tools) | |
| graph_builder = StateGraph(WebSearchHelperState, output_schema=WebSearchHelperOutput) | |
| web_graph = graph_builder.compile() | |
Copyright 2026 Luca Silver Web search helper subgraph that executes web searches for the planning agents. Functions: - `format_web_output`: Normalizes web search helper response into standardized helper output schema. - `tool_route`: Conditionally routes web helper loop based on tool calls and loop count. Graph Structure: - START -> web_node - web_node -> [tool_node | format_web_output] (conditional routing based on tool_route) - tool_node -> web_node (feedback loop) - format_web_output -> END Exports: - `web_graph`: Compiled LangGraph web search helper subgraph. Loop limits are defined in config.json.
| WebSearchHelperOutput format_web_output | ( | WebSearchHelperState | state | ) |
Normalizes the web helper response into the helper output schema.
If the last message is a tool message (meaning the web search helper passed its
loop limit without providing a final answer), the full message history is serialized
into a single string so the planner can inspect the tool trail. Otherwise, the final
AI message content is returned directly as the web result.
Args:
state (WebSearchHelperState): Helper state containing the search request
context and the message history produced by the web helper loop.
Returns:
WebSearchHelperOutput: Output object containing the original query and the
formatted web result string.
| tool_route | ( | WebSearchHelperState | state | ) |
Routes the web helper loop based on tool usage and loop count.
The web helper is allowed a limited number of iterations. If the latest AI
message includes tool calls, the graph routes to the tool node. Otherwise it
formats the output. If the loop limit is reached, the function enforces a final
response path and includes a fallback message when necessary.
Args:
state (WebSearchHelperState): Current helper state including messages,
loop counter, and requested web information.
Returns:
str: The next node name to execute.
| lg_agent.web_helper_graph.CONFIG = json.load(f) |
| lg_agent.web_helper_graph.CONFIG_PATH = os.path.join(PARENT_DIR, "config.json") |
| lg_agent.web_helper_graph.graph_builder = StateGraph(WebSearchHelperState, output_schema=WebSearchHelperOutput) |
| lg_agent.web_helper_graph.LOOP_CONFIG = CONFIG["loop_limits"] |
| lg_agent.web_helper_graph.PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) |
| lg_agent.web_helper_graph.tool_node = ToolNode(web_tools) |
| lg_agent.web_helper_graph.web_graph = graph_builder.compile() |