Skip to content

post_generate_fixes.py matches exact base-class lists and breaks when envelope composition changes #1680

Open

Description

@KonstantinMirin

adcontextprotocol/adcp#8547 fixes how task response schemas compose the envelope. core/protocol-envelope.json now composes core/version-envelope.json, and response schemas compose only protocol-envelope. Background: #1678.

As a result, the generated response classes change from class X(AdcpVersionEnvelope, ProtocolEnvelope): to class X(ProtocolEnvelope):. The version fields still arrive through ProtocolEnvelope.

scripts/post_generate_fixes.py patches generated code by matching exact class-signature strings. There are 29 hard-coded AdcpVersionEnvelope matches, for example lines 5430, 5934, 6331–6743 (the verify_brand_claim(s) passes) and 6902/6941. So:

  1. It crashes. The "Generate Python SDK" job on adcp#8547 fails with RuntimeError: ListCreativesResponse marker missing (line 6904).
  2. Once that's fixed, other passes skip silently. They also expect the old signatures, including the check_governance / report_plan_outcome status aliases (around line 6181) and the verify_brand_claim(s) passes. They won't raise; they'll just stop applying.

Fix:

  • Match generated classes by class name, not by the full base-class list.
  • Make every pass fail loudly when its target isn't found.

The check_governance / report_plan_outcome status aliases should also be reviewed against adcp#8553. From 3.1 on, status is the task status, and the domain value lives in verdict / outcome_state.

Activity

  1. KonstantinMirin commented on Oct 28, 2026

    @KonstantinMirin
    CollaboratorAuthor

    A second failure on adcontextprotocol/adcp#8547's current head (43c537b522), separate from the post_generate_fixes.py signatures. "Generate Python SDK" now fails earlier, in generation:

    $ref file not found: <workdir>/sdk/.typegen-*/.schema_temp/core/async_response_refs/core/context.json
    

    The generator copies the async response schemas into core/async_response_refs/ and then resolves their $refs relative to that copy. Since #8547 those schemas reference core schemas directly (/schemas/core/protocol-envelope.json, /schemas/core/task-submitted.json, /schemas/core/task-id.json, /schemas/core/context.json), so the copied tree has to keep resolving them from the schema root.

  2. KonstantinMirin commented on Oct 28, 2026

    @KonstantinMirin
    CollaboratorAuthor

    To be clear about where the problem lies: the schemas aren't wrong now. They were wrong before.

    The old task response schemas didn't compose the envelope consistently, closed some roots, and copied envelope fields by hand. Generated code built from them couldn't represent a conforming response, so the generators grew patches to compensate:

    • post-processors written for one specific schema (postProcessCompactTaskSubmittedEnvelope);
    • rewrites keyed on exact class signatures (post_generate_fixes.py, 29 of them);
    • a copied side tree for the async schemas, with its own $ref resolution;
    • stripping or relaxing fields at runtime.

    adcontextprotocol/adcp#8547 fixes the schemas: plain allOf composition of protocol-envelope, one definition per envelope field (core/task-id.json, core/task-submitted.json, …), and open response roots. With that in place, these patches aren't needed. They fail because they're aimed at a schema layout that no longer exists.

    So the fix on the SDK side is to remove them, not to adapt them to the new layout. A generator that maps schema to classes directly through standard allOf, $ref and discriminated oneOf produces the right types from these schemas without them. Post-processing that works around a general generator limitation, the same way for every schema, is fine. Post-processing that has to know the structure of one particular schema is the sign of a problem in the schema, and that problem should be fixed in the schema.

  3. KonstantinMirin commented on Oct 30, 2026

    @KonstantinMirin
    CollaboratorAuthor

    #1705 fixed the class-signature matching, but "Generate Python SDK" on adcontextprotocol/adcp#8547 (38c5e7a6e9) still fails on the second issue in this thread:

    $ref file not found: <workdir>/sdk/.typegen-*/.schema_temp/core/async_response_refs/core/context.json
    

    The cause is the side tree in scripts/generate_types.py around line 783 (and consolidate_exports.py:231). The generator copies the async response schemas into core/async_response_refs/ and rewrites their relative $refs by hand. Since #8547, those schemas reference core schemas directly (protocol-envelope, task-submitted, task-working, task-input-required, task-id, task-message, context), and a reference rewritten relative to the copy resolves to core/async_response_refs/core/…, which doesn't exist. The readiness check on #1678 overlaid bundle-style refs, so it took a different path and didn't hit this.

    Same request as before: drop the copied side tree and resolve $refs from the schema root. The schemas use plain root-relative /schemas/... references and standard allOf, so the generator doesn't need to relocate or rewrite them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions