Skip to content

Commit 5a51cec

Browse files
committed
refactor: update architecture documentation and improve environment variable handling in agents.py
Signed-off-by: Andre Bossard <anbossar@microsoft.com>
1 parent a661b4b commit 5a51cec

3 files changed

Lines changed: 58 additions & 26 deletions

File tree

.github/copilot-instructions.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## Architecture
44

5-
- `backend/app.py` hosts both REST (`/api/*`) and MCP JSON-RPC (`/mcp`) on port 5001; every new capability should be exposed via the shared `@operation` decorator so both interfaces stay in sync.
6-
- Business logic lives in `backend/tasks.py` (`TaskService` plus Pydantic models) backed by an in-memory `_tasks_db`; keep it the single source of truth and seed demo data via `TaskService.initialize_sample_data()`.
7-
- The React side is feature-first: `frontend/src/App.jsx` just switches tabs while each folder under `frontend/src/features` owns its state, calculations, and FluentUI layout; `frontend/src/services/api.js` is the only place that should issue network calls.
5+
- `backend/app.py` hosts REST (`/api/*`), MCP JSON-RPC (`/mcp`), and LangGraph agent (`/api/agents/run`) on port 5001; new capabilities should use the `@operation` decorator in `backend/operations.py` so all interfaces stay in sync.
6+
- Business logic lives in service modules: `tasks.py` (TaskService), `tickets.py` (ticket models + SLA calculations); keep services as the single source of truth.
7+
- The React side is feature-first: `frontend/src/App.jsx` switches tabs via React Router; each folder under `frontend/src/features` owns its state, calculations, and FluentUI layout.
8+
- All network calls go through `frontend/src/services/api.js`; localStorage helpers live in separate modules like `reminderStorage.js`.
89

910
## Backend Patterns
1011

backend/agents.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,14 @@
4141

4242
# Ensure operations register before we request LangChain tools
4343
import operations # noqa: F401
44-
4544
# Local - Import operations registry for automatic tool discovery
4645
from api_decorators import get_langchain_tools
47-
4846
# Third-party - FastMCP client for external MCP servers
4947
from fastmcp import Client as MCPClient
5048
from langchain_core.tools import StructuredTool
51-
5249
# Third-party - LangChain and LangGraph
5350
from langchain_openai import AzureChatOpenAI
5451
from langgraph.prebuilt import create_react_agent
55-
5652
# Third-party - Pydantic for validation
5753
from pydantic import BaseModel, Field, create_model, field_validator
5854

@@ -143,8 +139,8 @@ class AgentResponse(BaseModel):
143139
# Azure OpenAI configuration - only API key from environment
144140
AZURE_OPENAI_ENDPOINT = "https://can-i-haz-houze-resource.cognitiveservices.azure.com"
145141
AZURE_OPENAI_API_KEY = os.getenv("AZURE_API_KEY", "")
146-
AZURE_OPENAI_DEPLOYMENT = "gpt-5-mini"
147-
AZURE_OPENAI_API_VERSION = "2025-04-01-preview"
142+
AZURE_OPENAI_DEPLOYMENT = os.getenv("AZURE_OPENAI_DEPLOYMENT", "gpt-5-mini")
143+
AZURE_OPENAI_API_VERSION = os.getenv("AZURE_OPENAI_API_VERSION", "2025-04-01-preview")
148144

149145
# External MCP server URL for ticket management (hardcoded)
150146
TICKET_MCP_SERVER_URL = "https://yodrrscbpxqnslgugwow.supabase.co/functions/v1/mcp/a7f2b8c4-d3e9-4f1a-b5c6-e8d9f0123456"

