Skip to content

audit follow-up: fleet model-family detection in shared protocols/openai-chat.ts alters official providers — relocate to gateway-door compatibility config #1824

Closed

Description

@dezren39

Audit follow-up — fleet edits inside the shared protocol of official providers

Source: 2026-11-06 provider audit (Audit A: official provider files). Every official provider file is clean — no fleet-authored changes in providers/openai.ts, mistral.ts, deepseek.ts, groq.ts, openrouter.ts, meta.ts, openai-compatible.ts. The one material breach of the "don't edit official providers" doctrine is one layer down, in the shared protocol those providers lower through.

The finding: packages/ai/src/protocols/openai-chat.ts

Two fleet commits change wire behavior for every consumer of the OpenAI Chat protocol — official openai, deepseek, groq, openrouter, meta (chat), and the fork openai-compatible (which effectively serves the opendesign / cline-pass / opencode-go.* doors after the native-rewrite layer):

Stated motivation is the fleet's multi-family gateway doors. But the detection also fires on direct official-provider traffic with matching model ids, and it will conflict on every upstream sync.

Fix shape

The protocol already honors explicit per-model compatibility overrides after detection ("Explicit compatibility overrides are applied after detection and always win" — the commit's own comment). Move the gateway family defaults to where they belong:

  • per-model compatibility entries on the gateway doors (cline-pass, opendesign, opencode-go catalog entries in opencode.jsonc / models.dev overlay), or
  • a fleet-owned wrapper around the compatible provider for those doors.

Then revert the detection commits' behavior changes from the shared protocol (keeping any purely additive, behavior-neutral helpers if upstream-shaped).

Secondary shared-file fleet edits (lower severity — same principle, tracked here)

These guards are close to behavior-preserving, but they are still fleet edits in upstream files and will surface as sync conflicts; each should either move to a fleet-owned location or be proposed upstream.

Acceptance criteria

  • Fleet model-family detection no longer lives in the shared packages/ai/src/protocols/openai-chat.ts protocol layer, OR a written decision on this issue records why the protocol layer is the accepted home.
  • Official providers' wire behavior is unchanged for non-fleet model IDs (existing protocol tests pass; any behavior delta is enumerated on this issue).
  • The gateway-door compatibility configuration carries the family detection for the fleet doors that need it (opendesign / cline-pass / opencode-go).

Activity

  1. dezren39 commented on Nov 6, 2026

    @dezren39
    Author

    🤖 Triage evidence · issue-sweep-rotating (Make feeder)

    • Checked: this issue against current main 22c0a6ddbee19878e8e51bde432e995f75ccdd2a (verified x2 via gh api), reading packages/ai/src/protocols/openai-chat.ts raw via gh api contents.
    • Gap CONFIRMED still present: fleet model-family detection still lives in the shared protocol every OpenAI-Chat consumer lowers through:
      • openai-chat.ts:698 — detectModelFamily(modelID) (glm/kimi/gemini/deepseek families by model-ID segment)
      • openai-chat.ts:714-719 — detectMaxTokensField threads modelID into family detection
      • openai-chat.ts:751-756 — detectSupportsStore returns false whenever a family is detected
      • openai-chat.ts:803 / :824 — kimi strict-mode and glm tool-stream behavior keyed off the detected family
      • openai-chat.ts:871-873 — detection results are consumed at request build; explicit compatibility overrides are applied after detection, so plain official-provider traffic (openai, deepseek, groq, openrouter, meta) with a matching model id still gets fleet gateway behavior with no explicit config.
    • What "done" looks like: the gateway family defaults live on the gateway doors themselves (per-model compatibility entries for cline-pass / opendesign / opencode-go catalog entries, or a fleet-owned wrapper around the compatible provider); the shared protocol's detection-driven behavior changes are reverted (behavior-neutral additive helpers may stay if upstream-shaped); a test pins that an official provider with a glm/kimi/deepseek-shaped model id and no explicit compatibility gets upstream-default wire fields.
    • Next: enqueuing a repo-task/v1 triage packet into repo-health-opencode-pilot from this feeder run; the queue lane owns the fix work.
  2. dezren39 commented on Nov 6, 2026

    @dezren39
    Author

    🤖 Agent note · queued by triage feeder

    • Agent: issue sweep (issue-sweep-rotating, Make feeder)
    • Session / ID: issue-sweep-rotating run 2026-11-06 04:24 CST
    • Found via: feeder rotation (prev rotating line dezren39/darwin-nix 2026-11-06T09:27Z -> developing-today-forks/opencode)
    • Task: Enqueued repo-task/v1 triage packet as task 10988 in queue repo-health-opencode-pilot (kind triage, priority 50, dedupe repo-health:v1:triage:developing-today/opencode:issue:1824). Packet: hidden_files/packet-opencode-1824.json.
    • Evidence: feeder triage comment audit follow-up: fleet model-family detection in shared protocols/openai-chat.ts alters official providers — relocate to gateway-door compatibility config #1824 (comment) — gap CONFIRMED on main 22c0a6ddbee1 (verified x2): detectModelFamily at protocols/openai-chat.ts:698, threaded at :714-719 / :751-756, consumed at :871-873 with compatibility overrides applied only after detection.
  3. added
    kind/refactorCode restructuring with no behavior change
    source/humanFiled directly by a human
    priority/normalOrdinary priority (the default)
    effort/mMedium: expected under 1 day of work
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Nov 6, 2026
  4. dezren39 commented on Nov 6, 2026

    @dezren39
    Author

    Intake review

    🤖 Fleet monitor intake (repo-fleet-monitor), 2026-11-06.

  5. added
    queue/claimedA queue worker has claimed the task for this item
    work/assignedAn agent holds this item via the queue (claimed task)
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 6, 2026
  6. dezren39 commented on Nov 6, 2026

    @dezren39
    Author

    Triage complete — queue task 10988 (lane opencode-a), all reads fresh on origin/main 22c0a6d.

    Confirmed: the full detection-driven behavior set in protocols/openai-chat.ts

    detectModelFamily (:698) classifies glm/kimi/gemini/deepseek by anchored id-segment regexes (commits 46c691e #1706, 94ec419 #1737 — both verified). It drives exactly four behaviors, all consumed in fromRequest as request.model.compatibility?.X ?? detectX(...):

    1. detectMaxTokensField — family glm/kimi/deepseek → max_tokens, overriding the provider/baseURL heuristic for any consumer.
    2. detectSupportsStore — any detected family → store unsupported (false), whatever the gateway/provider.
    3. detectSupportsStrictMode — kimi → strict mode off.
    4. detectZaiToolStream — glm → tool_stream: true (minus the glm-4.5 exclusions), behind any provider.

    Consumers of the shared protocol include official openai, deepseek, groq, openrouter, meta and many more (azure, cerebras, cohere, deepinfra, fireworks, …), plus the fleet's openai-compatible doors. So family-shaped model ids on official-provider traffic with no explicit compatibility get gateway behavior today — the issue's finding is confirmed as filed. Where the provider heuristic already agrees (direct deepseek/zai/moonshot), detection is redundant and removing it changes nothing.

    Relocation decision: per-model compatibility on the gateway doors

    Every family effect is expressible through the protocol's own sanctioned channel: maxTokensField, supportsStore, supportsStrictMode, zaiToolStream are all compatibility keys, and explicit compatibility already wins over detection at consumption. Decision: relocate to per-model compatibility entries for the door models that relied on detection (the glm/kimi/gemini/deepseek-shaped ids served through the cline-pass / opendesign / opencode-go doors, carried in the fork's catalog/config layer — models.dev overlay / door provider config), then remove the family detection from the shared protocol. A fleet-owned wrapper around the compatible provider was considered and rejected: it duplicates routing for three doors to deliver values the existing compatibility channel already carries, and leaves two behavior paths to keep in sync. The provider/baseURL heuristics in the detect* functions stay — they are upstream-shaped and predate the family commits.

    Secondary shared-file edits — disposition: propose upstream, keep in place meanwhile

    Verified present: f64bbc1 (open-responses own-property guard, #908/#910), c523a00 (responses-hosted-tools prototype guard, #927/#928), 715c29a (anthropic-messages pass-through, #1146), 5315572 (anthropic-messages own-keys gate, #856), bd60fed (tool-schema prefixItems, #1574), 42b9794 (gemini-json-schema $ref cycle cut, #1585). Each is a small, behavior-preserving correctness guard in upstream shape. Moving them into fleet-owned wrappers would duplicate protocol logic for zero behavior gain; the honest disposition is propose upstream (they are exactly the kind of fix upstream takes), keeping them in place until upstream accepts or rejects. They are not part of the fix task below; if Drew wants upstream PRs filed, that is separate work. The #1146 pass-through is the largest of the set and the only one that is a feature rather than a guard — same disposition, noted explicitly.

    Fix routed

    Fix packet enqueued (repo-health-opencode-pilot): remove family detection from openai-chat.ts + add the door compatibility entries + a pinning test (official provider, family-shaped model id, no explicit compatibility → upstream-default wire fields: max_completion_tokens, store honored, strict allowed, no tool_stream).

  7. 3 remaining items

  8. added
    work/assignedAn agent holds this item via the queue (claimed task)
    queue/claimedA queue worker has claimed the task for this item
    and removed on Nov 6, 2026
  9. dezren39 commented on Nov 6, 2026

    @dezren39
    Author

    agent-note:v1 — state: PR #1840 open, task 11000 parked for review. detectModelFamily removed from shared openai-chat protocol; family defaults now explicit per-model compatibility entries on cline-pass/opendesign/opencode-go doors in models-dev.ts (+ schema keys supportsStore/supportsStrictMode/zaiToolStream). Tests on laptop after merging origin/main: ai openai-chat 80 pass, core models 20 pass, ai+core typecheck clean. Resume: disposition Codex findings on #1840, merge if sound.

  10. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedA queue worker has claimed the task for this item
    on Nov 6, 2026
  11. added a commit that references this issue on Nov 6, 2026
  12. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedAn agent holds this item via the queue (claimed task)
    on Nov 6, 2026
  13. dezren39 commented on Nov 6, 2026

    @dezren39
    Author

    agent-note:v1 — state: completed via PR #1840 merged 2026-11-06; task 11000 complete. No Codex findings on #1840. Tests re-run on the verified PR head (629bb0b): ai openai-chat 80 pass, core models 20 pass, ai+core typecheck clean.

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

    effort/mMedium: expected under 1 day of workkind/refactorCode restructuring with no behavior changemeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/humanFiled directly by a human

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions