Skip to content

test: add Microsoft Agent Framework VCR coverage - #259

Open
sipercai wants to merge 1 commit into
mainfrom
test/maf-vcr-contract
Open

test: add Microsoft Agent Framework VCR coverage#259
sipercai wants to merge 1 commit into
mainfrom
test/maf-vcr-contract

Conversation

@sipercai

@sipercai sipercai commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR adds a test-first, replay-only VCR contract for the Microsoft Agent Framework instrumentation and fixes an oldest-supported-version compatibility gap.

  • exercises the real MAF framework and OpenAI-compatible client across content-disabled/content-enabled non-streaming, fully consumed streaming, deferred finalization, tool round-trip, provider error, and concurrent calls;
  • includes five bounded DashScope provider recordings as the real-provider baseline and two deterministic local OpenAI-compatible supplements for tool and error behavior;
  • defaults committed replay to record_mode=none, fake credentials, strict request matching, and sanitized cassette headers/identifiers;
  • adds reproducible oldest/latest dependency lanes and the generated GitHub Actions jobs;
  • calls MAF's enable_instrumentation(force=True) only when the installed MAF version exposes the force parameter.

The framework/client packages are test-only dependencies; runtime package metadata is unchanged. Commercial probe packaging and Robin-only behavior are outside this PR.

Fixes # (N/A)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • tox -e precommit
  • uvx --from 'tox>=4,<5' tox -e generate-workflows
  • uvx --from 'tox>=4,<5' tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-microsoft-agent-framework-oldest,py312-test-loongsuite-instrumentation-microsoft-agent-framework-latest -- --vcr-record=none -q

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Validation Evidence

Spec and Scope

  • Linked issue/spec: MAF-VCR-TDD Spec v1; no GitHub issue.
  • Approved spec/comment: approved before implementation.
  • Changed surface: MAF instrumentation startup compatibility, real-framework replay tests/cassettes, test dependency lanes, and generated CI matrix.

Local Checks

Check Command Result Notes
Static readiness LoongSuite check_loongsuite_pr_readiness.py --repo . --base origin/main --committed-only pass No errors or warnings.
Precommit tox -e precommit with a fresh hook cache pass No files modified.
Focused tests uvx --from 'tox>=4,<5' tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-microsoft-agent-framework-oldest,py312-test-loongsuite-instrumentation-microsoft-agent-framework-latest -- --vcr-record=none -q pass 79 tests passed in each lane.
Test-first red Same replay tests against fd2cd94^ pass Collection and cassette replay succeeded; all seven scenarios reached targeted telemetry assertions and failed on the pre-fix source.
VCR replay-only Focused tox command above with --vcr-record=none pass Seven scenarios, fake credentials, no cassette misses or network fallback.
Independent review Two qoder review rounds pass Final verdict LGTM; no blocking findings. Serializer versions were pinned after review.
VCR/privacy scan Repository cassette privacy scan pass No credentials, local paths, usernames, auth/cookie/trace/request headers, or private keys found.

Business Isolation

Scenario Status Evidence
prepare/start fault N/A No business-call wrapper or prepare/start callback behavior changed.
response mapping/stop fault N/A No response-mapping or stop callback implementation changed.
fail callback fault N/A No failure callback implementation changed.
stream chunk/final callback fault N/A No stream callback wrapper changed; replay validates framework-owned finalization only.
early close/cancellation/GeneratorExit N/A MAF exposes deferred final-response retrieval, not provider transport cancellation, on this tested surface.
cross-task or cross-Context stream N/A No context token reset implementation changed.
clean sibling after fault N/A No instrumentation callback fault path changed.

Real E2E Matrix

Scenario Status Command or Demo Evidence
non-streaming pass Real MAF + provider-recorded VCR replay Content-disabled and content-enabled calls produce a closed AGENT/LLM trace.
streaming pass Real MAF + provider-recorded SSE replay Fully consumed and deferred-finalization flows complete with expected content and TTFT where supported.
concurrency pass Two concurrent real-framework calls Trace IDs, parents, and captured content remain isolated.
agent/tool/ReAct pass Deterministic local OpenAI-compatible tool replay One AGENT, two LLM, and one TOOL span form one closed trace.
tool-heavy N/A Not part of the changed surface The PR changes replay coverage and startup compatibility, not multi-tool orchestration.
error path pass Deterministic provider-500 replay AGENT and LLM spans retain one trace and export ERROR status.

Telemetry and Weaver

Check Status Command or Artifact Notes
Span tree / span kinds pass Seven replay scenarios Closed AGENT roots with expected LLM/TOOL counts and no cross-trace parents.
Content capture modes pass Content-disabled and content-enabled replays Sensitive message/system attributes are absent when disabled and present when enabled.
Concurrency isolation pass Two-call replay No trace, parent, or content leakage.
Weaver live-check pass Actual in-memory-exported AGENT and LLM sample checked with the loongsuite-genai advice profile No violations; only registry development-stability and provider-enum advisories.

CI

  • GitHub checks: pending PR creation.
  • Known unrelated failures: none.
  • Follow-up needed: monitor the generated oldest/latest MAF jobs after publication.

@ralf0131

ralf0131 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Merge conflict detected

This PR has conflicts with the main branch and cannot be merged. Please rebase or merge main into your branch and resolve the conflicts:

git fetch origin
git checkout test/maf-vcr-contract
git rebase origin/main
# resolve conflicts, then:
git push --force-with-lease

This is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved.


Automated notification by github-manager-bot

@ralf0131 ralf0131 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR adds comprehensive VCR-based integration tests for the Microsoft Agent Framework instrumentation, covering 8 scenarios (non-streaming, streaming, tools, errors, concurrency, content modes). It also includes a clean backwards-compatibility fix for MAF 1.0 by using inspect.signature() to conditionally pass the force parameter to enable_instrumentation().

The code is well-structured, test coverage is thorough, and the compatibility fix is minimal and safe. LGTM.

Findings

  • [Info] conftest.pyrecord_mode: "none" is the right default for CI safety. Contributors re-recording cassettes locally will need to explicitly set record_mode="once" — consider adding a brief comment in the file header for discoverability.
  • [Info] test_integration_vcr.py — The _assert_closed_maf_trace helper is a solid abstraction. It correctly verifies root span kind, child span count, and that all spans are ended. Consider also asserting status_code != StatusCode.UNSET for error-path tests to catch accidental status regressions.
  • [Info] __init__.py — The inspect.signature() approach with try/except (TypeError, ValueError) fallback is robust. Clean fix for MAF 1.0 compatibility.

Automated review by github-manager-bot

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.

4 participants