Skip to content

Feature/tas27#1004

Draft
Dhruvkumar-Microsoft wants to merge 62 commits into
dev-v4from
feature/TAS27
Draft

Feature/tas27#1004
Dhruvkumar-Microsoft wants to merge 62 commits into
dev-v4from
feature/TAS27

Conversation

@Dhruvkumar-Microsoft
Copy link
Copy Markdown
Collaborator

Purpose

  • ...

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

marktayl1 and others added 30 commits April 23, 2026 16:16
- Fix 6 test collection errors caused by sys.modules pollution
- Remove dead code: agents_service.py, global_debug.py, requirements.txt
- Fix test imports to prevent module cache conflicts
- Add ADR-001: retain custom JSON declarative config over MAF declarative package

Test results: 880 passed, 0 collection errors, 13 pre-existing failures
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
- Remove azurite DB files from tracking, add __azurite_db_* to .gitignore
- Remove orphan root package-lock.json (no root package.json)
- Remove infra/old/ (24 superseded Bicep/ARM files)
- Remove src/frontend/migration-commands.txt (one-time Vite migration notes)
- Remove src/mcp_server/README_NEW.md (identical to README.md)
- Rename src/tests/agents/__init__py -> __init__.py (fix missing dot)
- Move test_sample_user.py (6 passing tests) to src/tests/backend/auth/
- Remove 13 old files: 5 duplicated in newer tree, 3 broken (stale imports),
  1 empty, 4 __init__.py
- Remove pycache-only dirs: handlers/, helpers/, context/
- Canonical test tree is now src/tests/ exclusively
- Remove duplicate AZURE_AI_AGENT_MODEL_DEPLOYMENT_NAME (keep gpt-4.1-mini)
- Remove 2 unused vars: AZURE_OPENAI_MODEL_NAME, AZURE_AI_MODEL_DEPLOYMENT_NAME
- Add 4 missing vars: AZURE_AI_PROJECT_ENDPOINT, AZURE_BASIC_LOGGING_LEVEL,
  AZURE_PACKAGE_LOGGING_LEVEL, AZURE_LOGGING_PACKAGES
