Skip to content

[AAASM-990] ✨ (adapters): Add edge emission hooks for LangGraph and OpenAI Agents#42

Merged
Chisanan232 merged 6 commits into
masterfrom
v0.0.1/AAASM-990/feat/edge_emission_hooks
May 10, 2026
Merged

[AAASM-990] ✨ (adapters): Add edge emission hooks for LangGraph and OpenAI Agents#42
Chisanan232 merged 6 commits into
masterfrom
v0.0.1/AAASM-990/feat/edge_emission_hooks

Conversation

@Chisanan232
Copy link
Copy Markdown
Contributor

Summary

  • GatewayClient.report_edge() — new sync method posting to POST /topology/edges with source/target agent IDs, edge type, and optional metadata JSON (REST endpoint landing in AAASM-995).
  • EdgeEmitter — fire-and-forget wrapper (agent_assembly/client/emitter.py) that dispatches report_edge() on a daemon thread so adapters are never blocked by network I/O.
  • LangGraph adapter_NODE_TRANSITION thread-local + _EDGE_EMITTER module global: after each node exits, the next node enter emits a messages edge (source = previous node name, target = current node name).
  • OpenAI Agents adapter — after each Handoff.__call__ completes, emits a delegates_to edge (source = process_agent_id, target = handoff agent_name/name).
  • 8 new unit tests covering both adapters: sequential 2-node graph, no predecessor for first node, 3-node chain, no-emitter guard, handoff edge, None emitter, None process_agent_id, name-attribute fallback.

Why

AAASM-990 AC requires Python SDK adapter emission hooks so the topology store records real node-to-node and delegation edges at runtime. The gateway-side ReportEdge gRPC RPC was merged in PR #254; this PR adds the Python SDK side.

How to verify

uv sync
.venv/bin/python -m pytest test/unit/adapters/langgraph/test_edge_emission.py \
                            test/unit/adapters/openai_agents/test_edge_emission.py -v
# All 8 tests pass
.venv/bin/python -m pytest test/unit/ -q
# 258 passed

Closes #AAASM-990

Posts to POST /topology/edges with source/target agent IDs, edge type,
and optional metadata JSON.

Closes #AAASM-990
Wraps GatewayClient.report_edge() in a daemon thread so callers are
never blocked by network I/O.
Stores the completed node name in threading.local after each node exit;
on the next node enter, fires a fire-and-forget Messages edge via
_EDGE_EMITTER if one is registered.  set_edge_emitter() and
LangGraphPatch.edge_emitter field expose the wiring point.
After each Handoff.__call__ completes, fire a delegates_to edge from
process_agent_id to the handoff target via _EDGE_EMITTER.
set_edge_emitter() and OpenAIAgentsPatch.edge_emitter expose the wiring
point.
…pters

Four tests for LangGraph messages edges (sequential 2-node, first-node
has no predecessor, 3-node chain, no-emitter guard).  Four tests for
OpenAI Agents delegates_to edges (basic handoff, None emitter, None
process_agent_id, name-attribute fallback).  Also applies ruff UP045
auto-fixes to gateway.py and emitter.py.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

❌ Patch coverage is 53.33333% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
agent_assembly/client/emitter.py 0.00% 16 Missing ⚠️
agent_assembly/client/gateway.py 16.66% 10 Missing ⚠️
agent_assembly/adapters/langgraph/patch.py 94.11% 1 Missing ⚠️
agent_assembly/adapters/openai_agents/patch.py 93.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

LangGraph: include transition_input_keys (state keys at node exit time)
in Messages edge metadata.
OpenAI Agents: include reason (from handoff tool_description/description)
in DelegatesTo edge metadata.
Tests updated to assert metadata fields are present and correct.
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
52.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Chisanan232 Chisanan232 merged commit dd8dd33 into master May 10, 2026
22 of 24 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-990/feat/edge_emission_hooks branch May 10, 2026 04:05
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.

1 participant