Skip to content

fix: updated the agent framework to latest version#856

Merged
Roopan-Microsoft merged 6 commits intodev-v4from
psl-latestversinov2
Mar 17, 2026
Merged

fix: updated the agent framework to latest version#856
Roopan-Microsoft merged 6 commits intodev-v4from
psl-latestversinov2

Conversation

@Dhruvkumar-Microsoft
Copy link
Collaborator

Purpose

This pull request updates the backend agent framework integration to support the new Agent and Message APIs, replacing legacy ChatAgent and ChatMessage types throughout the codebase. It also updates dependencies to the latest stable and RC versions, removes deprecated tools, and improves protocol handling for agent sessions and streaming. The changes modernize agent initialization, invocation, and response handling, ensuring compatibility with the latest agent framework and Azure AI SDKs.

Framework migration and agent protocol updates

  • Replaced all occurrences of ChatAgent/ChatMessage with Agent/Message types, including agent initialization, response handling, and invocation in foundry_agent.py, proxy_agent.py, lifecycle.py, and response_handlers.py. Updated methods and parameters to match new API contracts, including streaming and session management. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

  • Updated agent protocol methods: replaced get_new_thread/AgentThread with create_session/AgentSession, and switched from run_stream to unified run method supporting streaming via a stream flag. Adjusted internal streaming and response logic accordingly. [1] [2]

Dependency updates

  • Updated dependencies in pyproject.toml to latest stable and RC versions: azure-ai-projects, agent-framework-azure-ai, agent-framework-core, and added agent-framework-orchestrations. [1] [2]

Tool handling and removal of deprecated features

  • Removed deprecated HostedCodeInterpreterTool and switched to server-side handling for code interpreter functionality in AzureAIClient. Updated tool collection and agent creation logic to use new AzureAISearchTool (replacing AzureAISearchAgentTool). [1] [2] [3] [4]

Response and content handling improvements

  • Updated response handling to use new Content API, ensuring text and usage updates are wrapped and serialized properly for frontend consumption. Improved websocket event dispatch to send structured data instead of relying on fragile string representations. [1] [2] [3]

These updates ensure the backend is fully compatible with the latest agent framework and Azure AI SDKs, streamline agent session and streaming protocols, and remove legacy and deprecated features for improved maintainability.

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

Copy link
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 PR migrates the backend’s agent orchestration integration to the newer Agent/Message APIs (and new orchestrations package), updates Python dependencies accordingly, and adjusts both backend websocket payloads and frontend parsing to handle the new clarification-request format.

Changes:

  • Migrated orchestration + agents from legacy ChatAgent/ChatMessage to Agent/Message, including session/streaming protocol updates.
  • Updated orchestration event handling to the new event shape (workflow.run(..., stream=True)), adding buffering + emission of AGENT_MESSAGE.
  • Updated Python dependencies (agent framework + Azure SDKs) and improved frontend parsing for user clarification requests.

Reviewed changes

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

Show a summary per file
File Description
src/frontend/src/services/PlanDataService.tsx Adds direct JSON extraction for user clarification requests with legacy repr fallback.
src/backend/v4/orchestration/orchestration_manager.py Migrates orchestration to new API and refactors event/stream handling + agent message emission.
src/backend/v4/orchestration/human_approval_manager.py Updates manager to new orchestrations package and introduces stateless _complete() retries for rate limits.
src/backend/v4/magentic_agents/proxy_agent.py Updates ProxyAgent to new run(stream=...) contract, session API, and websocket payload format.
src/backend/v4/magentic_agents/foundry_agent.py Migrates Foundry agent wrapper to Agent/Message and new Azure Search tool type.
src/backend/v4/magentic_agents/common/lifecycle.py Updates lifecycle base types to Agent and MCP tool type changes.
src/backend/v4/callbacks/response_handlers.py Migrates callbacks to Message and keeps streaming extraction logic.
src/backend/uv.lock Locks upgraded agent framework and Azure SDK dependency graph.
src/backend/pyproject.toml Pins updated versions and adds agent-framework-orchestrations.
Comments suppressed due to low confidence (1)

src/backend/v4/callbacks/response_handlers.py:136

  • streaming_agent_response_callback drops updates when update.text is missing: it only falls back to Message.text or update.content, but AgentResponseUpdate (including the one created by ProxyAgent in this PR) carries text in update.contents. If AgentResponseUpdate.text isn’t populated, this callback will return early and nothing will be streamed to the client. Add a fallback to extract text from update.contents (e.g., concatenate any text content items) before returning.
    try:
        # Handle various streaming update object shapes
        chunk_text = getattr(update, "text", None)

        # If text is None, don't fall back to str(update) as that would show object repr
        # Just skip if there's no actual text content
        if chunk_text is None:
            # Check if update is a Message
            if isinstance(update, Message):
                chunk_text = update.text or ""
            elif hasattr(update, "content"):
                chunk_text = str(update.content) if update.content else ""
            else:
                # Skip if no text content available
                return


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

You can also share your feedback on Copilot code review. Take the survey.

manager=manager,
checkpoint_storage=storage,
max_round_count=orchestration_config.max_rounds,
max_stall_count=3, # CRITICAL: Prevent re-calling agents when stalled (default is 3!)
@Roopan-Microsoft Roopan-Microsoft merged commit ecc97fb into dev-v4 Mar 17, 2026
5 of 7 checks passed
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