Skip to content

feat(instrument): Port AutoGen framework adapter (M2)#101

Closed
mmercuri wants to merge 2 commits into
feat/instrument-base-foundationfrom
feat/instrument-frameworks-autogen
Closed

feat(instrument): Port AutoGen framework adapter (M2)#101
mmercuri wants to merge 2 commits into
feat/instrument-base-foundationfrom
feat/instrument-frameworks-autogen

Conversation

@mmercuri

Copy link
Copy Markdown
Contributor

Summary

M2 fan-out PR: ports the AutoGen framework adapter from the ateam
reference implementation onto the new layerlens.instrument base
layer. Replaces the AutoGen slice of the larger orchestration bundle
(PR #96) with a self-contained, per-adapter unit suitable for
focused review.

  • Source: A:/github/layerlens/ateam/stratix/sdk/python/adapters/autogen/
    (~1,213 LOC, 6 files)
  • Template: src/layerlens/instrument/adapters/frameworks/langchain/
  • Stacks on: PR instrument: base foundation (M1.A port) #93 (feat/instrument-base-foundation) — required for the
    BaseAdapter / CaptureConfig / EventSink surface this adapter consumes.

Scope

src/layerlens/instrument/adapters/frameworks/
  __init__.py                         # adapter package docstring (autogen-only listing)
  autogen/
    __init__.py                       # public surface, ADAPTER_CLASS, instrument_agents
    lifecycle.py                      # AutoGenAdapter (BaseAdapter subclass)
    wrappers.py                       # traced send / receive / generate_reply / execute_code
    groupchat.py                      # GroupChatTracer (multi-agent turn management)
    human_proxy.py                    # HumanProxyTracer (HITL classification)
    metadata.py                       # environment.config payload extractor
tests/instrument/adapters/frameworks/test_autogen.py   # 13 SDK-shape mocked tests
samples/instrument/autogen/main.py                     # runnable end-to-end demo (mocked LLM)
docs/adapters/frameworks/autogen.md                    # install / quick-start / events emitted
pyproject.toml                                         # autogen extra + ARG002/pyright relaxation

Adaptations from ateam source

  • stratix.*layerlens.* (BaseAdapter, CaptureConfig,
    PydanticCompat, MemoryEntry).
  • STRATIX docstrings/branding → LayerLens.
  • Monkey-patched private attributes (_stratix_tracer,
    _stratix_human_tracer, _stratix_original) gain _layerlens_*
    primary names with the _stratix_* aliases retained as deprecation
    shims for ateam-era consumers (removed in v2).
  • requires_pydantic set explicitly to V1_OR_V2 — the adapter does
    not import pydantic directly.
  • Sample rewritten to be runnable offline against an in-process
    EventSink and a duck-typed agent, since HttpEventSink ships in a
    later milestone.

Blast radius

  • Default pip install layerlens install set is unchanged. Verified
    by tests/instrument/test_default_install.py.
  • Importing layerlens.instrument does NOT pull in pyautogen.
    Verified by tests/instrument/test_lazy_imports.py::test_layerlens_import_does_not_pull_frameworks
    and ::test_instrument_import_does_not_pull_frameworks.
  • Pure additions — no public surface changes outside the new
    layerlens.instrument.adapters.frameworks.autogen namespace.

Test plan

  • uv run pytest tests/instrument/adapters/frameworks/test_autogen.py -x
    13 passed in 2.16s
  • uv run mypy --strict src/layerlens/instrument/adapters/frameworks/autogen
    Success: no issues found in 6 source files
  • uv run ruff check src/layerlens/instrument/adapters/frameworks/autogen tests/instrument/adapters/frameworks/test_autogen.py
    All checks passed!
  • Lazy-import + default-install guards still pass for the frameworks
    surface (test_layerlens_import_does_not_pull_frameworks +
    test_instrument_import_does_not_pull_frameworks +
    test_default_install)
  • python -m samples.instrument.autogen.main
    → runs end-to-end producing 15 events across 8 event types
  • Reviewer (m-peko) verifies wrap/unwrap parity with ateam source

Linear

LAY-3400 umbrella (M2 framework fan-out, AutoGen slice).

Port the AutoGen framework adapter from the ateam reference
implementation onto the new layerlens.instrument base layer. This is
the M2 fan-out per-adapter PR for AutoGen — replaces the AutoGen slice
of the larger orchestration bundle (PR #96) with a self-contained,
mergeable unit.

Source: A:/github/layerlens/ateam/stratix/sdk/python/adapters/autogen/
       (~1,213 LOC, 6 files)
Template: src/layerlens/instrument/adapters/frameworks/langchain/

Scope
-----
- src/layerlens/instrument/adapters/frameworks/autogen/
  - __init__.py        — public surface + ADAPTER_CLASS + instrument_agents
  - lifecycle.py       — AutoGenAdapter (BaseAdapter subclass)
  - wrappers.py        — traced send/receive/generate_reply/execute_code
  - groupchat.py       — GroupChatTracer (multi-agent turn management)
  - human_proxy.py     — HumanProxyTracer (HITL classification)
  - metadata.py        — environment.config payload extractor
- tests/instrument/adapters/frameworks/test_autogen.py
  — 13 SDK-shape mocked tests (no pyautogen install required)
- samples/instrument/autogen/main.py
  — runnable end-to-end demo with mocked LLM + duck-typed agent
- docs/adapters/frameworks/autogen.md
  — install, quick-start, events emitted, capture-config guide
- pyproject.toml
  - autogen = ["pyautogen>=0.2,<0.5; python_version >= '3.10'"]
  - ARG002 + pyright relaxation for monkey-patched framework code

Adaptations from ateam source
-----------------------------
- stratix.* imports → layerlens.* (BaseAdapter, CaptureConfig,
  PydanticCompat, MemoryEntry).
- STRATIX docstrings/branding → LayerLens.
- Monkey-patched private attributes (_stratix_tracer,
  _stratix_human_tracer, _stratix_original) gain _layerlens_*
  primary names with the _stratix_* aliases retained as deprecation
  shims for ateam-era consumers.
- requires_pydantic explicit (V1_OR_V2) — adapter does not import
  pydantic directly.

Acceptance
----------
- pytest tests/instrument/adapters/frameworks/test_autogen.py -x
  → 13 passed
- mypy --strict src/layerlens/instrument/adapters/frameworks/autogen
  → Success: no issues found in 6 source files
- ruff check src/layerlens/instrument/adapters/frameworks/autogen
  tests/instrument/adapters/frameworks/test_autogen.py
  → All checks passed
- Lazy-import + default-install guards still pass for the frameworks
  surface (test_layerlens_import_does_not_pull_frameworks +
  test_instrument_import_does_not_pull_frameworks +
  test_default_install).
- Sample runs end-to-end producing 15 events across 8 event types.

Stacks on
---------
feat/instrument-base-foundation (PR #93) — provides BaseAdapter,
CaptureConfig, EventSink, AdapterRegistry, PydanticCompat, vendored
event schemas. Cannot rebase off origin/main alone because the
adapter literally subclasses BaseAdapter; merging this requires #93
first.

Related
-------
- Replaces the AutoGen slice of PR #96 (orchestration bundle) for
  the per-adapter fan-out review.
- Sibling fan-out PRs ship LangChain, LangGraph, CrewAI, Agentforce,
  Langfuse separately.
…deferred)

AutoGenAdapter implements serialize_for_replay (returns a populated
ReplayableTrace with events + state snapshots + capture config), but
get_adapter_info().capabilities did not declare AdapterCapability.REPLAY.
The atlas-app catalog UI reads that list to surface replay support, so
customers were told they could not replay traces from AutoGen even
though the adapter supports it.

PR #119 (brand leak + capability declarations) wired REPLAY for the
adapters that lived on its branch; AutoGen was deferred because it
lives on its own source-port branch (PR #101). This closes that
deferral per CLAUDE.md item 5/11.

STREAMING is intentionally NOT declared. Per CLAUDE.md 'no fake claims',
a capability is only declared if the adapter actually implements it.
The AutoGen integration wraps send / receive / generate_reply /
execute_code as discrete method calls rather than streaming
entry-points — no per-chunk events flow through the adapter.

Tests: added test_declares_replay_capability regression asserting
REPLAY appears and STREAMING does NOT.

Verification:
* uv run --with pytest python -m pytest tests/instrument/adapters/frameworks/test_autogen.py -x
    -> 14 passed
@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