Skip to content

Instantly share code, notes, and snippets.

@samirsaci
Created November 9, 2025 13:04
Show Gist options
  • Select an option

  • Save samirsaci/0a73b10aef7a61086a4b8a146e2c813f to your computer and use it in GitHub Desktop.

Select an option

Save samirsaci/0a73b10aef7a61086a4b8a146e2c813f to your computer and use it in GitHub Desktop.
AI Agent Budget Planning - Summarize Function
async def summarize(state: AgentState) -> AgentState:
if "error" in state:
return {}
try:
interpreter = state.get("interpreter") or BudgetPlanInterpreter(
model_name=config["budget_agent"]["model_name"],
session_id=state.get("session_id", config["budget_agent"]["session_id"]),
)
html = await interpreter.interpret(state["params"], state["budget_results"])
return {"html_summary": html}
except Exception as e:
logger.exception("[BudgetGraph] summarize crashed")
return {"error": f"Summarization exception: {e}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment