Commit Graph

6 Commits

  • Python: Add support for function approval flow in Foundry hosted agent (#5666)
    * Add support for function approval flow in Foundry hosted agent
    
    * Address comments
    
    * Address comments
    
    * Address comments
  • Python: Fix hosted MCP replay producing orphan function_call_output (#5581)
    * Python: Fix hosted MCP replay producing orphan function_call_output
    
    Resolves part of #5546. After a turn ran a hosted MCP / Foundry-toolbox-MCP
    tool, the next turn's replayed input array carried a function_call_output
    with an mcp_* call_id and no matching function_call, and the Responses API
    returned a 400.
    
    Two layers covered here:
    
    * Chat-client serialize layer (packages/openai): adds mcp_server_tool_call
      and mcp_server_tool_result cases to _prepare_message_for_openai and
      _prepare_content_for_openai. Pairs are coalesced via a post-pass into a
      single mcp_call input item carrying both arguments and output. Orphan
      results are dropped (debug-logged) rather than serialized as orphan
      function_call_output, which is what the Responses API rejected.
    
    * Host read layer (packages/foundry_hosting): _item_to_message and
      _output_item_to_message now route custom_tool_call_output whose
      call_id.startswith("mcp_") to Content.from_mcp_server_tool_result.
      Non-mcp_ call_ids continue to produce Content.from_function_result.
      Symmetric with the host write-side choice for hosted-MCP results.
    
    Two further fixes (agentserver SDK additions, host write-side single-item
    emission) remain tracked on the issue and depend on an SDK release.
    
    * Python: Fix pyright unknown-type in _stringify_mcp_output
    
    cast(Sequence[Any], output) after the isinstance check so pyright stops
    flagging the loop variable as unknown. Also normalizes a couple of
    em-dashes in docstrings I introduced in the prior commit.
    
    * Python: Harden _stringify_mcp_output for dict-shaped MCP outputs
    
    Address Copilot review on PR #5581. Today the helper falls back to
    str() for any non-string, non-text-attribute entry, which produces
    Python repr (single-quoted dicts) for the canonical MCP raw-JSON
    text-content shape `{"type": "text", "text": "..."}` and any other
    dict-shaped output.
    
    Three small changes:
    
    * List-entry path: prefer plain string entries, then `.text` attribute
      (Content objects), then `entry["text"]` for Mapping entries in the
      canonical MCP shape, then JSON-encode anything else.
    * Final fallback: `json.dumps(output, default=str)` so Mappings and
      scalars produce valid JSON rather than Python repr.
    * Two new unit tests covering the dict-with-text shape and the
      non-text-dict JSON fallback.
    
    * Python: Suppress mypy redundant-cast on _stringify_mcp_output narrowing
    
    The cast is needed by pyright (reportUnknownVariableType) but mypy
    considers it redundant after the preceding isinstance narrowing.
    Pyright's behavior is correct for the strict-mode reporting we run,
    so keep the cast and silence mypy on the line.
  • Python: Update hosting agent samples + fixes (#5485)
    * Update foundry hosting samples
    
    * Add file data type support
    
    * Fix file content and add more tests
    
    * Fix README
    
    * Address comments
    
    * Fix int tests
    
    * remove temp
  • Python: update FoundryAgent for hosted agent sessions (#5447)
    * fixes to FoundryAgent to connect to new hosted agents
    
    Co-authored-by: Copilot <copilot@github.com>
    
    * fix mypy
    
    Co-authored-by: Copilot <copilot@github.com>
    
    * Python: remove Foundry service session helpers
    
    Remove the public hosted-agent service session CRUD helpers from FoundryAgent and drop the related feature-stage inventory entry.
    
    Update the hosted-agent sample to create and delete service sessions directly through the preview AIProjectClient APIs, and tighten a few test harnesses surfaced by full workspace validation.
    
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    
    * fix from merge
    
    * fix hosted env detection
    
    Co-authored-by: Copilot <copilot@github.com>
    
    * reverted sample update
    
    * fix tests and code
    
    Co-authored-by: Copilot <copilot@github.com>
    
    * remove aenter
    
    * skipping some tests
    
    Co-authored-by: Copilot <copilot@github.com>
    
    ---------
    
    Co-authored-by: Copilot <copilot@github.com>
    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Python: Upgrade hosting server dependency and add more type support (#5459)
    * Upgrade hosting server dependency and add more type support
    
    * Comments
  • Python: Foundry hosted agent V2 (#5379)
    * 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
    
    * Update dependency (#5215)
    
    * Add tests and more content types (#5235)
    
    * Add tests
    
    * fix tests and sample
    
    * Fix formatting
    
    * Remove function approval contents
    
    * 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
    
    * Move samples (#5281)
    
    * Python: Upgrade agentserver packages (#5284)
    
    * Upgrade agentserver packages
    
    * Fix new types
    
    * Python: Add special handling for workflows (#5298)
    
    * Add special handling for workflows
    
    * Address comments
    
    * Improve samples (#5372)
    
    * Python: Add more types (#5378)
    
    * Add more type supports
    
    * Upgrade packages
    
    * Remove TODOs in README
    
    * Fix README
    
    * Comments and mypy
    
    * User agent scoped
    
    * Fix README
    
    * Fix pre commit
    
    * Fix pre commit 2
    
    * Fix pre commit 3
    
    * Fix pre commit 4
    
    * Fix pre commit 5
    
    * Fix pre commit 6
    
    * Add azure-monitor-opentelemetry to dev deps
    
    Fixes Samples & Markdown CI failure. The PR's new transitive dep on
    azure-monitor-opentelemetry-exporter (via azure-ai-agentserver-core) makes
    pyright resolve the azure.monitor.opentelemetry namespace, flipping the
    check_md_code_blocks diagnostic for `configure_azure_monitor` from
    reportMissingImports (filtered) to reportAttributeAccessIssue (not filtered).
    Installing the umbrella azure-monitor-opentelemetry package in dev makes
    pyright resolve the symbol correctly, matching the install guidance the
    observability README already gives users.
    
    ---------
    
    Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>