Skip to content

feat(instrument): Port Semantic Kernel framework adapter (M2)#102

Closed
mmercuri wants to merge 1 commit into
feat/instrument-base-foundationfrom
feat/instrument-frameworks-semantic-kernel
Closed

feat(instrument): Port Semantic Kernel framework adapter (M2)#102
mmercuri wants to merge 1 commit into
feat/instrument-base-foundationfrom
feat/instrument-frameworks-semantic-kernel

Conversation

@mmercuri

Copy link
Copy Markdown
Contributor

Summary

Ports the Microsoft Semantic Kernel framework adapter from the ateam
reference implementation onto the new layerlens.instrument base
layer. This is the M2 fan-out for Semantic Kernel — slicing it
out of the bundled M1.C agent-tier port (#97) so it can land
independently and be reviewed in isolation.

Source

  • ateam/stratix/sdk/python/adapters/semantic_kernel/ (~929 LOC, 4
    files):
    • __init__.py (16 LOC)
    • lifecycle.py (594 LOC) — SemanticKernelAdapter + StratixMemoryStore
    • filters.py (259 LOC) — three SK filter implementations
    • metadata.py (60 LOC) — plugin / kernel metadata extraction
  • Template: existing src/layerlens/instrument/adapters/frameworks/langchain/
    package layout, requires_pydantic guard, STRATIX* deprecation alias
    pattern.

Scope

  • src/layerlens/instrument/adapters/frameworks/semantic_kernel/
    per-framework package (__init__, lifecycle, filters,
    metadata).
  • src/layerlens/instrument/adapters/frameworks/__init__.py — lazy
    package marker; importing it does NOT pull in any framework SDK.
  • tests/instrument/adapters/frameworks/test_semantic_kernel.py — 12
    SDK-shape mock tests (no real semantic-kernel runtime needed).
  • samples/instrument/semantic_kernel/{main.py,README.md} — runnable,
    mocked-by-default sample.
  • docs/adapters/frameworks-semantic_kernel.md — adapter integration
    guide (events emitted, capture config, BYOK pointer).
  • pyproject.toml — adds semantic-kernel = ['semantic-kernel>=1.0,<2.0; python_version >= '3.10''] extra; ruff ARG002 ignore + pyright
    exclusions for frameworks/ (mypy --strict stays strict).

Naming + back-compat

  • stratix.* import paths → layerlens.* import paths.
  • Three filter classes renamed STRATIX*LayerLens*. The old
    STRATIXFunctionFilter / STRATIXAutoFunctionFilter /
    STRATIXPromptRenderFilter symbols remain importable as deprecation
    aliases for ateam users (slated for removal next major SDK release).
  • StratixMemoryStore class name preserved — it implements the SK
    memory store contract that users embed by name.

Base branch

The acceptance check (uv run pytest tests/instrument/adapters/frameworks/test_semantic_kernel.py -x)
imports from layerlens.instrument.adapters._base, which only exists
on feat/instrument-base-foundation (M1.A) — origin/main reverted
the instrument layer in #76 pending the M1 stack. This PR therefore
targets feat/instrument-base-foundation instead of main. It will
re-target to main once the M1.A foundation lands.

Blast radius

  • Default pip install layerlens install set is unchanged.
    semantic-kernel is gated behind its own optional extra and a
    python_version >= '3.10' marker.
  • No changes to existing public API surface beyond the new adapter
    package.
  • Importing layerlens.instrument still does NOT pull
    semantic_kernel or any other framework module
    (tests/instrument/test_lazy_imports.py still passes).

Test plan

  • uv run pytest tests/instrument/adapters/frameworks/test_semantic_kernel.py -x
    → 12 passed
  • uv run mypy --strict src/layerlens/instrument/adapters/frameworks/semantic_kernel
    → Success: no issues found in 4 source files
  • uv run ruff check src/layerlens/instrument/adapters/frameworks/semantic_kernel tests/instrument/adapters/frameworks/test_semantic_kernel.py
    → clean
  • uv run pytest tests/instrument/test_lazy_imports.py tests/instrument/test_default_install.py
    → 6 passed (lazy-import + default-install guards still hold)
  • uv run pytest tests/instrument/ → 62 passed, 1 skipped (no
    regressions vs. base-foundation)
  • Reviewer (m-peko) verifies filter wiring + back-compat alias
    shape

Sibling of

Ports the Microsoft Semantic Kernel adapter from the ateam reference
implementation onto the layerlens.instrument base layer. M2 fan-out:
slices the SK-specific adapter out of the bundled M1.C agent-tier port
(PR #97) so it can land independently.

Source: ateam/stratix/sdk/python/adapters/semantic_kernel/ (~929 LOC, 4
files). Template: existing langchain framework adapter package.

Surface
- src/layerlens/instrument/adapters/frameworks/semantic_kernel/
  - __init__.py, lifecycle.py, filters.py, metadata.py
- src/layerlens/instrument/adapters/frameworks/__init__.py (lazy)
- tests/instrument/adapters/frameworks/test_semantic_kernel.py
- samples/instrument/semantic_kernel/{main.py,README.md}
- docs/adapters/frameworks-semantic_kernel.md

Naming and back-compat
- stratix.* import paths -> layerlens.* import paths.
- STRATIXFunctionFilter / STRATIXAutoFunctionFilter /
  STRATIXPromptRenderFilter remain importable as deprecation aliases
  for ateam users; new code should use the LayerLens* names.
- StratixMemoryStore class name preserved (matches the SK memory store
  contract users embed by name).

Packaging
- pyproject.toml gains semantic-kernel = ['semantic-kernel>=1.0,<2.0;
  python_version >= "3.10"']. Default install set is unchanged.
- ruff per-file-ignores adds ARG002 for adapters/frameworks/ — the SK
  filter callbacks have signatures dictated by the upstream filter API.
- pyright executionEnvironments relaxes a few rules under
  src/layerlens/instrument/adapters/frameworks because the framework
  instrumentation relies on runtime attribute mutation that pyright
  cannot follow. mypy --strict stays strict.

Verification
- uv run pytest tests/instrument/adapters/frameworks/test_semantic_kernel.py -x
  -> 12 passed
- uv run mypy --strict src/layerlens/instrument/adapters/frameworks/semantic_kernel
  -> Success: no issues found in 4 source files
- uv run pytest tests/instrument/test_lazy_imports.py
  tests/instrument/test_default_install.py -> 6 passed (lazy-import +
  default-install guards still hold)
@mmercuri mmercuri requested a review from m-peko April 26, 2026 05:56
@m-peko m-peko closed this May 21, 2026
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.

2 participants