- Group vars logically by service area
- Delete untracked .env_azure and .env_docker (hardcoded resource names)
- Remove src/.dockerignore (no effect; builds from src/backend/ and src/frontend/)
- Remove infra/main.json (compiled ARM artifact from main.bicep)
- Rename infra/vscode_web/.env -> .env.template (EJS placeholders, not values)
- Create root pyproject.toml with [tool.pytest.ini_options] and [tool.coverage.*]
- Add pythonpath = ['src'] to replace sys.path.insert hack in conftest.py
- Remove stale src/backend/tests/* omit pattern (dir deleted in prior commit)
- Delete pytest.ini and .coveragerc (now redundant)
- 886 tests pass, same 13 pre-existing failures (no regressions)
- Add thread-isolated integration tests for FoundryAgentTemplate covering
  MCP, RAG search, code interpreter, and multi-capability scenarios
- Fix singleton event-loop issue via _reset_cached_clients() helper
- Fix load_dotenv override to handle stale Windows user-level env vars
- Fix test_event_utils: mock config directly instead of env var check
- Fix test_health_check: use patch.object instead of string-based patching
Reasoning models (gpt-5*, o1, o3, o4) reject the temperature parameter with a 400 error. Passing temperature=None is also rejected because it serializes as null. Build a kwargs dict and spread into ChatAgent so temperature is fully omitted for these models, while gpt-4* models still get temperature=0.1.
Adds two new model deployments to the AI Foundry account: gpt-5-mini (reasoning + image-capable chat) and gpt-image-1 (image generation, required for ImageAgent in Use Case 6 / Ad Copy / Content Gen). New parameters: gpt5MiniModelName/Version/DeploymentType/Capacity and gptImageModelName/Version/DeploymentType/Capacity. Wired into both the existing-Foundry and new-Foundry deployment paths.
…ent-fixes

Feature/tas27 gpt5mini imageagent fixes
Co-authored-by: Copilot <copilot@github.com>
Task 1+2: Replace print() with structured logging; remove logging.basicConfig
- cosmosdb.py, router.py, team_utils.py: all print() -> logger.*
- team_utils.py: logging.basicConfig() -> logger = logging.getLogger(__name__)

Task 3: Remove stale commented-out imports
- magentic_agent_factory.py, lifecycle.py, response_handlers.py,
  settings.py, foundry_service.py, team_utils.py

Task 4: Rename common/models/messages_af.py -> messages.py
- Update all 29 import sites across src/backend and src/tests

Task 5: Rename utils_af.py -> team_utils.py, utils_agents.py -> agent_utils.py
- Update all import sites; rename matching test files

Task 8: Remove emoji from logger calls
- app.py, agent_registry.py, settings.py, router.py, magentic_agent_factory.py
- Fix matching test assertion in test_agent_registry.py
Migrate v4/magentic_agents to a new top-level agents/ package targeting the
GA agent_framework 1.2.2 + agent_framework_foundry 1.2.2 SDK.

New production modules:
- agents/agent_factory.py   – AgentFactory replaces MagenticAgentFactory
- agents/agent_template.py  – AgentTemplate replaces FoundryAgentTemplate
- agents/proxy_agent.py     – ProxyAgent ported to GA BaseAgent/AgentSession API
- agents/image_agent.py     – image agent carry-forward
- config/mcp_config.py      – MCPConfig / SearchConfig dataclasses
- config/agent_registry.py  – agent registry helper
- config/azure_config.py    – Azure config helpers
- orchestration/connection_config.py – connection/orchestration config

Key SDK changes from v4:
- MagneticOneGroupChat removed; orchestration handled by caller
- AgentThread -> AgentSession, ChatMessage -> Message
- TextContent/UsageContent -> Content.from_text/from_usage
- run_stream() -> run(stream=True) via ResponseStream
- FoundryAgentTemplate open() inlines _collect_tools and azure-search paths
- Reasoning + Bing guard-rail removed (platform constraint no longer applies)

New tests (69 passing, 0 failing):
- tests/backend/agents/test_agent_factory.py  (30 tests)
- tests/backend/agents/test_agent_template.py (15 tests)
- tests/backend/agents/test_proxy_agent.py    (24 tests)
- Remove InvalidConfigurationError from agent_factory.py (class, docstring,
  raise, and except clause) — platform constraint no longer applies
- Delete test_agent_factory.py tests for reasoning+bing/coding_tools guard-rail
- Delete test_sample_user.py — tested static fixture constants, not behavior
- Remove TestDatabaseBaseAbstractClass, TestDatabaseBaseMethodSignatures, and
  TestDatabaseBaseInheritance from test_database_base.py — tested Python's
  ABC machinery, not app logic

Net: 381 to 355 tests (-26)
- Add src/backend/models/__init__.py and plan_models.py (Phase 4.1 early,
  required by orchestration layer): PlanStatus, MStep, MPlan, AgentDefinition,
  PlannerResponseStep, PlannerResponsePlan
- Add src/backend/orchestration/human_approval_manager.py with plan_to_obj method
  and full exception handling in _wait_for_user_approval
- Add src/backend/orchestration/orchestration_manager.py
- Add src/backend/orchestration/helper/plan_to_mplan_converter.py
- Port 3 orchestration test suites (88 tests, all passing)
- Remove unnecessary parent sys.modules mocks from agent tests that caused
  full-suite collection contamination (test_proxy_agent, test_agent_factory,
  test_agent_template)
… kwargs assertion

- test_orchestration_manager.py: change unconditional sys.modules['agents'] = Mock()
  to setdefault so the real test package is not replaced during collection;
  this prevented pytest's Package.setup() from calling consider_module() on a Mock,
  which raised UsageError on pytest_plugins for all 73 agents/* setup steps
- test_app_config.py: add connection_timeout=30, read_timeout=180, retry_total=5
  to assert_called_once_with in test_get_ai_project_client_success; production code
  now passes these timeout kwargs to AIProjectClient

All 666 backend unit tests now pass (0 errors, 0 failures).
…p import errors

- Replace ChatMessage/AgentRunResponseUpdate/internal _magentic imports with
  MAF 1.2.2 GA types: Message, AgentResponseUpdate, AgentResponse, WorkflowEvent
- Rewrite orchestration_manager.py: MagenticBuilder keyword-args constructor,
  Agent() wrapper for FoundryChatClient, workflow.run(stream=True) event loop
  with WorkflowEvent type discriminator (magentic_orchestrator / data / output)
- Fix human_approval_manager.py: import MagenticContext/StandardMagenticManager
  from agent_framework.orchestrations; ORCHESTRATOR_* from agent_framework_orchestrations
- Fix callbacks/response_handlers.py: use Message and AgentResponseUpdate
- Add AgentMessageResponse and WebsocketMessageType to models/messages.py
- Remove stale executor state-clearing block (obsolete internal MAF 1.x API)
- Remove v4 router include from app.py and v4 import from team_utils.py
- Enable intermediate_outputs on MagenticBuilder for per-agent events
- Inject agent name markdown headers on executor_invoked events
- Stream all AgentResponseUpdate chunks to thinking buffer
- Use executor_completed for clean final results (agents + orchestrator)
- Fix PlanPage streaming handler to safely access content and scroll
- Fix vite.config.ts leaking full process.env into build
- Prior: AzureAISearchTool serialization, query_type default, SDK 2.1.0
- Only show agent name header when agent actually produces streaming output
- Remove robot emoji from agent headers
- Add search tool usage instructions to RFP team agent system messages
- Accumulate orchestrator streaming chunks as final result fallback
- Display agent names with 'Agent' suffix in plan steps (StreamingPlanResponse)
- Add agent names to Plan Overview left pane (PlanPanelRight)
- Strengthen plan prompt to require agent names on every step
- Remove party emoji prefix from final result message
- Revert basic logging level default back to WARNING
…proxy

MCP server and proxy are working well in the HR onboarding scenario.
The full workflow now completes end-to-end: pre-orchestration clarification,
HR agent tasks, and Tech Support agent tasks all execute as expected.

Fixes:
- hr.json: Add COMPLETION RULE to HR agent system message so it no longer
  declares the entire onboarding complete — only its own HR portion.
  Previously the orchestrator interpreted HR's closing language as workflow
  completion and never invoked TechnicalSupportAgent.
- plan_review_helpers.py: Add progress-ledger guard instructing the
  orchestrator to ignore agent-level completion language when deciding
  whether all plan steps are done.
- orchestration_manager.py: Add explicit MCP cleanup in a finally block
  at the end of run_orchestration to close UserInteractionAgent's
  streamable-HTTP async generators, preventing noisy cross-task
  RuntimeError from anyio on GC.

Validated: HR scenario runs to completion with both HR and Tech Support
agents invoked. MCP ask_user clarification round-trip works reliably
(an intermittent hang on the WebSocket/async-event chain was observed
once but resolved on retry — timing issue, not a logic bug).
marktayl1 and others added 30 commits May 19, 2026 10:51
…mplate

- CustomerDataAgent → macae-retail-customer-kb
- OrderDataAgent → macae-retail-orders-kb
- agent_template.py detects portal MCPTool with stale KB name and
  updates the agent definition to match team JSON config
- Removed obsolete bugs/ investigation files (moved to localspec)
- Add ORCHESTRATOR_MODEL_NAME config (default: o4-mini) for the
  MagenticManager agent, separate from participant model
- Create dedicated FoundryChatClient for manager with fallback to
  participant model on failure
- Add debug logging to plan conversion for diagnosis
- Fix test assertion to match current clarification policy header
- Update agent team configs and template for KB detection
- Switch plan prompt to emit JSON array [{agent, action}] instead of bullets
- Add _try_parse_json_plan() with JSON-first parsing, bullet fallback
- Fix f-string/format brace escaping in plan_append (use concatenation)
- Preserve backward-compatible bullet regex parsing for non-reasoning models
- Add ADR-003 documenting reasoning model choice for orchestrator manager

Resolves: empty steps[] regression when o4-mini produces non-bullet plans
Status: all teams working except HR (blocked by framework tool-history-leak bug)
…larification

- Add patches.py: two-layer monkey-patch filters tool call/result content
  types (function_call, function_call_output, function_result) and role=tool
  messages from being broadcast to other participants
- Strengthen progress_ledger_prompt: agent requesting user clarification is
  progress (not stalling), route to UserInteractionAgent
- Increase max_stall_count to 5 for user-interaction-heavy workflows
- TechnicalSupportAgent: must call get_workflow_blueprint first, only ask
  about actual tool parameters (QUESTION RULE)
Frontend:
- Scroll viewport to START of final result message instead of page bottom
- Use React.Fragment wrapper with ref anchor before last agent message
- scrollIntoView({ block: 'start' }) positions final answer at viewport top

Backend (hr.json):
- Add WORKFLOW RULE: agents must call get_workflow_blueprint first, execute
  only blueprint steps, never invent extras
- Add QUESTION RULE: one consolidated upfront ask for all blueprint-specified
  info (required params, optional steps, defaults), no invented questions
- Prevents LLM from fabricating extra HR/tech-support steps and extraneous
  user questioning
- test_agent_template: update mocks for new get/create_version API
  (replaces old list_agents/create_agent pattern), patch
  PromptAgentDefinition and ResourceNotFoundError for full-suite compat
- test_agent_factory: fix create_from_team_config assertions for new
  AgentTemplate constructor signature
- test_team_utils: rewrite tests for refactored load_team_config that
  returns parsed TeamConfig instead of raw dict
- test_cosmosdb: fix expected exception type (CosmosResourceNotFoundError)
- test_orchestration_manager: add get_executors_list mock, wire
  _user_interaction_ctx, set user_responses=False for inner-agent test
- test_response_handlers: fix indentation in sys.modules stubs
- conftest: pre-import backend.app to prevent sys.modules poisoning
…onAgent

- Add clarification_tool.py with approval-gated request_user_clarification tool
- Inject tool into domain agents via agent_factory extra_tools parameter
- Extend AgentTemplate to accept extra_tools list
- Rewrite orchestration_manager to detect function_approval_request events,
  send questions to frontend via WebSocket, and approve after user responds
- Remove UserInteractionAgent proxy pattern from orchestration
- Re-enable tool_history_leak patch (MAF framework bug workaround)
- Fix frontend PlanDataService parser to handle structured JSON format
  with nested .data wrapping from send_status_update_async
- Update orchestration_manager tests for new return format
…omments

- Remove diagnostic per-message cache dump from tool_history_leak patch
- Replace print() with logger.info() in patch application
- Remove unused imports from orchestration_manager.py
- Remove stale diagnostic dump from agent_template.py
- Add type: ignore[attr-defined] on intentional monkey-patch accesses
- Add noqa: ARG001 on by-design unused questions param
- Add capability comments on MagenticBuilder config and request_info events
- Change bare Exception to RuntimeError for plan cancellation

All 681 tests pass.
…erification checklists

- Add RE-INVOCATION CHECK to prevent redundant blueprint calls on resume
- Add explicit VERIFICATION CHECKLIST matching blueprint items exactly
- Separate BLUEPRINT STEP, QUESTION RULE, and EXECUTION phases
- Apply to both HRHelperAgent and TechnicalSupportAgent
Upstream PR #5690 (agent-framework 1.4.0) only fixes the fc_ duplicate
variant, not the orphaned function_call_output variant that triggers
'Progress ledger creation failed' in multi-agent Magentic workflows.
…om AppConfig

- AGENT_TEAM_FILE was never referenced anywhere in the codebase
- REASONING_MODEL_NAME duplicated ORCHESTRATOR_MODEL_NAME (already present)
- azure_config.py: superseded by direct model construction in orchestration_manager
- orchestration/patches.py: superseded by patches/tool_history_leak.py
- Neither module is imported anywhere in the codebase
- agent-framework==1.6.0 (GA umbrella)
- agent-framework-foundry==1.6.0 (Foundry integration)
- All existing imports validated — no breaking changes
…0 upgrade

- Fix agent_template.py: OpenAIChatOptions, cast(PromptAgentDefinition), typed dicts, update.text
- Fix orchestration_manager.py: Optional typing, asyncio.iscoroutine, assert narrowing
- Fix frontend tsconfig.json: add ignoreDeprecations for TS 6.0
- Fix mcp_server lint: factory.py, mcp_server.py, README formatting
- Add pyrightconfig.json (root + mcp_server) for import resolution
- Add/update pylintrc configs to suppress no-name-in-module, import-error
- Fix test_response_handlers.py: type: ignore for Mock .called access
- Collapse duplicate pylint sections in root pyproject.toml
…mework 1.6.0

- Flatten agent_teams JSON to use tool-based config (remove legacy fields)
- Simplify agent_factory.py and agent_template.py for new framework API
- Remove pyrightconfig.json files (consolidated in pyproject.toml)
- Update tests to match simplified agent creation flow
- Add e2e-test pyproject.toml
- Minor lint and type fixes across mcp_server and frontend models
…cess

The MCP image tool was returning direct blob URLs that are inaccessible
from the browser (private container, SAS generation often fails locally).

- Add backend_url config to MCP server settings
- Update image_service to return backend proxy URL when BACKEND_URL is set
- Add BACKEND_URL env var to MCP container in Bicep for deployed scenario

The backend already has a /api/v4/images/{blob_name} proxy endpoint that
fetches from blob storage using its own credential.
…s, upgrade Dockerfiles

- Remove dead Key Vault resource and all references (secret, RBAC, DNS zone)
- Fix circular dependency: BACKEND_URL uses constructed FQDN pattern
- Fix AZURE_OPENAI_IMAGE_DEPLOYMENT: use deployment variable not hardcoded string
- Add 'generated-images' blob container to storage account
- Build SUPPORTED_MODELS dynamically from deployed model names
- Add Cognitive Services OpenAI Contributor role for image generation
- Add gpt5Mini and gptImage params to main.parameters.json
- Add AZURE_OPENAI_IMAGE_DEPLOYMENT to backend container env
- Upgrade all Dockerfiles from EOL Bullseye to Bookworm
- Replace MCP devcontainer base with slim production image
- Remove dead AZURE_AI_SEARCH_API_KEY from app_config.py
- Disable MCP auth by default (runs behind backend Easy Auth)
- Integrate seed_knowledge_bases.py into post-deploy scripts (PS1 + bash)
- azure.yaml now uses main.bicep (pre-built images from public registry)
- azure_custom.yaml explicitly uses main_custom.bicep (build from source)
- Port to main_custom.bicep:
  - Add Cognitive Services OpenAI Contributor role for image generation
  - Build SUPPORTED_MODELS dynamically from deployed model names
  - Add AZURE_OPENAI_IMAGE_DEPLOYMENT to backend container env
  - Add 'generated-images' blob container to storage account
- Suppress no-hardcoded-env-urls on private link DNS zones
- Replace hardcoded login.microsoftonline.com with environment().authentication.loginEndpoint
- Remove unused storageContainerName param
- Remove unused aiSearchIndexName variable (main_custom)
- Remove unnecessary dependsOn on aiFoundryAiServices
- Add non-null assertion on guarded conditional module access
- Suppress BCP318 on unconditional userAssignedIdentity access
- Suppress no-unused-params on azd-injected container image params (main_custom)
- Suppress BCP334 theoretical length warning on container registry name (main_custom)
- Change gptImageModelName from gpt-image-1 to gpt-image-1.5
- Update gptImageModelVersion from 2025-04-15 to 2025-12-16
- Increase gptImageModelCapacity from 1 to 5 RPM (matches main_custom.bicep)
- Add infra/scripts/post_deploy.ps1: interactive use-case menu that seeds
  Cosmos DB teams, uploads blobs, creates search indexes, vector stores,
  and Foundry IQ knowledge bases directly (no backend required)
- Move seed_vector_stores.py and seed_knowledge_bases.py into infra/scripts/
- Remove top-level scripts/ directory (seed_teams.py superseded)
- Update azure.yaml postdeploy hook to invoke post_deploy.ps1
- Update requirements.txt with azure-cosmos, aiohttp, httpx deps
- Fix .gitignore: scope scripts/ rule to top-level only, remove obsolete entry
- Update agent_template.py error message to reflect new script path
- Make APPLICATIONINSIGHTS_CONNECTION_STRING optional in app_config.py
- Fix frontend PlanDataService.tsx TeamAgentBE to Agent mapping
- Remove invalid ignoreDeprecations from tsconfig.json (TS 5.8+)
…s dep

- Add azure-ai-projects to requirements.txt (fixes vector store ModuleNotFoundError)
- Track step failures with $script:hasErrors flag
- Exit with code 1 and report errors when any step fails
- Change WARNING to ERROR with red output for failed steps
- Only print 'ready to use' when all steps succeed
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.

3 participants