[AAASM-4547] 🐛 (python-sdk): Register targets gRPC endpoint + loud unregistered warning - #250
Conversation
Registration is the SDK's only direct gateway gRPC call and must target the gateway's gRPC port (:50051), not the REST gateway_url (:7391). Add a resolver that derives the gRPC endpoint from AA_GATEWAY_ENDPOINT, else the resolved REST host with the gRPC port substituted, else the loopback default. Refs AAASM-4547 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rk7iwwAuGv6HbwK8hY8Fbr
Agent registration is the SDK's one direct gateway gRPC call and must reach the gateway's gRPC port (:50051). init_assembly now resolves that endpoint from the gateway host (via resolve_gateway_grpc_endpoint) and threads it into the native register instead of leaving it unset — so a non-loopback gateway host registers against that host's gRPC port rather than always 127.0.0.1, and the REST gateway_url (:7391) is never dialed for registration. Refs AAASM-4547 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rk7iwwAuGv6HbwK8hY8Fbr
… gap connect_runtime_client returning None (native _core absent on a pure-Python install) or a register failure was previously swallowed silently, so init returned a clean-looking context for an agent that never reached the gateway and will never appear in the dashboard. Emit a loud stderr warning (mirroring the Node SDK's warnAgentUnregistered) and surface a `registered` flag on the AssemblyContext so callers can detect the gap programmatically. Init still proceeds (proxy / eBPF stay authoritative); enforce still fails init closed on a register error. Refs AAASM-4547 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rk7iwwAuGv6HbwK8hY8Fbr
Cover resolve_gateway_grpc_endpoint (env override, REST->gRPC port swap, non-loopback host preserved, loopback default) and the loud unregistered path: native absent, native-present-no-client, and register-failure-under-observe all warn to stderr and set ctx.registered False; a successful register sets it True. Refs AAASM-4547 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rk7iwwAuGv6HbwK8hY8Fbr
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Review — AAASM-4547 (python-sdk portion) · Claude CodeReviewed against the 4-point checklist. Verdict: APPROVE for the python scope (not merging/approving — human sign-off required). 1. CI — GREENAll 26 check runs pass or are skipped; no RED. 2. Scope vs ticket — delivers the python interim AC
This satisfies the ticket's minimum python AC bullet — "Python's silent 3. Side effects — none
4. Front-end — N/A
APPROVE (advisory — not merging/approving per review mandate). 🤖 Generated with Claude Code |



Description
Fixes the Python SDK portion of AAASM-4547 (cross-repo bug; node = AAASM-4468, go = docs). Two scoped changes to the agent-registration path:
Registration targets the gateway gRPC endpoint (:50051), not the REST URL (:7391). Agent registration is the SDK's one direct gateway gRPC call (
AgentLifecycleService.Registerviaaa-sdk-client, ADR 0004), which must reach the gateway's gRPC port — distinct from the RESTgateway_url. A newresolve_gateway_grpc_endpoint()derives it fromAA_GATEWAY_ENDPOINT→ the resolved REST host with the gRPC port substituted → the loopback default, andinit_assemblythreads it intoregister. Previously the endpoint was left unset (native default127.0.0.1:50051), so a non-loopback gateway host would never register against the right host.Loud unregistered warning +
registeredflag instead of a silentNonefallback. When registration cannot run — nativeagent_assembly._coreabsent (pure-Python / unsupported-platform install) or the gateway gRPC endpoint unreachable/rejecting — the SDK previously returned a clean-looking context for an agent that never reached the gateway. It now emits a prominentsys.stderrwarning (mirroring the Node SDK'swarnAgentUnregistered, citing AAASM-4547) and surfacesctx.registeredso callers can detect the gap programmatically. Init still proceeds (proxy / eBPF stay authoritative);enforcestill fails init closed on a register error.Type of Change
Breaking Changes
AssemblyContextgains aregistered: boolfield (defaultsTrue) — additive.Related Issues
Testing
resolve_gateway_grpc_endpointunit tests (env override, REST→gRPC port swap, non-loopback host preserved, loopback default); loud-warn path tests (native absent, native-present-no-client, register-failure-under-observe all warn + setregistered=False; successful register setsregistered=True). Existing register-wiring tests updated to expect the derived endpoint. Full suite: 790 passed, 16 skipped.ruff check/ruff format/mypyclean on changed files.Live check: booted
aa-gatewayon127.0.0.1:50051and raninit_assembly(gateway_url="http://127.0.0.1:7391")with the native_corepresent. Registration correctly dialed the derived:50051endpoint (the gRPC service responded with an application-level rejection — proving connectivity to the right port, vs the "unreachable" error when nothing listens), and the loud warning +ctx.registered=Falsefired end-to-end. The full "agent appears inGET /api/v1/agents" assertion could not be completed in-env:aa-api-server(REST :7391) is not built locally, and the only availableaa-gatewaybinary (Jun-25) rejects the newer_coreregistration handshake (version skew) — both environmental, not defects in this change.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01Rk7iwwAuGv6HbwK8hY8Fbr