feat: integrate AgentScope v2, MAF, and bootstrap registry updates#233
Merged
Conversation
16 tasks
This was referenced Jul 1, 2026
85ac7e7 to
5509517
Compare
…te.md Implements the hybrid "SpanProcessor + optional ReAct step patch" plan documented in llm-dev/microsoft-agent-framework/investigate/execute.md. - MicrosoftAgentFrameworkInstrumentor: enables MAF native OTel layers (force=True) and registers MAFSemanticProcessor. - MAFSemanticProcessor (span_processor.py): injects gen_ai.span.kind, gen_ai.operation.name, renames MAF private-prefix attributes to gen_ai.*, normalizes provider.name (azure_openai -> openai), backfills TTFT from streaming events, sets StatusCode.OK on success, aggregates the 6 ARMS gauges. Reuses opentelemetry.util.genai.utils.gen_ai_json_dumps (aligned with openai-agents-v2/span_processor.py:27) to coerce dict/list attribute values into JSON strings. - react_step_patch.py (opt-in via ARMS_MAF_REACT_STEP_ENABLED): emits one react step span per LLM round-trip inside FunctionInvocationLayer via ExtendedTelemetryHandler.react_step() from opentelemetry-util-genai. - config.py: env switches (master, sensitive data, react step, slow threshold). - tests: 23 passing unit tests covering span classification, metric aggregation, provider normalization, TTFT backfill, dict coercion, and react_step handler behavior.
[M1] MCP span classification: detect mcp.method.name attribute (or SpanKind.CLIENT + mcp.* fallback) in _classify_span and return (CLIENT, MCP). MAF_SPAN_NAME_PREFIXES documents that MCP is detected via attribute rather than prefix (method names are unbounded). [M2] revert_react_step_patch: capture originals BEFORE wrapping (via __wrapped__ unwrap chain), and switch from broken decorator form to wrap_function_wrapper(class, name, wrapper) + @wrapt.decorator. revert now restores the original; apply->revert->apply does not stack wrappers. [L1] _safe_dumps: cap output at 4096 chars (execute.md single-field cap) since gen_ai_json_dumps only serializes. Docstring + module docstring updated to match actual behavior. Tests: +6 (test_mcp_span_classified_as_client, mcp client-kind fallback, non-mcp client negative, _safe_dumps truncation, apply->revert->apply round-trip, _unwrap_to_function). 29 passed.
- P0: react_step_patch wrappers now return coroutines from sync wrappers so MAF's await layer.get_response no longer raises TypeError. ContextVar tokens are set inside the coroutine body so set/reset share the same asyncio task context. - P1: extend op_name override condition to include CLIENT span kind so MCP tools/call inner spans get gen_ai.operation.name=mcp even when MAF pre-wrote execute_tool. - P3: provider.name normalization now handles sequence values (MAF emits list-wrapped values on AGENT spans) and falls back to case-insensitive matching so microsoft.agent_framework -> openai on AGENT spans. - P5: instrument() prepends MAFSemanticProcessor to the SDK processor tuple so on_end enrichments run before exporter processors registered earlier in bootstrap. Adds 7 unit tests; pytest tests/ -> 36 passed.
Add license header to all 11 files in the microsoft-agent-framework instrumentation package. Resolves the check-license-header CI failure.
5509517 to
3f63471
Compare
123liuziming
approved these changes
Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR supersedes and integrates:
The combined branch resolves the generated workflow / bootstrap registry hotspot once, then keeps the three feature surfaces in one reviewable PR:
loongsuite-instrumentation-microsoft-agent-frameworkwith semantic processor, ReAct step patching, util-genai bridge, tests, README, and changelog;bootstrap_registry/*fragments and update change detection / workflow generation tests;executor.process AgentExecutorspans to setgen_ai.provider.name=microsoft.agent_frameworkwhen reclassified asinvoke_agent/create_agent.Supersedes #208, #229, and #232.
Type of change
How Has This Been Tested?
Local validation:
tox -e generate-workflowstox -c tox-loongsuite.ini -e py311-test-detect-loongsuite-changestox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-microsoft-agent-frameworktox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-crewaitox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-agentscope-latest -- instrumentation-loongsuite/loongsuite-instrumentation-agentscope/tests/test_v2_instrumentation.pyPRE_COMMIT_HOME="$(mktemp -d)" tox -e precommitgit diff --checkReal runtime / telemetry validation:
agent-framework-core 1.10.0: realAgent,AgentSession,WorkflowBuilder,AgentExecutor, local deterministic tool, streaming, multi-turn, concurrency, and error flows against a DashScope OpenAI-compatible model. ARMS/CMS readback covered 8 representative traces.2.0.3: real v2Agent.reply,Agent.reply_stream,Toolkit,FunctionTool, multi-turn, concurrency, and error flows against a DashScope model. ARMS/CMS readback covered 6 representative traces.1.15.1+ LiteLLM1.90.2: multi-agent incident workflow, streaming crew, concurrent crews with OTel context propagation, deterministic tools, and error path. ARMS/CMS readback covered 4 representative traces.gen_ai.crewai.*.Validation Evidence
Spec and Scope
loongsuite-instrumentation-agentscope,loongsuite-instrumentation-microsoft-agent-framework,loongsuite-instrumentation-crewai,loongsuite-distrobootstrap registry generation, LoongSuite workflow generation.Local Checks
python "$PIPELINE_SKILL_DIR/scripts/check_loongsuite_pr_readiness.py" --repo . --base origin/mainOK: LoongSuite static PR readiness checks passedpython "$PIPELINE_SKILL_DIR/scripts/plan_review_matrix.py" --repo . --format markdownPRE_COMMIT_HOME="$(mktemp -d)" tox -e precommitgit diff --checktox -e generate-workflowstox -c tox-loongsuite.ini -e py311-test-detect-loongsuite-changes45 passedtox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-microsoft-agent-framework58 passedtox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-crewai48 passedtox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-agentscope-latest -- instrumentation-loongsuite/loongsuite-instrumentation-agentscope/tests/test_v2_instrumentation.py13 passedorigin/mainReal E2E Matrix
LLM/AGENTtrees exported and read back from ARMS/CMSreply_stream, CrewAI streaming workflowAgentExecutorworkflow, AgentScope v2Toolkit/FunctionTool, CrewAI multi-agent workflowAGENT/STEP/TOOL/LLMparent-child trees observedTelemetry and Weaver
ENTRY/WORKFLOW/AGENT/STEP/TOOL/LLMshapes where applicablegen_ai.provider.name=microsoft.agent_frameworkweaver registry live-check ... --advice-profile loongsuite-genai ...gen_ai.crewai.*CI
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.