Skip to content

feat(adapter): arc 1 — typed protocol descriptors on AdapterCapabilities - #1543

Merged
joelteply merged 1 commit into
canaryfrom
42bd9367/adapter-capabilities
Jun 7, 2026
Merged

joelteply merged 1 commit into
canaryfrom
42bd9367/adapter-capabilities

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

feat(adapter): arc 1 — typed protocol descriptors on AdapterCapabilities (card 42bd9367)

The bool-flag AdapterCapabilities (supports_tool_use, supports_vision, etc.)
was unsigned about HOW each capability is provided — fine for "is the
feature available" questions, useless for "which protocol does cognition
need to speak." Arc 1 of the substrate plan addresses this directly.

This commit adds three typed descriptors alongside the existing bool
flags (kept for back-compat; new selectors should consult the typed
fields):

  • tool_call_protocol: ToolCallProtocol — enumerates HOW the adapter
    accepts tool calls. None / JsonInPrompt / JsonMode /
    NativeFunctionCalling / XmlTags. Cognition's tool loop routes through
    this without special-casing per adapter name.

  • structured_output_protocol: StructuredOutputProtocol — None /
    JsonSchema / GrammarConstrained (llama.cpp GBNF) / PromptOnly. Lets
    cognition pick the right enforcement strategy per workload per adapter.

  • modalities: ModalitySet — typed text_in/text_out/vision_in/audio_in/
    audio_out booleans declaring what the adapter handles NATIVELY.
    Modalities NOT in the set get bridged by the substrate
    (VisionDescriptionService, STT, TTS) before the adapter sees the
    request. LCD personas get sensory parity via bridges per the
    [[ai-namespace-multimodal-crutches]] doctrine.

  • max_output_tokens: u32 — distinct from max_context_window; bounds
    the compose phase.

Each existing adapter declares truthfully:

  • HeuristicAdapter — TEXT_ONLY, no tool protocol, no structured
    output. Substrate doesn't try to use it for what it can't do.
  • OpenAI-compatible (OpenAI/DeepSeek/Together/Fireworks/Groq/xAI/
    Mistral) — NativeFunctionCalling + JsonSchema when supports_tools.
    Vision-in native when supports_vision.
  • Anthropic — NativeFunctionCalling (tool_use blocks) +
    JsonSchema. Vision-in native.
  • LlamaCpp — JsonInPrompt (prompt-driven tool emulation) +
    GrammarConstrained (GBNF). Vision-in handled by mmproj adapter
    separately.
  • AircRemoteAdapter — defers to None / TEXT_ONLY until a
    capability-discovery handshake card lands (future work).

Per [[adapter-pattern-is-the-pivot-insurance]]: every ML-touching
capability sits behind this trait so the substrate pivots (swap
framework, swap model, swap provider) by declaration, not rewrite.
Arc 2 (#122 LoRA paging) and arc 3 (teacher routing) build on this.

Tests: 48/48 ai:: tests pass; no behavior changes (existing capability
queries continue to work via bool flags; new typed fields are purely
additive).

Co-Authored-By: Claude Opus 4.7 [email protected]

…ies (card 42bd9367)

The bool-flag `AdapterCapabilities` (supports_tool_use, supports_vision, etc.)
was unsigned about HOW each capability is provided — fine for "is the
feature available" questions, useless for "which protocol does cognition
need to speak." Arc 1 of the substrate plan addresses this directly.

This commit adds three typed descriptors alongside the existing bool
flags (kept for back-compat; new selectors should consult the typed
fields):

- `tool_call_protocol: ToolCallProtocol` — enumerates HOW the adapter
  accepts tool calls. None / JsonInPrompt / JsonMode /
  NativeFunctionCalling / XmlTags. Cognition's tool loop routes through
  this without special-casing per adapter name.

- `structured_output_protocol: StructuredOutputProtocol` — None /
  JsonSchema / GrammarConstrained (llama.cpp GBNF) / PromptOnly. Lets
  cognition pick the right enforcement strategy per workload per adapter.

- `modalities: ModalitySet` — typed text_in/text_out/vision_in/audio_in/
  audio_out booleans declaring what the adapter handles NATIVELY.
  Modalities NOT in the set get bridged by the substrate
  (VisionDescriptionService, STT, TTS) before the adapter sees the
  request. LCD personas get sensory parity via bridges per the
  [[ai-namespace-multimodal-crutches]] doctrine.

- `max_output_tokens: u32` — distinct from `max_context_window`; bounds
  the compose phase.

Each existing adapter declares truthfully:

- **HeuristicAdapter** — TEXT_ONLY, no tool protocol, no structured
  output. Substrate doesn't try to use it for what it can't do.
- **OpenAI-compatible** (OpenAI/DeepSeek/Together/Fireworks/Groq/xAI/
  Mistral) — NativeFunctionCalling + JsonSchema when supports_tools.
  Vision-in native when supports_vision.
- **Anthropic** — NativeFunctionCalling (tool_use blocks) +
  JsonSchema. Vision-in native.
- **LlamaCpp** — JsonInPrompt (prompt-driven tool emulation) +
  GrammarConstrained (GBNF). Vision-in handled by mmproj adapter
  separately.
- **AircRemoteAdapter** — defers to None / TEXT_ONLY until a
  capability-discovery handshake card lands (future work).

Per [[adapter-pattern-is-the-pivot-insurance]]: every ML-touching
capability sits behind this trait so the substrate pivots (swap
framework, swap model, swap provider) by declaration, not rewrite.
Arc 2 (#122 LoRA paging) and arc 3 (teacher routing) build on this.

Tests: 48/48 ai:: tests pass; no behavior changes (existing capability
queries continue to work via bool flags; new typed fields are purely
additive).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@joelteply
joelteply merged commit 75b21d0 into canary Jun 7, 2026
3 checks passed
@joelteply
joelteply deleted the 42bd9367/adapter-capabilities branch June 7, 2026 01:23
joelteply added a commit that referenced this pull request Oct 6, 2026
…; history is never replayed down a stream (#1543) (#4817)

InboxRequest gained before (the backward page); the core's two forward
inbox reads pass None.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant