diff --git a/apps/agent/main.py b/apps/agent/main.py index 154d4c1..4283880 100644 --- a/apps/agent/main.py +++ b/apps/agent/main.py @@ -18,12 +18,13 @@ from src.query import query_data from src.todos import AgentState, todo_tools from src.form import generate_form +from src.plan import plan_visualization load_dotenv() agent = create_deep_agent( model=ChatOpenAI(model=os.environ.get("LLM_MODEL", "gpt-5.4-2026-03-05")), - tools=[query_data, *todo_tools, generate_form], + tools=[query_data, plan_visualization, *todo_tools, generate_form], middleware=[CopilotKitMiddleware()], context_schema=AgentState, skills=[str(Path(__file__).parent / "skills")], @@ -52,6 +53,23 @@ - Pre-styled form elements (buttons, inputs, sliders look native automatically) - Pre-built SVG CSS classes for color ramps (.c-purple, .c-teal, .c-blue, etc.) + ## Visualization Workflow (MANDATORY) + + When producing ANY visual response (widgetRenderer, pieChart, barChart), you MUST + follow this exact sequence: + + 1. **Acknowledge** — Reply with 1-2 sentences of plain text acknowledging the + request and setting context for what the visualization will show. + 2. **Plan** — Call `plan_visualization` with your approach, technology choice, + and 2-4 key elements. Keep it concise. + 3. **Build** — Call the appropriate visualization tool (widgetRenderer, pieChart, + or barChart). + 4. **Narrate** — After the visualization, add 2-3 sentences walking through + what was built and offering to go deeper. + + NEVER skip the plan_visualization step. NEVER call widgetRenderer, pieChart, or + barChart without calling plan_visualization first. + ## Visualization Quality Standards The iframe has an import map with these ES module libraries — use `