Skip to content

Ship the provider adapters out of the box (opt-in module) #362

Closed

Description

@jerm-dro

Problem

engine/ ships port.LLMProvider and mockllm. The real adapters live in the root module's internal/adapter/, unimportable — so anyone embedding the engine has to write their own before they have a working loop. That means re-deriving wire-format details that have exactly one correct answer, with no test to tell them when they get it wrong.

Prompt caching is the sharpest example. Anthropic caches by prefix match, so breakpoint placement decides what gets re-billed each turn. Place them wrong and every turn of an agentic loop reprocesses the whole accumulated transcript at full input price — quadratic cost growth on precisely the long tool-calling sessions this engine exists to run. Nothing fails. The loop works perfectly. You find out from a bill.

That's the shape of the whole problem: message ordering rules, stream assembly, usage accounting, cache breakpoints. None of it involves consumer-specific judgment, all of it is derivable from the request shape, and getting it wrong is silent. Reinventing that per consumer is pure downside.

Why the earlier "no" doesn't hold

#269 carved the provider adapters out: heavy SDK dependencies shouldn't be forced onto every engine importer. Right — but that argues against the engine module, not against shipping them at all. mecatl is already multi-module; a third (mecatl/provider/anthropic) makes the dependency opt-in by import. Nobody who doesn't want it pays for it.

What consumers keep

Credentials, custom auth, thinking on/off, model choice — real policy, already served by the existing Options pattern. Wire-format correctness comes from the library. Same opt-in contract as #269: import it, wrap it, or ignore it and implement the port yourself.

Metadata

Metadata

Assignees

Labels

atrium-convergenceenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions