Commit Graph

1911 Commits

  • Python: Add special handling for workflows (#5298)
    * Add special handling for workflows
    
    * Address comments
  • .NET: Add error checking to workflow samples (#5175)
    * Initial plan
    
    * Add WorkflowErrorEvent and ExecutorFailedEvent error checking to all workflow samples
    
    Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/c5d77400-d7ed-4fbe-9103-f5d74aabcf2b
    
    Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
    
    * Fix if/else if consistency for error event handlers per code review feedback
    
    Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/c5d77400-d7ed-4fbe-9103-f5d74aabcf2b
    
    Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
    
    * Address PR comments
    
    * fixup: PR comments
    
    ---------
    
    Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
    Co-authored-by: Jacob Alber <jaalber@microsoft.com>
  • .NET: Add Handoff sample (#5245)
    * feat: Add Handoff sample
    
    * docs: Add Handoff sample to readme
  • .NET: Foundry Evals integration for .NET (#4914)
    * Foundry Evals integration for .NET
    
    - Core evaluation framework: EvalItem, LocalEvaluator, FunctionEvaluator, EvalChecks
    - IAgentEvaluator interface with MeaiEvaluatorAdapter bridge
    - AgentEvaluationExtensions for agent.EvaluateAsync() overloads
    - FoundryEvals wrapping MEAI quality/safety evaluators
    - ConversationSplitters (LastTurn, Full) and IConversationSplitter
    - EvalItem.PerTurnItems() for multi-turn decomposition
    - HasImageContent for multimodal content detection
    - WorkflowEvaluationExtensions for per-agent workflow evaluation
    - 7 eval samples mirroring Python parity:
      02-agents/Evaluation: SimpleEval, ExpectedOutputs, Multimodal
      03-workflows/Evaluation: WorkflowEval
      05-end-to-end/Evaluation: FoundryQuality, MixedProviders, ConversationSplits
    - Comprehensive unit tests (1958 passing)
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Rewrite FoundryEvals to use real Foundry Evals API
    
    Replace MEAI evaluator shim with actual OpenAI EvaluationClient protocol
    methods. FoundryEvals now creates eval definitions, submits runs, polls
    for completion, and fetches per-item results server-side.
    
    - New constructor: FoundryEvals(AIProjectClient, model, evaluators)
    - Add FoundryEvalConverter for MEAI ChatMessage -> Foundry JSON format
    - Add EvalId, RunId, ReportUrl to AgentEvaluationResults
    - All 20 built-in evaluator constants now work (agent, tool, quality, safety)
    - Remove Microsoft.Extensions.AI.Evaluation.Quality/Safety dependencies
    - Update all samples for new constructor (no more ChatConfiguration)
    - Replace BuildEvaluators tests with ResolveEvaluator tests
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Add response output to CustomEvals and ExpectedOutputs samples
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Address review: pagination, validation, error handling, tests
    
    FoundryEvals fixes:
    - Add pagination for output items (has_more/after cursor)
    - Add guard clauses for pollIntervalSeconds/timeoutSeconds <= 0
    - Fix double TryGetProperty for passed field parsing
    - Throw on all-tool-evaluators with no tool definitions
    - Fix XML doc (default 300s, not 180s)
    
    New tests (30 added, 1989 total):
    - EvalChecks: NonEmpty, ContainsExpected (pass/fail/skip/case),
      HasImageContent, ToolCallsPresent
    - FoundryEvalConverter: ConvertMessage (text, image, function call,
      function results fan-out, empty fallback, mixed content),
      ConvertEvalItem, BuildTestingCriteria (quality/agent/tool/groundedness
      data mappings), BuildItemSchema
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Fix review: null-refs, Data.ToString() bug, ContainsExpected, add tests
    
    - Fix NullReferenceException in sample Response display (pattern matching)
    - Fix WorkflowEvaluationExtensions Data?.ToString() producing type names
      instead of message text (pattern-match ChatMessage/AgentResponse/list)
    - Change EvalChecks.ContainsExpected to return Passed=false when no
      ExpectedOutput (was silently passing, masking misconfiguration)
    - Add EvalItem constructor tests with LastTurn/Full/null splitters
    - Add FoundryEvalConverter.ConvertMessage DataContent (base64 image) test
    - Add ExtractAgentData tests with ChatMessage, list, and AgentResponse data
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Fix review: conversation fidelity, eval caching, fallback tests
    
    - WorkflowEvaluationExtensions: preserve full response messages (tool calls,
      intermediate) instead of synthetic 2-message conversation. Cast completed
      Data to AgentResponse and use Messages when available, fallback to text.
    - FoundryEvals: cache evalId per schema shape (hasContext, hasTools) so
      subsequent EvaluateAsync calls create runs under the same eval definition.
    - MeaiEvaluatorAdapter: code already correctly passes queryMessages (not full
      conversation) to IEvaluator — no change needed, verified by inspection.
    - Add tests: AgentResponse full messages preservation, unknown object
      ToString() fallback for ExtractAgentData.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Rename AzureAI→Foundry: move eval files, update references
    
    - Move FoundryEvals.cs and FoundryEvalConverter.cs from
      Microsoft.Agents.AI.AzureAI to Microsoft.Agents.AI.Foundry
    - Update namespace from AzureAI to Foundry in both files
    - Add explicit usings required by Foundry project (no implicit usings)
    - Move FoundryEvalConverter tests to Foundry.UnitTests project
      (avoids ReplacingRedactor type conflict from dual project refs)
    - Update all sample csproj references and using statements
    - Remove Foundry project reference from AI UnitTests
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * PR review round 4: wire up tool extraction, remove eval cache, fix null safety
    
    - BuildEvalItem: extract tools from agent via GetService<ChatOptions>() into EvalItem.Tools (Python parity)
    - FoundryEvals: remove eval ID cache - each call creates fresh definition (matches Python behavior)
    - FoundryEvals: replace null-forgiving operators with descriptive InvalidOperationException
    - MixedProviders sample: remove unnecessary explicit PackageReferences (transitively provided)
    - FoundryEvalConverter: document that tool results take precedence over text content
    - Add LocalEvaluator zero-checks test documenting 0 metrics = failed behavior
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Python-dotnet parity: 9 feature gaps filled
    
    New checks:
    - ToolCallArgsMatch() — verify tool call names + argument subset match
    - ToolCalledCheck(ToolCalledMode.Any, ...) — match any of the specified tools
    - ToolCalledMode enum (All/Any)
    
    FoundryEvals enhancements:
    - Default evaluators now [Relevance, Coherence, TaskAdherence] (was Relevance, Coherence)
    - Auto-add ToolCallAccuracy when items have tool definitions
    - EvaluateTracesAsync — evaluate by response_ids, trace_ids, or agent_id
    - EvaluateFoundryTargetAsync — evaluate deployed Foundry targets
    
    Result type enrichment:
    - AgentEvaluationResults: added Status, Error, PerEvaluator, DetailedItems
    - New EvalItemResult/EvalScoreResult/PerEvaluatorResult types
    - FoundryEvals populates all new fields from API responses
    
    Workflow fix:
    - Skip internal executors (_*, input-conversation, end-conversation, end)
    
    Tests: 8 new tests covering ToolCallArgsMatch, ToolCalledMode.Any, internal executor filtering
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Add MeaiEvaluatorAdapter and PerTurnItems edge case tests
    
    - 3 tests for MeaiEvaluatorAdapter: query message forwarding, synthetic
      response fallback, multiple items aggregation
    - 3 tests for EvalItem.PerTurnItems: empty conversation, no user messages,
      system+assistant only
    - StubEvaluator and StubChatClient test helpers
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Blocking link check for outdated package in DevUI.
    
    * Replace Dictionary<string, object> payloads with typed wire models
    
    Introduce internal FoundryEvalWireModels.cs with compile-time-safe types
    for the OpenAI Evals API wire format. The OpenAI .NET SDK (2.9.1) only
    provides protocol-level methods with BinaryContent/ClientResult — no
    typed request models. These internal models replace scattered dictionary
    literals with [JsonPropertyName]-annotated classes, giving:
    
    - Compile-time safety (typos become build errors)
    - Single point of change when the API evolves
    - IntelliSense discoverability
    - Cleaner serialization via JsonPolymorphic for content items
    
    Models: WireContentItem hierarchy (text, image, tool_call, tool_result),
    WireMessage, WireEvalItemPayload, WireTestingCriterion, WireItemSchema,
    WireCreateEvalRequest, WireCreateRunRequest, and data source variants.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Skip metric when Foundry returns neither score nor passed
    
    When an evaluator returns no score and no passed value, the previous
    code created BooleanMetric(name, false), which falsely failed items
    via ItemPassed. Now we skip the MEAI metric entirely for indeterminate
    results — the raw data remains available in DetailedItems for diagnostics.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Address PR #4914 review comments: fix tool evaluator bug and add tests
    
    - Fix duplicate ToolCallAccuracy: resolve evaluator names before checking
      against ToolEvaluators set (Comment 2)
    - Make FilterToolEvaluators internal for testability; add tests for the
      ArgumentException edge case when all evaluators are tool-type (Comment 3)
    - Add CancellationToken test for LocalEvaluator (Comment 4)
    - Add EvaluateAsync integration test on Run with sequential workflow and
      per-agent SubResults verification (Comment 5)
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Address Peter's review comments on PR #4914
    
    - Add trailing newline to Evaluation_FoundryQuality.csproj (Comment 6)
    - Make evaluator name lookups case-insensitive: switch BuiltinEvaluators,
      ToolEvaluators, AgentEvaluators, and ResolveEvaluator's StartsWith check
      from Ordinal to OrdinalIgnoreCase (Comment 7)
    - Add Trace.TraceWarning when Foundry returns fewer results than submitted
      items, indicating expected vs actual count before padding (Comment 8)
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Add Microsoft.Extensions.AI.Evaluation packages to Directory.Packages.props
    
    These were removed in #5269 as unused, but are needed by the Foundry
    and core evaluation integration added in this PR.
    
    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: Feat: Add finish_reason support to AgentResponse and AgentResponseUpdate (#5211)
    * feat: add finish_reason support to AgentResponse and AgentResponseUpdate
    
    Add finish_reason field to AgentResponse and AgentResponseUpdate classes,
    propagate it through _process_update() and map_chat_to_agent_update(),
    and add comprehensive unit tests.
    
    Fixes #4622
    
    * feat: add finish_reason to AgentResponse and AgentResponseUpdate
    
    * style: add copyright header to test_finish_reason.py
    
    * docs: add finish_reason to AgentResponse and AgentResponseUpdate docstrings
    
    * refactor: move finish_reason tests into test_types.py per review feedback
    
    Move all finish_reason test cases from the separate test_finish_reason.py
    file into test_types.py as requested by eavanvalkenburg. Tests are placed
    in a new '# region finish_reason' section at the end of the file.
    
    * fix: use model instead of model_id in _process_update
    
    Address PR review feedback from @eavanvalkenburg — ChatResponse and
    ChatResponseUpdate both use 'model', not 'model_id'.
    
    * fix: resolve SIM102 lint error in _process_update
    
    Combine nested if statements for AgentResponse finish_reason check
    to satisfy ruff SIM102 rule, with line wrapping to stay under 120 chars.
    
    * fix: resolve pyright reportArgumentType in map_chat_to_agent_update
    
    Add type: ignore[arg-type] for FinishReason NewType widening when
    passing ChatResponseUpdate.finish_reason to AgentResponseUpdate.
    Matches existing patterns in the codebase (40+ similar ignores).
  • Python: Fix Gemini client support for Gemini API and Vertex AI (#5258)
    * Add Gemini and Vertex AI client support
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Address Gemini PR review feedback
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * removed sample run readme part
    
    ---------
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
  • .NET: Improve local release build perf by only formatting for one build target framework (#5266)
    * Improve local release build perf by only formatting for one build target framework
    
    * Update dotnet/Directory.Build.targets
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  • .NET: Update Microsoft.Extensions.AI to 10.5.0 and OpenAI to 2.10.0 and remove unused refs (#5269)
    * Update versions of System, Microsoft.Extensions and OpenAI packages
    
    * Remove unused package references
    
    * Remove further unused references
  • Python: Handle url_citation annotations in FoundryChatClient streaming responses (#5071)
    * Fix url_citation annotations dropped in streaming (#5029)
    
    Add url_citation branch to the streaming annotation handler in
    _parse_chunk_from_openai, mirroring the existing non-streaming path.
    The handler creates an Annotation with type='citation', title, url,
    and annotated_regions (TextSpanRegion), wrapped in Content.from_text.
    
    Update test_streaming_annotation_added_with_unknown_type to use a
    truly unknown type, and add new tests for url_citation (with and
    without url).
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Address review feedback for #5029: Python: [Bug]: url_citation annotations silently dropped in Foundry streaming (SharePoint grounding citations lost)
    
    ---------
    
    Co-authored-by: Copilot <copilot@github.com>
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
  • Bump Anthropic SDK to 12.13.0 and Anthropic.Foundry to 0.5.0 (#5279)
    - Update Anthropic from 12.11.0 to 12.13.0
    - Update Anthropic.Foundry from 0.4.2 to 0.5.0
    - Change Anthropic project from release candidate to preview
    - Add new IBetaService members (Agents, Environments, Sessions, Vaults) to test mock
  • Add AgentExecutorResponse.with_text() to preserve conversation history through custom executors (#5255)
    Fixes #5246
    
    When a custom @executor transforms agent output and sends a plain str,
    the downstream AgentExecutor.from_str handler loses the full conversation
    context. This adds a with_text() helper that creates a new
    AgentExecutorResponse with replaced text while preserving the prior
    conversation chain, so AgentExecutor.from_response is invoked instead.
    
    - Add with_text(text) method to AgentExecutorResponse dataclass
    - Add 3 regression tests in test_full_conversation.py
    
    Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
  • .NET: Fix intermittent checkpoint-restore race in in-process workflow runs (#5134)
    * Improve workflow unit tests
    
    * Update test name prefix for clarity.
    
    * Update tests to surface any errors.
    
    * fix check-point restore-time race in off-thread workflow event stream
    
    * Fixes an intermittent checkpoint-restore race in in-process workflow runs.
  • Python: Add OpenAI types to default checkpoint encoding allow list (#5297)
    * Add OpenAI types to default checkpoint encoding allow list
    
    * Address comments
  • Python: Add context_providers and description to workflow.as_agent() (#4651)
    * Add context_providers and description to `workflow.as_agent()`
    
    * Add default workflow name and description
    
    * Positional
    
    * Move import
    
    ---------
    
    Co-authored-by: Tao Chen <taochen@microsoft.com>
    Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
  • Revert to public MCP server and skip on transient upstream errors (#5296)
    The local MCP server can't be used for hosted tools tests because
    Anthropic's backend needs to reach the MCP URL from their infrastructure
    (not localhost on the CI runner). Revert to learn.microsoft.com/api/mcp
    but catch BadRequestError, InternalServerError, APIConnectionError, and
    APITimeoutError and pytest.skip so upstream outages don't block the
    merge queue.
  • Python: improve misc-integration test robustness (#5295)
    * Python: use local MCP server for hosted tools test and broaden image assertion
    
    The hosted tools integration test was hitting rate limits on the external
    learn.microsoft.com MCP server, causing persistent failures that retries
    couldn't recover from. Switch to the local MCP server already spun up in
    CI via LOCAL_MCP_URL, skipping when the env var isn't set.
    
    Also broaden the image description assertion to accept common synonyms
    (cottage, mansion, villa, etc.) instead of just "house", since the model
    legitimately uses varied vocabulary for the same image.
    
    * Address review feedback: validate LOCAL_MCP_URL scheme and use word boundaries
    
    - Skip hosted tools test when LOCAL_MCP_URL lacks http/https scheme,
      matching the pattern used in test_mcp.py.
    - Use regex word boundaries for image assertion to avoid false matches
      like "villain" matching "villa".
  • Python: bump misc-integration retry delay to 30s (#5293)
    The misc-integration job (Anthropic, Ollama, MCP) frequently fails on merge to main when the upstream MCP server (e.g. learn.microsoft.com/api/mcp) returns a transient rate-limit error. The previous 5s retry delay is too short to ride out the upstream backoff window, so all retries fail and the merge queue is blocked. Bumping to 30s gives the upstream a chance to recover before pytest-retry re-runs the test.
  • Python: add experimental file history provider (#5248)
    * add experimental file history provider
    
    * Improve file history provider writes
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * typo
    
    * cleanup
    
    * cleanup
    
    * fix in readme
    
    * added security messages
    
    * Refine file history provider locking
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * added additional sample
    
    ---------
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Python: Upgrade agentserver packages (#5284)
    * Upgrade agentserver packages
    
    * Fix new types
  • Python: Bump agent-framework-devui to 1.0.0b260414 for release (#5259)
    Update devui version and changelog for the streaming memory fix release.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Python: Refine samples and upgrade packages (#5261)
    * Refine samples and upgrade pacakges
    
    * Upgrade to a new package that fixes a bug
    
    * Update model env var
  • Python: Fix reasoning replay when store=False (#5250)
    * fix reasoning content when store=False
    
    * Remove accidental worktree entries
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * remove local session sample
    
    * removed left over files
    
    * Add attribution override regression test
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Python: Add GeminiChatClient (#4847)
    * Add agent-framework-gemini package
    
    * Add AGENTS.md documentation
    
    * Add LICENSE file
    
    * Add README.md for agent-framework-gemini package
    
    * Add Google Gemini API keys to .env.example
    
    * Add Google Gemini chat client implementation
    
    * Add tests for GeminiChatClient
    
    * Add Google Gemini agent examples
    
    * Fix client inheritence order
    
    * Update Gemini agent examples
    
    * Update documentation
    
    * Update AGENTS.md
    
    * Add tests for JSON string handling in GeminiChatClient
    
    * Add final response assembly test in GeminiChatClient
    
    * Add tests for handling empty candidates in GeminiChatClient
    
    * Improve Pydantic response handling in GeminiChatClient
    
    * Add tests for function result resolution and callable tool normalization
    
    * Add test for function result resolution when call_id is generated
    
    * Refactor GeminiChatClient to correct inheritance order
    
    Also updates constructor parameter order for environment file handling
    
    * Enhance documentation and clarify Gemini-specific fields
    
    * Update ThinkingConfig with new attributes and type
    
    * Add tests for GoogleSearch and GoogleMaps configs
    
    * Suppress valid-type mypy error on GeminiChatOptionsT
    
    * Move service_url method near overrides
    
    * Order _prepare_config kwargs by base then Gemini-specific
    
    * Use FunctionCallingConfigMode for clarity and type safety
    
    * Fix code_execution doc
    
    * Add agent-framework-gemini to project dependencies
    
    * Remove package from core dependencies
    
    Initial release will be done without agent-framework-gemini in
    core[all].
    
    * Move integration tests into one file
    
    * Remove __init__.py file from gemini tests directory
    
    * Introduce RawGeminiChatClient as lightweight chat client
    
    Updated GeminiChatClient to inherit from RawGeminiChatClient, maintaining full functionality with added features.
    
    * Updated variable names from `model_id` to `model`
    
    Across the codebase, including environment variables and client initialization. Adjusted related tests and sample scripts to reflect this change, ensuring consistency in the usage of the Gemini model identifier.
    
    * Update AGENTS.md
    
    * Update Gemini package to alpha status
    
    * Fix docstrings in Gemini tests
    
    * Change 'model_id' to 'model' in response handling
    
    * Fix model property change in response handling
    
    * Add built-in tool factory methods to Gemini client
    
    Replaces boolean tool options (code_execution, google_search_grounding,
    google_maps_grounding) with static factory methods that return types.Tool
    objects: get_code_interpreter_tool, get_web_search_tool, get_mcp_tool,
    get_file_search_tool, and get_maps_grounding_tool.
    
    Simplifies _prepare_tools to a single translation boundary between
    FunctionTool (framework) and FunctionDeclaration (Gemini API), with
    types.Tool objects passed through unchanged.
    
    * Surface code execution parts
    
    _parse_parts now maps executable_code and code_execution_result
    parts to text Content objects so callers can see the code run
    and its output. Unknown part types log at debug level rather than
    being silently dropped.
    
    * Update Gemini client documentation
    
    * Unify Gemini model name
    
    Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
    
    * Update Agent Framework core version
    
    Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
    
    * Add Python 3.14 in classifiers
    
    * Replace kwargs with parameters in tool factories
    
    * Refactor chat options handling in Gemini client
    
    * Add tests for handling unknown and consumed keys
    
    * Update Gemini documentation
    
    Now reflects new options and built-in tool factory methods
    
    * Change build system to flit
    
    Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
    
    * Fix build system in pyproject.toml
    
    * Fix type checking for generate_content_stream
    
    ---------
    
    Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
  • Python: Skip get_final_response in OTel _finalize_stream when stream errored (#5232)
    * Python: Skip get_final_response in OTel _finalize_stream when stream errored
    
    When a streaming error occurs, _finalize_stream (a cleanup hook registered by
    AgentTelemetryLayer) was unconditionally calling get_final_response(), which
    triggers all registered result hooks including after_run context providers.
    This caused providers to fire incorrectly on error paths.
    
    Guard against this by checking result_stream._consumed: True only after
    StopAsyncIteration (normal completion), False when an exception was raised.
    The fix applies to both the chat client and agent telemetry layers.
    
    Closes #5231
    
    * Python: Expose consumed/stream_error on ResponseStream and capture error in OTel span
    
    Address Copilot review feedback on #5232:
    
    - Add `_stream_error: Exception | None` to ResponseStream, set in __anext__'s
      except branch so cleanup hooks can inspect the failure.
    - Expose public `consumed` and `stream_error` properties to avoid coupling
      observability.py to private stream internals.
    - Update both _finalize_stream closures (chat and agent layers) to use the
      public properties and call capture_exception() with the stream error before
      returning early, ensuring the OTel span records the failure rather than
      closing silently.
    
    * Python: Address Copilot review feedback on stream error handling
    
    - Use stream_error is not None as the guard in _finalize_stream instead of
      not consumed, so the early-return path is keyed precisely to actual errors
      rather than any non-normal completion state.
    - Clear _stream_error after _run_cleanup_hooks() completes to avoid retaining
      the exception traceback (and any large object graphs it references) on the
      stream instance beyond the cleanup phase.
    
    * Python: Remove consumed/stream_error properties, use private attrs directly
    
    Per review feedback: since observability.py and _types.py are in the same
    package, accessing _stream_error directly is fine and the public properties
    are unnecessary.
    
    * Python: Fix Pyright reportPrivateUsage via inline ignore comments
    
    Keep _stream_error private (consistent with rest of ResponseStream), and
    suppress reportPrivateUsage at the call sites in observability.py with
    inline pyright: ignore comments — access is intentional within the package.
  • Python: Fix DevUI streaming memory growth and add cross-platform regression coverage (#5221)
    * fix for memory leak in devui
    
    * update async sleep
    
    * remove old func
  • Python: Move InMemory history provider injection to the first invocation (#5236)
    * Move InMemory history provider injection to the first invocation
    
    * Add tests
  • Python: AG-UI deterministic state updates from tool results (#5201)
    * AG-UI deterministic state updates from tool results
    
    * fix(ag-ui): address PR #5201 review comments
    
    1. Add missing AGUIEventConverter, AGUIHttpService, __version__ to
       _IMPORTS in core ag_ui lazy-export list to match the .pyi stub.
    
    2. Coalesce predictive and deterministic state snapshots into a single
       StateSnapshotEvent when both mechanisms are active on the same tool
       result, reducing redundant snapshot traffic.
    
    3. Update state_update() docstring to clarify that a predictive snapshot
       may be emitted before the deterministic one when predict_state_config
       is active.
    
    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: Fix HandoffBuilder dropping function-level middleware when cloning agents (#5220)
    * Fix HandoffBuilder dropping function-level middleware when cloning agents (#5173)
    
    _clone_chat_agent() was using agent.agent_middleware (agent-level only)
    instead of agent.middleware (all types), which silently dropped any
    function middleware registered on the original agent.
    
    Changed to use agent.middleware to preserve all middleware types
    (agent, function, and chat) during cloning.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Python: Fix HandoffBuilder dropping function-level middleware when cloning agents
    
    Fixes #5173
    
    * Fix false-positive middleware regression test (#5173)
    
    The test used isinstance(m, FunctionMiddleware) which matched
    _AutoHandoffMiddleware (always appended during build) instead of the
    user's @function_middleware decorator. Assert directly that
    tracking_middleware is present in the cloned agent's middleware list.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Address review feedback for #5173: Python: [Bug]: HandoffBuilder drops function-level middleware when cloning agents
    
    ---------
    
    Co-authored-by: Copilot <copilot@github.com>
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Python: Add allowed_checkpoint_types support to CosmosCheckpointStorage for parity with FileCheckpointStorage (#5202)
    * Python: Add allowed_checkpoint_types support to CosmosCheckpointStorage (#5200)
    
    Add allowed_checkpoint_types parameter to CosmosCheckpointStorage for
    parity with FileCheckpointStorage. This ensures both providers use the
    same restricted pickle deserialization by default.
    
    Changes:
    - Accept allowed_checkpoint_types kwarg in __init__, stored as frozenset
    - Convert _document_to_checkpoint from @staticmethod to instance method
    - Forward allowed_types to decode_checkpoint_value on all load paths
    - Update class docstring to describe the new parameter
    - Add tests covering built-in safe types, app type opt-in/blocking,
      and all load paths (load, list_checkpoints, get_latest)
    - Add changelog entry noting the breaking behavior change
    
    BREAKING CHANGE: CosmosCheckpointStorage now uses restricted pickle
    deserialization by default. Checkpoints containing application-defined
    types will require passing those types via allowed_checkpoint_types.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * Python: Add `allowed_checkpoint_types` support to `CosmosCheckpointStorage` for parity with `FileCheckpointStorage`
    
    Fixes #5200
    
    * Address PR review: add pickle security warning and fix docstring examples
    
    - Reintroduce explicit security warning about pickle deserialization risks
    - Convert Example:: block to .. code-block:: python with imports for
      consistency with other docstring examples
    - Note: PR title should be updated to include [BREAKING] prefix per
      changelog convention (comment #3, requires GitHub UI change)
    
    Fixes #5200
    
    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: skill name validation improvements (#4530)
    * Initial plan
    
    * Port .NET validation improvements to Python skills: reject consecutive hyphens and enforce directory name match
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    * Fix E501 lint error: split long error message string in _validate_skill_metadata
    
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
  • Add tests and more content types (#5235)
    * Add tests
    
    * fix tests and sample
    
    * Fix formatting
    
    * Remove function approval contents
  • Bump pygments from 2.19.2 to 2.20.0 in /python (#4978)
    Bumps [pygments](https://github.com/pygments/pygments) from 2.19.2 to 2.20.0.
    - [Release notes](https://github.com/pygments/pygments/releases)
    - [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
    - [Commits](https://github.com/pygments/pygments/compare/2.19.2...2.20.0)
    
    ---
    updated-dependencies:
    - dependency-name: pygments
      dependency-version: 2.20.0
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Python: Fix python-feature-lifecycle skill YAML frontmatter (#5226)
    * Fix python-feature-lifecycle skill YAML frontmatter
    
    Remove copyright comment that preceded the YAML frontmatter delimiter,
    which prevented the skill from loading. The --- block must be the very
    first line of SKILL.md.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * fix: update broken eslint-react plugin links in devui README
    
    The upstream eslint-react repo moved plugins from packages/plugins/
    to the top-level plugins/ directory, causing 404 errors detected by
    linkspector CI.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • .NET: Update AGUI service to support session storage (#5193)
    * Update AGUI service to support session storage
    
    * Apply suggestion from @Copilot
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    * Address PR comments
    
    ---------
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  • .NET: feat: Refactor Handoff Orchestration and add HITL support (#5174)
    * feat: Refactor Handoff Orchestration and add HITL support
    
    * Change HandoffAgentExecutor to use factory-based instantiation
    * Extract shared request collection logic in AIAgentUnservicedRequestsCollector
    * Refactor HandoffAgentExecutor to use the "ContinueTurn" pattern as in AIAgentHostExecutor
    
    * fix: Remove '$' from exception strings
  • Python: Wrapper + Samples 1st (#5177)
    * Experiment
    
    * Update dependency and add non streaming
    
    * Add more samples
    
    * Rename samples
    
    * Add invocations
    
    * Comments 1
    
    * Comments 2
    
    * Comments 3
    
    * Improve README
    
    * Add local shell sample
    
    * WIP: Add eval and memory samples
    
    * Update user agent prefix
    
    * Update user agent prefix doc
  • .NET: Update version to 1.1.0 (#5204)
    * Update version to 1.1.0
    
    * Apply suggestion from @Copilot
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  • Standardize file skills terminology on 'directory' (#5205)
    Rename authored identifiers, XML docs, log messages, and comments
    from 'folder' to 'directory' across the file skills codebase for
    consistency with the agentskills.io specification and .NET conventions.
    
    Public API changes (experimental):
    - ScriptFolders → ScriptDirectories
    - ResourceFolders → ResourceDirectories
    
    .NET BCL API calls (Directory.Exists, Path.GetDirectoryName, etc.)
    were already using 'directory' and are unchanged.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • .NET: Support reflection for discovery of resources and scripts in class-based skills (#5183)
    * support reflection for discovery of resources and scripts in class-based skills
    
    * fix format issues
    
    * refactor samples to use reflection
    
    * Validate resource member signatures during discovery
    
    Add discovery-time validation in AgentClassSkill.DiscoverResources() to
    fail fast when [AgentSkillResource] is applied to members with incompatible
    signatures:
    
    - Reject indexer properties (getter has parameters)
    - Reject methods with parameters other than IServiceProvider or
      CancellationToken
    
    Throws InvalidOperationException with actionable error messages instead of
    allowing silent runtime failures when ReadAsync invokes the AIFunction with
    no named arguments.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * prevent duplicates
    
    ---------
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>