Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

You set a temperature, but the selected model does not support temperature. Should construction fail, silently ignore the setting, or return a usable client and explain what it could not apply? Matt Cockayne argues for the third option: build the best meaningful client available, return a detailed report of dropped optional settings, and fail only when a prerequisite makes a working client impossible.

Why one constructor error can be too blunt

A conventional Go constructor often returns a value and an error: (T, error). In that pattern, a non-nil error generally means callers should not use the returned value. Cockayne argues that this binary outcome can be a poor fit for a chat client assembled from independent choices such as provider, model, credentials, endpoint, timeout, sampling options, streaming, tools, and fallback behavior.

Some choices can be incompatible while the rest of the client remains useful. Rejecting the whole client may discard valid configuration; quietly dropping the incompatible choice may leave the caller unaware that the client will behave differently from what was requested. Cockayne’s proposal is an API design argument, not a universal Go convention: return the usable client along with a receipt describing what could not be configured.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Separate recoverable settings from fatal prerequisites

Unsupported optional settings can degrade the configuration

If a caller requests a temperature value for a model that does not support temperature, the client may still be able to perform its core task. Under the proposal, construction returns that client and reports that the temperature setting was not applied. This is a degradation only because the remaining client can still operate meaningfully.

Missing essentials should still stop construction

Some omissions prevent a meaningful client from being built. Cockayne gives missing credentials as an example: the constructor should return no client and report ErrUnableToConstruct. The design does not treat every error as recoverable; it draws the line between an incompatible option and a missing prerequisite.

Make the construction report actionable

A useful receipt should identify the affected fields, the capability they required, and why that setting could not be applied. A caller needs enough detail to distinguish, for example, a dropped sampling option from a missing credential, rather than receiving a vague warning that configuration was incomplete.

The proposed report should collect all discovered construction problems in one attempt instead of stopping at the first. As Cockayne puts it: “Construction reports every problem rather than the first, so a caller fixing three mistakes learns all three from one call instead of one round-trip at a time.” He describes this as the intended behavior of the proposal, not a measured performance result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

It should also preserve error unwrapping so callers can inspect underlying causes using Go’s error-handling mechanisms. The report’s named fields are Fields, Capability, and Reason: together, they indicate what was omitted, what it depended on, and why it could not be set.

What callers must do with a partial-configuration report

Returning a client alongside diagnostics transfers an important decision to the caller. The library can make dropped settings visible, but it cannot ensure callers notice or act on them. If application code ignores the report, the client may run with behavior different from the requested configuration.

Callers adopting this contract should inspect the report and choose explicitly whether the resulting client is acceptable. Depending on the application, a caller might proceed with a documented limitation or reject the partial configuration at its own boundary. The key distinction is that the constructor communicates what happened; the caller decides whether that outcome is safe for its use case.

What this design trades

Question Reject the whole construction Return a usable client with a report
Failure scope Any construction error can prevent use of the entire result. Recoverable incompatibilities need not discard usable portions.
Visibility Depends on the error details and whether multiple issues are reported. Each dropped setting can be reported with its field, required capability, and reason.
Failure boundary The constructor may take a strict all-or-nothing stance. Optional settings may be dropped, while essential missing prerequisites remain fatal.
Caller responsibility The library enforces rejection centrally. Callers must inspect and handle the partial-configuration report.

Neither policy is automatically right for every Go client. An all-or-nothing constructor makes strictness easy to enforce; a partial-result contract can preserve useful work but requires callers to handle diagnostics carefully. The choice depends on whether partial operation is meaningful and whether callers can reliably make that decision.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

An implementation detail that exposed a reporting gap

Cockayne recounts that an early dropped-setting error did not name the default model when the caller had not chosen one. He says a fix addressed that omission. The example illustrates why diagnostics should describe the effective configuration, including defaults—not only values explicitly supplied by the caller. It is an account of that implementation, not evidence about Go constructors generally.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.