Skip to content

feat(provider): V4 type crate aimux-provider (phase 1 unit 1.6) - #16

Open
cunninghamcard-bit wants to merge 13 commits into
exp/restartfrom
exp/u1.6-aimux-provider-v4
Open

cunninghamcard-bit wants to merge 13 commits into
exp/restartfrom
exp/u1.6-aimux-provider-v4

Conversation

@cunninghamcard-bit

@cunninghamcard-bit cunninghamcard-bit commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Phase 1 unit 1.6: design draft of the V4 layers in RFC-0042 §3.1 / arcships#200:58. This adds a new aimux-provider crate holding only the AI SDK @ai-sdk/provider@4.0.21 language-model/v4 and shared/v4 types. It is a workspace member; nothing depends on it and nothing is wired to it.

  • Dependencies: only serde and serde_json; no aimux crate (docs: full-chain AI SDK alignment design and impact map arcships/aimux#200 §2.1 constraint 1). cargo tree -p aimux-provider shows only those two, and cargo tree -i aimux-provider shows nothing depends on it. A test enforces this from the manifest.
  • Wire: AI SDK JSON — camelCase fields, kebab-case type/role/sourceType tags, absent optionals omitted, bytes as base64 text.
  • Layer rule:
    • prompt tool-call.input is parsed JSON (JsonValue);
    • output and stream tool-call.input is the provider's text (String);
    • stream text/reasoning deltas use delta;
    • no core invalid, error, retry or recording fields.
  • Types:
    • Prompt and messages: user, assistant and tool parts, plus tool-result outputs.
    • Call options: tools, tool choice, response format, reasoning, nullable headers.
    • Output: Content, Source, ToolCall/ToolResult, FinishReason, Usage, GenerateResult.
    • Streaming: StreamPart (all 21 variants) and the stream result info.
    • Shared: FileData, Warning, ProviderOptions/Metadata.
  • Not modelled: the LanguageModelV4 interface (doGenerate, doStream, supportedUrls) and abortSignal, which are behaviour rather than data.
  • Tests: cargo test -p aimux-provider — exact JSON round trips for every variant, rejection of unknown tags, and the no-aimux-dependency check.

Note: this branch is cut from exp/unit2-ci so that CI triggers, so the diff against exp/restart also includes unit 2's ci.yml change.

Errors (D21)

aimux_provider::ProviderError is one enum with one variant per class in @ai-sdk/provider@4.0.21 src/errors/. It implements std::error::Error and Display:

  • Display prints the upstream message, and the constructors fill in upstream's default messages;
  • cause is reachable through source();
  • name() returns the AI_* name;
  • is_retryable() is true only for ApiCall, whose default mirrors upstream (status 408/409/429/≥500, and an explicit value wins).

There is no serde and no wire format; mapping to aimux error codes and golden fixtures is deferred to 3.3.

variant upstream class (src/errors/…)
AiSdk AISDKError (ai-sdk-error.ts)
ApiCall APICallError (api-call-error.ts)
EmptyResponseBody EmptyResponseBodyError (empty-response-body-error.ts)
EvaluationUnsupportedQuestionType EvaluationUnsupportedQuestionTypeError (evaluation-unsupported-question-type-error.ts)
InvalidArgument InvalidArgumentError (invalid-argument-error.ts)
InvalidPrompt InvalidPromptError (invalid-prompt-error.ts)
InvalidResponseData InvalidResponseDataError (invalid-response-data-error.ts)
JsonParse JSONParseError (json-parse-error.ts)
LoadApiKey LoadAPIKeyError (load-api-key-error.ts)
LoadSetting LoadSettingError (load-setting-error.ts)
NoContentGenerated NoContentGeneratedError (no-content-generated-error.ts)
NoSuchModel NoSuchModelError (no-such-model-error.ts)
NoSuchProviderReference NoSuchProviderReferenceError (no-such-provider-reference-error.ts)
TooManyEmbeddingValuesForCall TooManyEmbeddingValuesForCallError (too-many-embedding-values-for-call-error.ts)
TypeValidation TypeValidationError (type-validation-error.ts, incl. TypeValidationContext)
UnsupportedFunctionality UnsupportedFunctionalityError (unsupported-functionality-error.ts)

get-error-message.ts is a helper, not a class; it is used for the cause text inside the messages. tests/errors_test.rs (7 tests) covers construction, Display text, is_retryable and the source chain.

cunninghamcard-bit added a commit that referenced this pull request Oct 11, 2026
…data; per-provider core-conversion tests

- Provider { dynamic, mark: ProviderExecutedMark::{Unmarked, Marked} }
  replaces the bool; documented as transitional until E.3b moves the
  provider side to #16's V4 tool-result type.
- Client { dynamic, provider_executed: Option<bool> }: plain data, no
  hidden 'input had false' marker. Test: absent / false client samples
  round-trip byte for byte.
- provider_executed_core_conversion_test: anthropic, google, vertex,
  openai responses, xai, huggingface each yield providerExecuted:true
  through generate_text and stream_text (cassettes / upstream-port bodies).
JSON and TS unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant