Created
November 9, 2025 13:05
-
-
Save samirsaci/a956da42f864b53e3392a31ffd524311 to your computer and use it in GitHub Desktop.
AI Agent Budget Planning - Graph Builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def route_after_parse(state: AgentState) -> str: | |
| return "error" if "error" in state else "run" | |
| def route_after_run(state: AgentState) -> str: | |
| return "error" if "error" in state else "summarize" | |
| def build_budagent_graph(): | |
| graph_builder = StateGraph(AgentState) | |
| graph_builder.add_node("parse", parse_email) | |
| graph_builder.add_node("run", run_budget) | |
| graph_builder.add_node("summarize", summarize) | |
| graph_builder.add_node("error", handle_error) | |
| graph_builder.add_edge(START, "parse") | |
| graph_builder.add_conditional_edges("parse", route_after_parse, { | |
| "run": "run", | |
| "error": "error", | |
| }) | |
| graph_builder.add_conditional_edges("run", route_after_run, { | |
| "summarize": "summarize", | |
| "error": "error", | |
| }) | |
| graph_builder.add_edge("summarize", END) | |
| graph_builder.add_edge("error", END) | |
| return graph_builder.compile() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment