Skip to content

design(adapters): IOContract.build_prompt is unimplemented and uncalled everywhere — decide whether to finish it or remove it #1644

Open

Description

@planetf1

Problem

Epic #929 migrated several capabilities onto IOContract (rag.py, guardian.py, requirement_check — Phase 1, #1136–#1139, #1332), but only the output side of the contract actually got wired through. parse() is called from real code:

# mellea/stdlib/components/intrinsic/_util.py:252
return adapter.io_contract.parse(result_str)

and its own follow-up issue (#1516) formalised that path properly.

build_prompt() never got the matching treatment. It's abstract on IOContract (_core.py:141), and every concrete subclass either raises NotImplementedError (_DictContract/_ListContract) or is a placeholder that says outright it isn't used:

# mellea/backends/huggingface.py:3234, on _UnusedIOContract
def build_prompt(self, **kwargs: object) -> Component:
    raise NotImplementedError(
        "not used on the intrinsic generation path: "
        "_generate_from_intrinsic builds prompts via IntrinsicsRewriter."
    )

A repo-wide search for .build_prompt( finds zero call sites — not just for intrinsics, for any capability. So the epic went half-way: the output side got unified, the input side didn't, and nothing ever decided whether it should be.

Why this matters now

Three independent pieces of adapter work have each run into this and each deliberately routed around it rather than resolve it:

Three in a row correctly declining to touch it means the gap itself needs a decision, not another workaround.

Ask

Decide one of:

  1. Finish it. File the input-side equivalent of refactor(intrinsics): resolve the adapter's output contract from the adapter, not a parallel argument (Epic #929 Phase 2) #1516: _generate_from_intrinsic (and the other generation paths) would call adapter.io_contract.build_prompt(**kwargs) instead of instantiating IntrinsicsRewriter directly, and every IOContract subclass gets a real implementation instead of a stub or a raise.
  2. Remove it. Drop build_prompt from the IOContract abstract interface and document that prompt construction is intentionally out of scope for it — IOContract becomes an output-parsing contract only, closing the asymmetry the other way.

No urgency — not blocking #993 or #1633. Filed so the gap is tracked rather than rediscovered by the next person who bumps into it.

Activity

  1. added
    p2
    needs-design
    area/backends
    area/adapter-functions
    on Oct 5, 2026
  2. planetf1 commented on Oct 20, 2026

    @planetf1
    ContributorAuthor

    Came back to this to frame the actual decision.

    Facts first: build_prompt has no callers. The tests only stub it because the ABC
    makes them, and all our prompt building goes through IntrinsicsRewriter instead
    (#1486, #1633, #993, #1654). But it's public API (IOContract is in __all__), and
    the output half of the contract, parse, is real and used everywhere. The input half
    is the piece that never happened.

    So the design question: does prompt construction belong in the adapter's I/O contract,
    or in the generation machinery? Deleting the method settles it as "the rewriter owns
    it"; building it out settles it as "the contract owns it", at the cost of becoming its
    first real caller.

    Keeping this under needs-design. The facts above are recorded so the decision has
    something concrete to work from.

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

    area/adapter-functionsarea/backendsneeds-designp2refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions