Skip to main content

Add a new chat provider adapter

Status: Ready

Article ID: 109

Truth label: Current

Audience: Brain contributor

Reader outcome: Normalize messages, controls, usage, and failure behavior.

Related articles: 022, 023, 024

Target week: 44

Last verified: 2026-09-13

Technical reviewer: Codex extension source audit

Editorial reviewer: Codex editorial audit

Implement the provider contract​

Map system, user, assistant, and tool messages into the provider format. Normalize streaming events, final response, model identity, usage, finish reason, and provider errors back into Brain's contract.

Declare control support​

Report which generation controls the provider accepts. Validate ranges and incompatible combinations before sending a request. Reject unsupported fields instead of silently pretending they influenced output.

Handle credentials and egress​

Load the provider credential from the approved runtime source. Document which prompt, repository, retrieval, and tool content can leave the host, plus the provider's approved model and retention policy.

Test real failure shapes​

Cover model discovery, non-stream and stream success, partial stream then error, authentication rejection, rate limit, timeout, malformed usage, tool call, and unsupported control. Use synthetic secrets in fixtures.

Current limits​

Adapter conformance does not make providers deterministic or interchangeable. Usage fields may differ, model lists change, and a trace does not prove which files a third-party CLI or tool read after launch.

Next lesson​

Continue with Test an architecture extension.

Derivative map​

  • Weekly package: WEEK-44
  • Long video: VIDEO-W44-LONG
  • Shorts: SHORT-W44-PROBLEM, SHORT-W44-MECHANISM, SHORT-W44-WARNING
  • Email: EMAIL-W44
  • LinkedIn: LI-W44-A, LI-W44-B
  • X: X-W44-A, X-W44-B
  • Visual: VISUAL-W44

Review record​

  • Message, stream, final, usage, model, and error normalization included.
  • Generation capabilities are declared and validated.
  • Credential, egress, failure, and synthetic-secret tests included.
  • Determinism, model-change, and trace limits remain explicit.

Review completed: 2026-08-27

Re-audited against the running product: 2026-09-13