Skip to content

fix: Dev v4 to main PR#1001

Open
Dhruvkumar-Microsoft wants to merge 23 commits into
mainfrom
dev-v4
Open

fix: Dev v4 to main PR#1001
Dhruvkumar-Microsoft wants to merge 23 commits into
mainfrom
dev-v4

Conversation

@Dhruvkumar-Microsoft
Copy link
Copy Markdown
Collaborator

Purpose

This pull request primarily updates the naming of a key Azure role from "Azure AI User" to "Foundry User" throughout the documentation, infrastructure, and scripts, to match current Azure terminology. Additionally, it introduces improved error handling and status reporting in the frontend and backend plan orchestration workflow.

Role Naming Consistency Updates:

  • All references to the "Azure AI User" role in documentation (docs/LocalDevelopmentSetup.md, docs/re-use-foundry-project.md), infrastructure Bicep modules (infra/main.bicep, infra/main_custom.bicep), deployment scripts (infra/scripts/assign_azure_ai_user_role.sh), and generated ARM templates (infra/main.json) have been changed to "Foundry User" for accuracy and clarity. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

Frontend Plan Orchestration Improvements:

  • Enhanced error handling in the plan execution workflow: when a plan fails or an error is received as a final result message, the UI now clearly displays an error message, updates plan status, stops spinners, and disables further input. [1] [2] [3] [4] [5] [6] [7]
  • Added a new planFailedFinal action in the Redux slice to centralize error state management for plan execution. [1] [2]
  • Minor UI update: only display the "AI Agent" tag for non-system agents in streaming agent messages.

Backend Orchestration Robustness:

  • Improved error handling in backend orchestration: exceptions in background orchestration tasks are now logged and tracked with additional context, including plan and session IDs.
  • Preparatory backend imports for plan status and database integration, likely supporting the new error reporting and status updates.

These changes ensure consistent terminology, improve user experience by making error states more visible and actionable, and enhance backend robustness for orchestration failures.

Does this introduce a breaking change?

  • Yes
  • No

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

Coverage

Coverage Report •
FileStmtsMissCoverMissing
v4/orchestration
   orchestration_manager.py2653985%267–268, 329–331, 335, 341, 353–355, 359, 365, 405–406, 424, 484–485, 492, 494–498, 500–503, 505, 555, 560, 564, 574–581
TOTAL305638987% 

Tests Skipped Failures Errors Time
883 5 💤 0 ❌ 0 🔥 7.796s ⏱️

Comment thread src/App/src/hooks/usePlanWebSocket.tsx Dismissed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request aligns Azure AI Foundry RBAC terminology by renaming the “Azure AI User” role to “Foundry User” across docs/infra/scripts, and improves plan-execution failure reporting end-to-end (backend orchestration → WebSocket → frontend UI state).

Changes:

  • Rename “Azure AI User” → “Foundry User” in documentation, Bicep templates, ARM template output, and the role-assignment script.
  • Backend: propagate orchestration failures with richer logging/telemetry and emit ERROR_MESSAGE WebSocket events; attempt to mark the plan as failed in storage.
  • Frontend: add a centralized planFailedFinal Redux action and handle ERROR_MESSAGE (plus a safety net for error-as-final-result), improving UX for failure states; minor UI tweak for “AI Agent” tag display.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tests/backend/v4/orchestration/test_orchestration_manager.py Extends mocks to cover new imports/message types used by orchestration error handling.
src/backend/v4/orchestration/orchestration_manager.py Adds plan_id threading, DB status update on failure, and sends ERROR_MESSAGE via WebSocket.
src/backend/v4/api/router.py Wraps background orchestration task with error logging + telemetry (plan/session/user context).
src/App/src/store/slices/planSlice.ts Adds planFailedFinal action to centralize plan failure UI state updates.
src/App/src/hooks/usePlanWebSocket.tsx Handles ERROR_MESSAGE and updates plan/UI state accordingly; disconnects socket on terminal failure.
src/App/src/components/content/streaming/StreamingAgentMessage.tsx Only shows “AI Agent” tag for non-system agent messages.
infra/scripts/assign_azure_ai_user_role.sh Updates role-name output/messages to “Foundry User”.
infra/main.json Regenerates ARM template (Bicep generator metadata and formatting changes).
infra/main.bicep Updates inline role comment to “Foundry User”.
infra/main_custom.bicep Updates inline role comment to “Foundry User”.
docs/re-use-foundry-project.md Updates role assignment guidance to “Foundry User”.
docs/LocalDevelopmentSetup.md Updates local dev role assignment command to “Foundry User”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to 43
from common.database.database_factory import DatabaseFactory
from v4.models.models import PlanStatus

"content": f"Error during orchestration: {str(e)}",
"content": user_error_message,
"status": "error",
"timestamp": asyncio.get_event_loop().time(),
echo "Assigning Azure AI User role role to users"
echo "Assigning Foundry User role to users"

echo "Using provided Azure AI resource id: $aif_resource_id"
feat: Enhance email template, add RG owner tag, scalability input
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated 8 comments.

Comments suppressed due to low confidence (1)

src/App/src/hooks/usePlanWebSocket.tsx:260

  • In the ERROR_MESSAGE handler you mark the plan failed and disconnect, but you don’t disable the chat input. If input was enabled (e.g., after a clarification request), the user can still submit text against a disconnected/failed run. Dispatch setSubmittingChatDisableInput(true) as part of this failure handling.
                const errorAgent: AgentMessageData = {
                    agent: 'system',
                    agent_type: AgentMessageType.SYSTEM_AGENT,
                    timestamp: Date.now(),
                    steps: [],
                    next_steps: [],
                    content: formatErrorMessage(errorContent),
                    raw_data: errorMessage || '',
                };
                dispatch(addAgentMessage(errorAgent));
                dispatch(planFailedFinal());
                dispatch(setShowBufferingText(false));
                scrollToBottom();
                showToast(errorContent, 'error');
                webSocketService.disconnect();
            },

Comment on lines +41 to 43
from common.database.database_factory import DatabaseFactory
from v4.models.models import PlanStatus

Comment on lines +299 to +303
async def run_orchestration(self, user_id: str, input_task, plan_id: str = None) -> None:
"""
Execute the Magentic workflow for the provided user and task description.
"""
self._plan_id = plan_id
"content": f"Error during orchestration: {str(e)}",
"content": user_error_message,
"status": "error",
"timestamp": asyncio.get_event_loop().time(),
Comment on lines +202 to 220
} else if (messageStatus === 'error') {
// Safety net: handle error status sent as FINAL_RESULT_MESSAGE
const errorContent = finalMessage.data?.content || 'An unexpected error occurred. Please try again later.';
const errorAgent: AgentMessageData = {
agent: 'system',
agent_type: AgentMessageType.SYSTEM_AGENT,
timestamp: Date.now(),
steps: [],
next_steps: [],
content: formatErrorMessage(errorContent),
raw_data: finalMessage || '',
};
dispatch(addAgentMessage(errorAgent));
dispatch(planFailedFinal());
dispatch(setShowBufferingText(false));
scrollToBottom();
showToast(errorContent, 'error');
webSocketService.disconnect();
}
echo "Assigning Azure AI User role role to users"
echo "Assigning Foundry User role to users"

echo "Using provided Azure AI resource id: $aif_resource_id"
Comment thread .github/workflows/job-send-notification.yml
Comment thread .github/workflows/job-send-notification.yml
Comment on lines +571 to +582
# Update plan status to failed in the database
try:
if self._plan_id:
memory_store = await DatabaseFactory.get_database(user_id=user_id)
plan = await memory_store.get_plan_by_plan_id(plan_id=self._plan_id)
if plan:
plan.overall_status = PlanStatus.FAILED
await memory_store.update_plan(plan)
self.logger.info("Plan '%s' status updated to FAILED", self._plan_id)
except Exception as db_error:
self.logger.error("Failed to update plan status to FAILED: %s", db_error)

fix: address SFI security compliance issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants