* Use actual message role when creating ChatMessage
Replace hard-coded ChatRole.User with a ChatRole constructed from the message's Role. The change ensures ToChatMessage and FunctionMessage use the original role (new ChatRole(this.Role)) for both text and contents branches, fixing incorrect role assignment when constructing ChatMessage instances.
* Update changes
* Fix formatting in ToChatMessage tests
---------
Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
* .NET: Add integration test for OpenAPI tools with AsAIAgent(agentVersion)
Validates end-to-end flow creating a Foundry agent with an OpenAPI tool
definition via native Azure.AI.Projects SDK types and wrapping it with
AsAIAgent(agentVersion). The test confirms the server-side OpenAPI
function is invoked correctly through RunAsync.
Addresses #4883
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address PR review: RetryFact, PascalCase naming, stronger tool assertion
- Use RetryFact with Skip for manual testing (flaky due to external API)
- Fix agentName -> AgentName to match PascalCase convention in file
- Strengthen tool invocation assertion: require >= 3 Eurozone countries
- Add comment explaining server-side OpenAPI tools don't surface as
FunctionCallContent in the MEAI abstraction
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add AsIChatClientWithStoredOutputDisabled for ProjectResponsesClient
Add extension method on ProjectResponsesClient in Microsoft.Agents.AI.AzureAI
package (Azure.AI.Extensions.OpenAI namespace) mirroring the existing extension
on ResponsesClient in the OpenAI package. This enables Azure AI consumers to
disable server-side response storage without depending on the OpenAI package.
- New ProjectResponsesClientExtensions class with AsIChatClientWithStoredOutputDisabled
- Optional deploymentName parameter (model is no longer required)
- Updated OpenAI counterpart doc to remove 'Required' wording for model param
- Added unit tests covering null guard, inner client accessibility,
StoredOutputEnabled=false, and reasoning encrypted content inclusion/exclusion
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Preserve existing RawRepresentationFactory when disabling stored output
Address PR review feedback: wrap/chain the existing factory instead of
replacing it, so upstream configuration (e.g., deploymentName/model defaults
from AsIChatClient) is preserved.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* add adr suggesting a new design to support a multi-source architecture for agent skills
* add deciders
* move the adr to the decisions folder
* remove unnecessary section
* describe adding a custom skill source
* update
* address comments
* add constructor overloads to inline skill resource and script
* consider ai-function as an alternative for skill script and skill resource model classes
* update decision outcome section and sync adr with latest changes in the code
* Add ADR to decide consitency of Chat History Persistence
* Add example
* Update ADR with review results
* Remove unecessary clarification
* Rename ADR to no 22
* Support MCP sampling tools capability (#4625)
Forward systemPrompt, tools, and toolChoice from MCP sampling requests
to the chat client's get_response() call. Also advertise the
sampling.tools capability to MCP servers when a client is configured.
- Pass SamplingCapability with tools support to ClientSession
- Convert systemPrompt to instructions in options
- Convert MCP Tool objects to FunctionTool instances for options
- Map MCP ToolChoice.mode to tool_choice in options
- Add tests for all new behaviors and update existing sampling tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix#4625: Support MCP sampling tool with proper typing and structured content
- Fix mypy error by typing sampling callback options as ChatOptions[None]
instead of dict[str, Any], and importing ChatOptions from _types
- Handle structuredContent from CallToolResult in _parse_tool_result_from_mcp,
serializing it as JSON text Content when present
- Add tests for structuredContent parsing (with and without regular content)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix lint: add author to TODO comment
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback for #4625: remove default=str, add edge-case tests
- Remove default=str from json.dumps for structuredContent to fail fast
on non-JSON-serializable values instead of silently converting
- Add test for non-JSON-serializable structuredContent (TypeError)
- Add tests for empty systemPrompt ('') and empty tools list ([]) edge
cases in sampling callback
- Expand TODO comment noting list[Content] return type constraint for
future result_type support
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Sanitize sampling callback error to avoid leaking internals (#4625)
Log exception details at DEBUG level instead of including them in the
ErrorData message returned to the MCP server, which may be untrusted.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback for #4625: move params to options, restore error info
- Remove stale TODO comment about response_format (ChatOptions already has it)
- Restore {ex} in sampling callback error message for useful debugging info
- Set structuredContent as additional_property on Content for structured access
- Move temperature, max_tokens, stop into options dict (not top-level kwargs)
- Only set temperature when provided (not all models support it)
- Add tests for generation params in options and temperature omission
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix MCP sampling callback and structured content error handling (#4625)
- Guard max_tokens like temperature: only set when not None, so options
can properly evaluate to None when all params are absent
- Wrap json.dumps of structuredContent in try/except to fall back to
str() for non-serializable values instead of propagating TypeError
- Extract test_connect_sampling_capabilities_with_client into its own
test function so pytest can discover it independently
- Add test for max_tokens=None omission from options
- Update structured content non-serializable test to expect fallback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback for #4625: review comment fixes
* Fix MCP and Azure validation regressions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Eduard van Valkenburg
·
2026-03-26 07:33:19 +00:00
* Include reasoning messages in MESSAGES_SNAPSHOT (#4843)
FlowState now tracks reasoning messages emitted during a run.
_emit_text_reasoning() persists reasoning (including encrypted_value)
into flow.reasoning_messages, and _build_messages_snapshot() appends
them to the final MESSAGES_SNAPSHOT event.
Changes:
- Add reasoning_messages field to FlowState
- Update _emit_text_reasoning() to accept optional flow parameter
- Include reasoning_messages in _build_messages_snapshot()
- Add 'reasoning' to ALLOWED_AGUI_ROLES so normalize_agui_role()
preserves the role through snapshot round-trips
- Skip reasoning messages in agui_messages_to_agent_framework() since
they are UI-only state and should not be forwarded to LLM providers
- Add regression tests for snapshot emission, encrypted value
preservation, and multi-turn round-trip with reasoning
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Python: Include reasoning messages in MESSAGES_SNAPSHOT events
Fixes#4843
* Fix PR review feedback for reasoning persistence (#4843)
- Accumulate reasoning text per message_id (append deltas) instead of
storing only the current chunk, matching flow.accumulated_text pattern
- Use camelCase encryptedValue in snapshot JSON to match AG-UI protocol
conventions (toolCallId, encryptedValue)
- Normalize snake_case encrypted_value to encryptedValue in
agui_messages_to_snapshot_format for input compatibility
- Update normalize_agui_role docstring to include reasoning role
- Add tests for incremental reasoning accumulation and key normalization
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback for #4843: Python: agent-framework-ag-ui: include reasoning messages in MESSAGES_SNAPSHOT
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix streaming path to deliver mcp_server_tool_result content (#4814)
Remove premature mcp_server_tool_result emission from the
response.output_item.added/mcp_call handler — at that point the MCP
server has not yet responded and output is always None.
Add a handler for response.mcp_call.completed that emits
mcp_server_tool_result with the actual tool output, matching the
non-streaming path behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix streaming path to deliver mcp_server_tool_result content (#4814)
Stop eagerly emitting mcp_server_tool_result on response.output_item.added
(when output is always None). Instead, handle response.output_item.done for
mcp_call items, which carries the full McpCall with populated output.
This matches the non-streaming path which guards with 'if item.output is not
None' before emitting the result.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix test docstring to match actual implementation event name
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: call_id fallback and raw_representation consistency (#4814)
- Add call_id fallback in response.output_item.done mcp_call handler to
match the output_item.added handler pattern
- Use done_item instead of event for raw_representation to keep
consistent with other output_item branches and non-streaming path
- Add test for call_id fallback when id attribute is missing
- Add raw_representation assertions to existing done handler tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: call_id fallback for non-streaming path and test coverage (#4814)
- Apply defensive call_id fallback (getattr with id/call_id/empty) to
non-streaming mcp_call path for consistency with streaming path
- Add raw_representation assertion to call_id fallback test
- Add test for empty-string fallback when neither id nor call_id exist
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix A2AAgent dropping message content from in-progress TaskStatusUpdateEvents (#4783)
_updates_from_task() returned [] for working-state tasks when
background=False, silently discarding all intermediate message content
from task.status.message. Now extracts and yields message parts from
in-progress status updates during streaming.
Also fixed MockA2AClient.send_message to yield all queued responses
(enabling multi-event streaming tests) and added text parameter to
add_in_progress_task_response for tests that need status messages.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix: gate intermediate status updates behind emit_intermediate flag and add missing test coverage
- Add emit_intermediate parameter to _updates_from_task and _map_a2a_stream
- Thread stream flag from run() so only streaming callers see intermediate updates
- Add IN_PROGRESS_TASK_STATES guard to emit_intermediate condition
- Add role parameter to test helper add_in_progress_task_response
- Add clarifying comment on MockA2AClient.send_message batch semantics
- Add tests for user role mapping, background precedence, non-streaming behavior,
terminal task with no artifacts, and empty parts edge case
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: HandoffAgentExecutor does not output any reponse when non-streaming
* fix: Ensure Workflow outputs persisted in chat history when hosted AsAgent
* fix: Remove duplicate history entry creation and ad test
* test: Add streaming tests for AsAgent to smoke tests
* feat: Add output configurability to Handoffs
* refactor: [BREAKING] Config => ExecutorConfig
Make the Config name less likely to collide with other classes by renaming to ExecutorConfig. Makes Configured and related classes internal as they do not need to be part of the public surface.
* fix: Make RouteBuilder explicit in SourceGen to avoid conflicts
* Handle external input request and response conversion for workflow as agent scenario
* Remove unnecessary test comment
* Fix PR comments
* Updated to fix edge cases, and add more tests.
* Update pending requests to use typed properties instead of relying on StateBag. replying to PR feedback.
* Fixed external response de-dup and updated possible brittle test.
* Address PR comments on sending turn token for normal messages and handle contentId collision by source agent
* Remove unnecessary serialization element and address pr comment on intercepted outgoing requests
* Updated MEAI changes for UserInput request and response abstractions.
* Expose workflow as MCP Tool
* Expose workflow as MCP Tool
* Cleanup
* PR feedback fixes
* update changelog to include PR numner
* Improvements to error handling.
* Adding a sample project demonstrating how to setup Agents and Workflows together.
* Ensure duplicate agent registrations are properly handled.
The `sessionId`, an optional parameter when starting a new session when
running a workflow is an arbitrary string. This allows consumers to
support whatever ids are needed by other systems, but can result in
errors when an OS special or forbidden character is included.
The fix is to escape the paths, in a 1:1 manner. We rely on
EncodeDataString to do this.
* Also modifies the index file to make it easier to determine what the
name of the file on disk is for a given `sessionId`.
* Persist messages during the Function Call Loop
* Revert version reset
* Fix bugs and improve sample
* Fix formatting issues
* Also updating conversation id during run
* Update based on ADR feedback
Azure.AI.Agents.Persistent 1.2.0-beta.10 now targets ME.AI 10.4.0+,
resolving the compatibility issue that required disabling this package.
- Remove IsPackable=false from the csproj
- Re-enable all 6 integration test classes (IntegrationDisabled → Integration)
- Remove outdated compatibility warning from README.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix PydanticSchemaGenerationError with PEP 563 annotations in @tool
_resolve_input_model used raw param.annotation from inspect.signature(),
which returns string annotations when 'from __future__ import annotations'
is active (PEP 563). This caused Pydantic's create_model to fail for
complex types like Optional[int] or FunctionInvocationContext.
Use typing.get_type_hints() to resolve annotations to actual types before
passing them to create_model, matching the approach already used by
_discover_injected_parameters.
Fixes#4809
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Remove reproduction report and unused test imports
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(tests): strengthen PEP 563 regression tests per review feedback (#4809)
- Verify type correctness in schema assertions (not just key presence)
- Fix ctx annotation to FunctionInvocationContext | None for type consistency
- Add test for Optional[CustomType] pattern (original bug trigger)
- Add test for get_type_hints() fallback with unresolvable forward refs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Address review feedback for #4809: Python: [Bug]: PydanticSchemaGenerationError in FunctionInvocationContext
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Bump HostedAgents samples to AgentFramework beta.11 and pass credential to UseFoundryTools
Update all 8 HostedAgents samples:
- Azure.AI.AgentServer.AgentFramework -> 1.0.0-beta.11
- Microsoft.Agents.AI.OpenAI -> 1.0.0-rc4
- Microsoft.Agents.AI/AzureAI/Workflows -> 1.0.0-rc4
- Azure.AI.Projects -> 2.0.0-beta.1
- Fix Workflow.AsAgent() -> AsAIAgent() in FoundryMultiAgent
- Pass credential to UseFoundryTools in AgentWithTools (resolves#56802)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Remove AgentWithTools sample (UseFoundryTools no longer supported)
Remove the AgentWithTools hosted agent sample as the UseFoundryTools
backend is no longer supported. Updated HostedAgents README and solution
file to remove all references.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix AgentWithHostedMCP: downgrade Azure.AI.OpenAI to 2.8.0-beta.1 for rc4 compatibility
Azure.AI.OpenAI 2.9.0-beta.1 has breaking changes (GetResponsesClient no
longer accepts deployment name, ResponsesClient.Model removed) that are
incompatible with Microsoft.Agents.AI.OpenAI rc4. Pin to 2.8.0-beta.1 and
use GetResponsesClient(deploymentName).AsAIAgent() pattern.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix source generator bug that silently drops base class handler registrations for protocol-only partial executors
* Fixed xml comments and variable naming.
* Fix workflow samples broken due to routing change
* Add ADR-0020: Foundry Evals integration design
Captures the design for integrating Azure AI Foundry Evaluations with
agent-framework. Key decisions:
- EvalItem with conversation (list[Message]) as single source of truth
- query/response derived from configurable conversation split strategies
- Tools as list[FunctionTool] (including auto-extracted MCP tools)
- FoundryEvals provider with auto-detection of evaluator capabilities
- LocalEvaluator with @function_evaluator decorator for local checks
- Consistent Python/C# APIs: evaluate_agent, evaluate_workflow
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Mark ADR 0020 Foundry Evals as accepted
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: alliscode <bentho@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Python: avoid duplicate agent response telemetry
* Python: conditionally suppress duplicate agent telemetry
* Simplify telemetry ownership tracking
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Aggregate token usage from inner chat spans on invoke_agent span
The invoke_agent span now carries the aggregated input/output token
counts from all inner chat completion spans that occur during an agent
run. Previously, when inner ChatTelemetryLayer spans captured usage,
the outer AgentTelemetryLayer skipped setting usage entirely to avoid
duplication. Now a new INNER_ACCUMULATED_USAGE context variable tracks
cumulative usage across all inner completions, and the agent span
always reports the total.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Eduard van Valkenburg
·
2026-03-20 10:09:46 +00:00
* Deprecate Azure AI v1 (Persistent Agents API) helper methods
Add DeprecationWarning to v1 classes and functions that have been
superseded by the v2 (Projects/Responses) API:
- AzureAIAgentsProvider -> use AzureAIProjectAgentProvider
- AzureAIAgentClient -> use AzureAIClient
- AzureAIAgentOptions -> use AzureAIProjectAgentOptions
- to_azure_ai_agent_tools() -> use to_azure_ai_tools()
- from_azure_ai_agent_tools() -> use from_azure_ai_tools()
- AzureAIAgentClient static tool factory methods -> use AzureAIClient equivalents
All v1 components still function but emit warnings to guide migration.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add deprecation warnings to AzureAIAgentsProvider methods
Mark create_agent(), get_agent(), and as_agent() as deprecated
individually, pointing to AzureAIProjectAgentProvider equivalents.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Emit tool call events in GitHubCopilotAgent streaming
_stream_updates now yields FunctionCallContent for TOOL_EXECUTION_START
and FunctionResultContent for TOOL_EXECUTION_COMPLETE events from the
Copilot SDK session. This enables DevUI and other consumers to display
tool calls during streaming agent execution. Previously only ASSISTANT_MESSAGE_DELTA, SESSION_IDLE, and SESSION_ERROR
were handled — tool execution events were silently dropped.
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
* Add some tests
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
* Respond to feedback
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
* Fix TOOL_EXECUTION_COMPLETE to use correct SDK types
- Read result text from session_events.Result.content (not ToolResult.text_result_for_llm)
- Read failure state from event.data.success/error (not result_obj.result_type/error)
- Handle ErrorClass.message and plain string errors
- Update tests to use session_events.Result and ErrorClass
- Add tests for string errors, success-with-error, and COMPLETE missing fields
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
---------
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
* [BREAKING] Refactor middleware layering and raw clients
Reorder chat client layers so function invocation wraps chat middleware, and chat middleware stays outside telemetry while still running for each inner model call. Add middleware pipeline caching, refresh docs and samples, and split Anthropic into raw and public clients to match the standard layering model.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Tighten typing ignores in ancillary modules
Add targeted typing ignores in workflow visualization and lab modules so pyright stays clean alongside the middleware refactor work.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix categorize_middleware to unpack tuple/Sequence and use relative MRO assertions
- Broaden isinstance check in categorize_middleware from list to Sequence
so tuples and other Sequence types are properly unpacked instead of
being appended as a single item.
- Replace fragile hardcoded MRO index assertions in anthropic test with
relative ordering via mro.index().
- Add regression tests for categorize_middleware with tuple, list, and
None inputs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix middleware string decomposition, add middleware param to FunctionInvocationLayer, and add tests (#4710)
- Guard categorize_middleware Sequence check against str/bytes to prevent
character-by-character decomposition of accidentally passed strings
- Add explicit middleware parameter to FunctionInvocationLayer.get_response
and merge it into client_kwargs before categorization, fixing the
inconsistency where only OpenAIChatClient supported this parameter
- Add assertions that RawAnthropicClient does not inherit convenience layers
- Add chat middleware cache test with non-empty base middleware
- Add tests for single unwrapped middleware item and string input
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Apply pre-commit auto-fixes
* Address review feedback for #4710: review comment fixes
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
Eduard van Valkenburg
·
2026-03-20 00:43:37 +00:00
* Emit TOOL_CALL_RESULT events on approval resume (#4589)
When a tool call is approved via the interrupt/resume flow,
_resolve_approval_responses executes the tool and injects the result
into the messages array, but no TOOL_CALL_RESULT SSE event was yielded
to the client.
Changes:
- _resolve_approval_responses now returns the list of resolved
function_result Content objects instead of None
- run_agent_stream yields ToolCallResultEvent for each resolved
approval result after RunStartedEvent is emitted
- Add ToolCallResultEvent to ag_ui.core imports in _agent_run.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* fix(ag-ui): address PR review feedback for #4589
1. _resolve_approval_responses now returns only approved results (not
rejections) so TOOL_CALL_RESULT events are emitted only for executed
tools. Rejection results are still written into message history.
2. Emit resolved TOOL_CALL_RESULT events in the no-updates fallback
RUN_STARTED path so approval results are never lost.
3. Rewrite tests to use real FunctionTool with func and
approval_mode='always_require' via StubAgent default_options,
verifying actual tool execution output in TOOL_CALL_RESULT content.
Added test for rejection not emitting TOOL_CALL_RESULT.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix#4589: clean up approval resolution and add missing tests
- Extract duplicated TOOL_CALL_RESULT emission block into
_make_approval_tool_result_events helper to prevent drift
- Remove dead rejection_results construction in _resolve_approval_responses;
_replace_approval_contents_with_results already handles rejections inline
- Pass only approved_results (not all_results) to clarify the contract
- Add mixed approve/reject test validating the core splitting logic
- Add zero-updates test covering the no-updates fallback emission path
- Add direct unit test for _resolve_approval_responses return value
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Fix import sorting lint error in test_approval_result_event.py
Add blank line between first-party and third-party import groups
to satisfy ruff I001 rule.
Fixes#4589
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Python: Emit AG-UI events for MCP tool calls, results, and text reasoning
Fixes#4213 — `_emit_content()` in the AG-UI layer only handled `text`,
`function_call`, `function_result`, `function_approval_request`, `usage`,
and `oauth_consent_request` content types. Foundry MCP content types
(`mcp_server_tool_call`, `mcp_server_tool_result`) and `text_reasoning`
fell through unhandled, producing no SSE events for AG-UI consumers.
Added three new handler functions wired into `_emit_content()`:
- `_emit_mcp_tool_call`: emits TOOL_CALL_START + TOOL_CALL_ARGS and
tracks in FlowState for MESSAGES_SNAPSHOT inclusion
- `_emit_mcp_tool_result`: emits TOOL_CALL_END + TOOL_CALL_RESULT with
full FlowState cleanup mirroring `_emit_tool_result`
- `_emit_text_reasoning`: emits the protocol-defined reasoning event
sequence (ReasoningStart → MessageStart → MessageContent → MessageEnd
→ ReasoningEnd) with ReasoningEncryptedValueEvent for protected_data
* Add HTTP round-trip tests for MCP tool and reasoning SSE events
Exercises the full POST → SSE bytes → parse → validate pipeline for
mcp_server_tool_call, mcp_server_tool_result, text_reasoning, and
ReasoningEncryptedValueEvent content through FastAPI TestClient.
* Fix _emit_mcp_tool_result missing predictive_handler support (#4213)
- Add predictive_handler parameter to _emit_mcp_tool_result and mirror
the apply_pending_updates + StateSnapshotEvent block from _emit_tool_result
- Forward predictive_handler from _emit_content to _emit_mcp_tool_result
- Add assertion for stored arguments in MCP tool call test
- Add test for predictive handler state snapshot after MCP tool result
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Refactor MCP tool emit functions and add missing tests (#4213)
- Extract _emit_tool_result_common shared helper to eliminate duplication
between _emit_tool_result and _emit_mcp_tool_result
- Remove server_name prefix from tool_call_name in _emit_mcp_tool_call;
display_name now equals tool_name directly
- Add test for tool_name fallback to 'mcp_tool' when tool_name is None
- Add test for output=None fallback to empty string in _emit_mcp_tool_result
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback for #4213: review comment fixes
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add script to ping on stale issues/PRs
* Add script to ping on stale issues/PRs
* Fix stale issue/PR ping script review comments
- Rename TEAM_NAME env var to TEAM_SLUG for clarity
- Add actionable error messages for 403/404 team lookup failures
- Add contents:read permission for actions/checkout
- Use github.event.inputs context with fallback for scheduled runs
- Pin PyGithub to 2.6.0 for reproducible builds
- Fetch comments once in should_ping() to reduce API calls
- Make ping() retry loop idempotent (track comment/label state)
- Validate DAYS_THRESHOLD with helpful error for non-numeric input
- Fix timezone bug: use astimezone() instead of replace(tzinfo=)
- Add comprehensive unit tests (29 tests)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Support detail field in OpenAI image_url payload (#4616)
Include the optional 'detail' field from Content.additional_properties
when building image_url payloads for the OpenAI Chat API, matching the
existing pattern used for 'filename' in document file payloads.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Remove reproduction report
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Simplify detail extraction from additional_properties (#4616)
- Remove unnecessary hasattr check; additional_properties is always
initialized as a dict on Content instances.
- Use 'is not None' instead of truthy check to be more precise.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Remove detail allowlist in chat client to align with responses client
Replace the strict allowlist check ('low', 'high', 'auto') with an
isinstance(detail, str) check so that any valid string detail value is
passed through to OpenAI. This aligns the chat client behavior with the
responses client, which passes detail through unconditionally.
Also add test coverage for:
- Future/unknown string detail values being passed through
- Data URI images (covering the 'data' branch of the match)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix zero-argument MCP tool schema missing 'properties' key (#4540)
MCP servers for zero-argument tools (e.g. matlab-mcp-core-server's
detect_matlab_toolboxes) declare inputSchema as {"type": "object"}
without a "properties" key. OpenAI's API requires "properties" to
be present on object schemas, causing a 400 invalid_request_error.
Normalize inputSchema at MCP ingestion in load_tools() to inject an
empty "properties": {} when it is missing from object-type schemas.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback for #4540: improve test robustness and add defensive guard
- Look up loaded functions by name instead of index to avoid brittle
ordering assumptions
- Add negative-path test cases: non-object schema (type: string) and
empty schema ({}) to verify guard clause skips them correctly
- Assert original inputSchema dicts are not mutated by load_tools()
- Add defensive guard for tool.inputSchema being None
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback for #4540: Python: [Bug]: Local stdio MCP works for calculator but fails for official matlab-mcp-core-server on LM Studio /v1/responses
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix A2AAgent to invoke context providers before and after run
A2AAgent.run() bypassed the context provider lifecycle (before_run/after_run)
that BaseAgent defines as a contract for all agents. This caused A2AAgent to
violate the semantic definition of BaseAgent, resulting in inconsistency with
other agent implementations.
The fix follows the same pattern used by WorkflowAgent:
- Create SessionContext and run before_run on all context providers before
processing the A2A stream
- Collect response updates and run after_run on all context providers after
the stream is fully consumed
- Auto-create a session when context providers are configured but no session
is explicitly passed
Fixes#4754
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Remove reproduction report from repository
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address PR review feedback for #4754
- Validate messages when no continuation_token: raise ValueError if
normalized_messages is empty, preventing IndexError on messages[-1]
- Import BaseContextProvider/SessionContext from public agent_framework
package instead of internal agent_framework._sessions module
- Add test for ValueError on run(None) without continuation_token
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Improve test coverage for empty-messages guard in A2AAgent.run (#4754)
- Parameterize test to cover both messages=None and messages=[] inputs
- Add test verifying run(None, continuation_token=...) does not raise
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Eduard van Valkenburg
·
2026-03-19 10:45:42 +00:00
* Fix invoke_agent span to aggregate token usage across LLM calls (#4062)
The FunctionInvocationLayer._get_response() loop was overwriting the
response on each iteration, so usage_details only reflected the last
chat completion call. Now tracks aggregated_usage across all iterations
using add_usage_details() and sets it on the returned response.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Remove reproduction report artifact
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Apply pre-commit auto-fixes
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Eduard van Valkenburg
·
2026-03-19 06:41:33 +00:00
* Fix source generator bug that silently drops base class handler registrations for protocol-only partial executors
* Fixed xml comments and variable naming.