explain.drawio

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,100 @@
11
<mxfile host="65bd71144e">
22
<diagram id="lG4lScdXApjigMqi7QEq" name="Page-1">
3-
<mxGraphModel dx="648" dy="396" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
3+
<mxGraphModel dx="134" dy="367" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
44
<root>
55
<mxCell id="0"/>
66
<mxCell id="1" parent="0"/>
7-
<mxCell id="16" value="Plan" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
7+
<mxCell id="16" value="Plan" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" parent="1" vertex="1">
88
<mxGeometry x="580" y="350" width="60" height="45" as="geometry"/>
99
</mxCell>
10-
<mxCell id="2" value="LLM" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
10+
<mxCell id="2" value="LLM" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
1111
<mxGeometry x="130" y="150" width="60" height="30" as="geometry"/>
1212
</mxCell>
13-
<mxCell id="3" value="LLM&lt;div&gt;instrinsic knowledge&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
13+
<mxCell id="3" value="LLM&lt;div&gt;instrinsic knowledge&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
1414
<mxGeometry x="50" y="180" width="220" height="350" as="geometry"/>
1515
</mxCell>
16-
<mxCell id="4" value="- &quot;m-dash&quot;" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
16+
<mxCell id="4" value="- &quot;m-dash&quot;" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
1717
<mxGeometry x="70" y="410" width="80" height="110" as="geometry"/>
1818
</mxCell>
19-
<mxCell id="5" value="Pizza Recipe / Mangement" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
19+
<mxCell id="5" value="Pizza Recipe / Mangement" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
2020
<mxGeometry x="160" y="410" width="80" height="110" as="geometry"/>
2121
</mxCell>
22-
<mxCell id="6" value="Legal Stuff" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
22+
<mxCell id="6" value="Legal Stuff" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
2323
<mxGeometry x="70" y="190" width="80" height="110" as="geometry"/>
2424
</mxCell>
25-
<mxCell id="7" value="Project Domain" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
25+
<mxCell id="7" value="Project Domain" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
2626
<mxGeometry x="200" y="190" width="180" height="125" as="geometry"/>
2727
</mxCell>
28-
<mxCell id="8" value="" style="endArrow=classic;html=1;" edge="1" parent="1" source="3" target="12">
28+
<mxCell id="8" value="" style="endArrow=classic;html=1;" parent="1" source="3" target="12" edge="1">
2929
<mxGeometry width="50" height="50" relative="1" as="geometry">
3030
<mxPoint x="350" y="410" as="sourcePoint"/>
3131
<mxPoint x="520" y="290" as="targetPoint"/>
3232
</mxGeometry>
3333
</mxCell>
34-
<mxCell id="9" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
34+
<mxCell id="9" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" vertex="1">
3535
<mxGeometry x="580" y="370" width="50" height="25" as="geometry"/>
3636
</mxCell>
37-
<mxCell id="11" style="edgeStyle=none;html=1;" edge="1" parent="1" source="10">
37+
<mxCell id="11" style="edgeStyle=none;html=1;" parent="1" source="10" edge="1">
3838
<mxGeometry relative="1" as="geometry">
3939
<mxPoint x="440" y="280" as="targetPoint"/>
4040
</mxGeometry>
4141
</mxCell>
42-
<mxCell id="10" value="&quot;Plan&quot; the task" style="shape=document;whiteSpace=wrap;html=1;boundedLbl=1;" vertex="1" parent="1">
42+
<mxCell id="10" value="&quot;Plan&quot; the task" style="shape=document;whiteSpace=wrap;html=1;boundedLbl=1;" parent="1" vertex="1">
4343
<mxGeometry x="400" y="390" width="70" height="60" as="geometry"/>
4444
</mxCell>
45-
<mxCell id="13" value="bias" style="edgeStyle=none;html=1;" edge="1" parent="1" source="12" target="9">
45+
<mxCell id="13" value="bias" style="edgeStyle=none;html=1;" parent="1" source="12" target="9" edge="1">
4646
<mxGeometry relative="1" as="geometry"/>
4747
</mxCell>
48-
<mxCell id="12" value="Plan" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
48+
<mxCell id="12" value="Plan" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" parent="1" vertex="1">
4949
<mxGeometry x="545" y="215" width="120" height="60" as="geometry"/>
5050
</mxCell>
51-
<mxCell id="15" style="edgeStyle=none;html=1;" edge="1" parent="1" source="14">
51+
<mxCell id="15" style="edgeStyle=none;html=1;" parent="1" source="14" edge="1">
5252
<mxGeometry relative="1" as="geometry">
5353
<mxPoint x="610" y="330" as="targetPoint"/>
5454
</mxGeometry>
5555
</mxCell>
56-
<mxCell id="17" style="edgeStyle=none;html=1;" edge="1" parent="1" source="14" target="10">
56+
<mxCell id="17" style="edgeStyle=none;html=1;" parent="1" source="14" target="10" edge="1">
5757
<mxGeometry relative="1" as="geometry"/>
5858
</mxCell>
59-
<mxCell id="14" value="adapt" style="shape=document;whiteSpace=wrap;html=1;boundedLbl=1;" vertex="1" parent="1">
59+
<mxCell id="14" value="adapt" style="shape=document;whiteSpace=wrap;html=1;boundedLbl=1;" parent="1" vertex="1">
6060
<mxGeometry x="490" y="310" width="70" height="40" as="geometry"/>
6161
</mxCell>
6262
</root>
6363
</mxGraphModel>
6464
</diagram>
65+
<diagram id="4hURqi519zki52A409Ot" name="Page-2">
66+
<mxGraphModel dx="402" dy="200" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
67+
<root>
68+
<mxCell id="0"/>
69+
<mxCell id="1" parent="0"/>
70+
<mxCell id="vc1tvxiwz19uGiisHoE9-6" style="edgeStyle=none;html=1;" edge="1" parent="1" source="vc1tvxiwz19uGiisHoE9-1" target="vc1tvxiwz19uGiisHoE9-3">
71+
<mxGeometry relative="1" as="geometry"/>
72+
</mxCell>
73+
<mxCell id="vc1tvxiwz19uGiisHoE9-8" style="edgeStyle=none;html=1;" edge="1" parent="1" source="vc1tvxiwz19uGiisHoE9-1" target="vc1tvxiwz19uGiisHoE9-4">
74+
<mxGeometry relative="1" as="geometry"/>
75+
</mxCell>
76+
<mxCell id="vc1tvxiwz19uGiisHoE9-1" value="Python" style="rounded=0;whiteSpace=wrap;html=1;fontStyle=1" vertex="1" parent="1">
77+
<mxGeometry x="240" y="230" width="120" height="60" as="geometry"/>
78+
</mxCell>
79+
<mxCell id="vc1tvxiwz19uGiisHoE9-5" style="edgeStyle=none;html=1;" edge="1" parent="1" source="vc1tvxiwz19uGiisHoE9-2" target="vc1tvxiwz19uGiisHoE9-1">
80+
<mxGeometry relative="1" as="geometry"/>
81+
</mxCell>
82+
<mxCell id="vc1tvxiwz19uGiisHoE9-2" value="React" style="rounded=0;whiteSpace=wrap;html=1;fontStyle=1" vertex="1" parent="1">
83+
<mxGeometry x="240" y="130" width="120" height="60" as="geometry"/>
84+
</mxCell>
85+
<mxCell id="vc1tvxiwz19uGiisHoE9-7" style="edgeStyle=none;html=1;" edge="1" parent="1" source="vc1tvxiwz19uGiisHoE9-3" target="vc1tvxiwz19uGiisHoE9-1">
86+
<mxGeometry relative="1" as="geometry"/>
87+
</mxCell>
88+
<mxCell id="vc1tvxiwz19uGiisHoE9-3" value="OpenAI" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
89+
<mxGeometry x="480" y="160" width="120" height="80" as="geometry"/>
90+
</mxCell>
91+
<mxCell id="vc1tvxiwz19uGiisHoE9-9" style="edgeStyle=none;html=1;" edge="1" parent="1" source="vc1tvxiwz19uGiisHoE9-4" target="vc1tvxiwz19uGiisHoE9-1">
92+
<mxGeometry relative="1" as="geometry"/>
93+
</mxCell>
94+
<mxCell id="vc1tvxiwz19uGiisHoE9-4" value="Ticket Feed HTTP/MCP" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
95+
<mxGeometry x="480" y="270" width="120" height="60" as="geometry"/>
96+
</mxCell>
97+
</root>
98+
</mxGraphModel>
99+
</diagram>
65100
</mxfile>

0 commit comments

Comments
 (0)