-
Notifications
You must be signed in to change notification settings - Fork 55
hl-782: Add MMGIS Copilot backed by Azure AI Agent Service #783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
midatm1234
wants to merge
22
commits into
NASA-AMMOS:development
Choose a base branch
from
midatm1234:hl-782
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
…ng and validation
WHY
- Deliver MVP loop for MMGIS cyber agent: map control via plain English with
only four actions (list layers, toggle, opacity, zoom). This keeps the (code) surface
area tiny, reduces risk, and enables fast demos on the built-in "Test" mission.
- Use same-origin `/api/agent` and MMGIS' auto-discovery for tools/backends to avoid
core edits and CORS complexity. This aligns with MMGIS' plugin guidance and keeps
rollback trivial.
- Add a rule-based fallback so the UI is demoable even if the LLM is misconfigured,
de-risking first-run experience while we wire credentials.
WHAT
- Frontend Tool: `src/essence/Tools/AgentChat/`
- Chat panel (input + send + transcript).
- Executes validated actions via the client JS API (list/toggle/opacity/zoom).
- Same-origin call to `/api/agent`; uses ROOT_PATH for robustness.
- Backend Plugin: `API/Backend/Agent/`
- `setup.js` registers `POST /api/agent` during `onceInit`.
- `routes/agent.js`:
- Validates tool calls (name + args), clamps opacity, checks lon/lat ranges,
enforces zoom bounds, and summarizes dropped/invalid calls.
- Includes a tiny rules mapper for "list", "turn on Sample_Points", "opacity 0.7",
and "zoom to lon,lat [zoom]" to prove the loop offline.
- `provider.js`:
- Thin Azure OpenAI caller using function-calling/tools with JSON Schemas
for the four actions; extracts `tool_calls` and returns `{tool,args}` tuples.
- Tool manifest: `src/essence/Tools/AgentChat/config.json` (autoloaded; icon, paths, copy).
FOLLOW-UPS
- If any `mmgisAPI.*` helpers differ in your MMGIS build, swap to the documented
layer/visibility/zoom helpers from the JavaScript API page.
WHY - Close acceptance gaps and harden UX: human display names with visibility, a single source of truth for success messages, strict validation, and an observable provider path with graceful fallback. - Reduce operational variance by using the Azure SDK instead of raw REST API. - Keep the surface area small and maintainable. WHAT - Provider (`provider.js`): switch to AzureOpenAI SDK chat completions with tools; set parallel_tool_calls=false, and a 10s timeout; include `source` and `debug` in responses for traceability. - Server (`agent.js`): validate actions strictly, drop unknown tools with reasons, and return a neutral "Planned:" message instead of claiming execution. - UI (`AgentChatTool.js`): build a layer catalog of display names with visibility; resolve names to internal ids before execution; perform actions once; print one authoritative "Performed:" line; add Undo for toggle/opacity/zoom; add input loading state, message length guard, and focus restore. TESTS - Add `test_provider.js` to exercise the provider in isolation. It accepts a prompt, runs through the SDK with our tool schemas and timeout, and prints a compact request/response summary (choices, tool calls, reason). When creds are missing it cleanly reports the fallback path. Useful for local smoke tests and CI diagnostics without spinning up the full UI. OUTCOMES - Deterministic behavior with transparent fallback and clear transcripts. - Human-friendly layer lists that match what users see on the map. - Demos work online (provider) and offline (fallback) with minimal code.
Motivation Replace brittle, duplicated tool wiring with a single source of truth. Align with DRY principles so planning, validation, and execution stay in sync. - Add generator (scripts/generate-tool-registry.js) to read per‑tool JSON specs in API/Backend/Agent/tools/*.json and emit API/Backend/Agent/tool-registry.json. - Server: load registry on boot, compile AJV validators, expose GET /api/agent/tools; schema‑driven validation with actionable errors. - Provider: define model tools from registry; use modelParameters (no top‑level oneOf) while server uses strict parameters for AJV. - Client (AgentChat): replace switches with registry‑backed dispatcher: - adapter:"mmgisAPI" maps args (displayName→id) to window.mmgisAPI. - adapter:"custom" handles list_layers/zoom/opacity with undo. - Add tool specs: list_layers, toggle_layer, set_layer_opacity, zoom_to. - package.json: add gen:tools and ajv dependency. - configure/public/toolConfigs.json: add AgentChat tool config.
Motivation
- Remove duplicated tool logic across server and client so planning,
validation, and execution remain consistent. Keep complex I/O
(e.g., web search) on the server; keep the client a thin, generic
renderer.
What changed
- Provider exports OpenAI/Azure tools solely from the registry
(name/description/parameters via modelParameters) and parses
tool_calls into {tool,args} without prior knowledge of names.
- Server planning/validation is registry-driven with Ajv; added a
server /api/agent/exec entrypoint for server tools (initial
web_search_product) returning {summary,links,citations}.
- Registry/generator adds describe_mmgis, describe_layer, and
web_search_product; emits uiProfiles for renderer mapping.
- Client replaces the if/else ladder with a renderer map and dispatch
by exec.adapter + uiProfiles[type].kind; undo stores generic
descriptors instead of tool-name branches.
- Tests add schema checks and basic provider/exec smoke coverage.
Design principles
- Single source of truth (registry) for contracts and UI hints.
- Adapters, not switches (mmgisAPI/openapi/custom).
- Validation-first (Ajv, helpful errors, clamping where safe).
- Deterministic generator and provider export for stable diffs.
Notes
- Fallback planner no longer routes by keywords.
- Web search currently uses Bing REST behind a stable interface; next
step is Azure Agents grounding with Bing Search.
BREAKING CHANGES
- None; internal code must not rely on tool-name conditionals.
Replaces the direct Azure OpenAI chat completions client with Azure AI Agents SDK (@azure/ai-agents) for all agent planning and general Q&A; refactor provider to plan via Agents; simplify /api/agent route; update registry and remove legacy tools. The AI agent now leverages built-in Bing Grounding for general Q&A, which provides grounded replies and source citations directly from the service, eliminating the need for custom server-side execution. Key changes: - Introduces a new `azureService.js` module to encapsulate all `AgentsClient` interactions (thread creation, runs, and cleanup). - Removes the now-redundant `/api/agent/exec` endpoint and its brittle, manual web search implementation. - Simplifies the `provider.js` to build a single prompt and parse a structured JSON response, offloading all planning logic. This change aligns our architecture with the recommended pattern for Azure AI Foundry, significantly reduces code complexity, and improves both maintainability and future extensibility. BREAKING CHANGE: deprecated tools removed and provider now requires PROJECT_ENDPOINT and AZURE_AI_FOUNDRY_AGENT_ID.
Rewrites `src/essence/Tools/AgentChat/AgentChatTool.js` as a draggable, resizable, minimizable overlay; persists history, shows citations, and exposes a traces/debug section. The previous jQuery-based implementation has been removed. The new component is built with plain JavaScript. Harden renderers.js: strict payload validation; consistent output for links/summary/citations; safer layer lookup/zoom/opacity.
tariqksoliman
added a commit
that referenced
this pull request
Oct 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Proposed Changes
Issues
Testing