feat(server): introduce ServeConfig dataclass to consolidate serve() kwargs#437
Draft
feat(server): introduce ServeConfig dataclass to consolidate serve() kwargs#437
Conversation
…kwargs Issue #414 — the 22-arg serve() signature is noisy, hard to read, and IDE autocomplete is unwieldy. Groups all kwargs into a frozen dataclass with sensible defaults while keeping full backwards compatibility. Closes #414 https://claude.ai/code/session_016DD1aTKm7E12tgrceKdz1M
- stacklevel=3 → stacklevel=4 in __post_init__ (warning was pointing at the synthesized __init__ frame rather than the caller site) - Remove conditional `if mock_mcp.call_count:` guards in tests — assertions are now unconditional so vacuous passes are impossible - Add config= mention to decisioning.serve() **serve_kwargs docstring so Copilot/Cursor see the param when generating decisioning calls https://claude.ai/code/session_016DD1aTKm7E12tgrceKdz1M
4 tasks
Empirically verified: stacklevel=3 points warnings.warn at the ServeConfig(...) call site; stacklevel=4 overshoots to sys. Previous fix commit based on DX-expert analysis was incorrect. Also removes dead _patch_serve_internals helper from tests. https://claude.ai/code/session_016DD1aTKm7E12tgrceKdz1M
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.
Closes #414
Summary
@dataclass(frozen=True) ServeConfigtosrc/adcp/server/serve.py, grouping all 22serve()keyword arguments into a single named, IDE-friendly object with the same defaultsserve()gainsconfig: ServeConfig | None = None; when supplied, config fields win and individual kwargs are ignored (backwards-compatible — existing call sites work unchanged)__post_init__emitsUserWarningon cross-transport field combinations (A2A-only fields set alongside MCP transport and vice versa);stacklevel=3empirically verified to point at theServeConfig(...)call siteSequencemoved fromTYPE_CHECKINGto runtime imports (fixesget_type_hintscompatibility)adcp.serverand added to__all__examples/typed_handler_demo.pyupdated to demonstrate the new patternsrc/adcp/decisioning/serve.pydocstring updated to surfaceconfig=in**serve_kwargsfor agent discoverabilitytests/test_serve_config.py; all 3200 existing tests passWhat tested
ruff check— cleanmypy src/adcp/server/— no new errors (all pre-existing from optional deps not installed locally)pytest tests/test_serve_config.py— 12/12 passedpytest tests/(excluding pre-existing network flaketest_real_tls_handshake_still_validates_hostname) — 3200 passed, 0 new failuresPre-PR review
if call_count:guards; dead helper removed;stacklevel=3confirmed correct via empirical test (stacklevel=4overshoots tosys)config=added todecisioning.serve()**serve_kwargsdocstring for agent discoverability; note: DX expert'sstacklevel=3→4recommendation was empirically incorrect and revertedKnown nit (not fixed):
SkillMiddlewareandContextFactoryare defined afterServeConfigin the file. Underfrom __future__ import annotations(PEP 563) this is safe at runtime since the full module loads before any caller runs. Reorganising the ~400-lineSkillMiddlewaredocstring block is out of scope for this PR.Session: https://claude.ai/code/session_016DD1aTKm7E12tgrceKdz1M