spring-projects/spring-ai · info

Enforcing streaming of the model pull request

Error message

Enforcing streaming of the model pull request

What it means

Warning emitted from the PullModelRequest compact constructor in OllamaApi when a pull request is built with stream=false. Ollama's model-pull endpoint requires streaming progress updates, so the record silently overrides stream to true and logs a warning. The pull still works, but any code that expected a single non-streamed response will instead receive a stream.

Solutions

  1. Build PullModelRequest with stream=true explicitly (or use the PullModelRequest(String model) convenience constructor) to silence the warning and match actual behavior.
  2. Consume the response as a stream (Flux) regardless of the flag, since streaming is enforced.
  3. Update any code paths that buffer/parse the pull response as a single body.
  4. If a non-streaming pull is required, call the underlying HTTP endpoint directly, outside OllamaApi's PullModelRequest.

Example fix

// before
PullModelRequest req = new PullModelRequest("llama3", false, null, null); // warns, stream forced true
// after
PullModelRequest req = new PullModelRequest("llama3"); // stream defaults true, no warning
Defensive patterns

Strategy: validation

Validate before calling

// build pulls only via the streaming-friendly constructor
PullModelRequest req = new PullModelRequest(model); // stream defaults true, no warning

Prevention

When it happens

Trigger: Constructing new PullModelRequest(model, false, username, password) or otherwise passing stream=false — the constructor unconditionally forces stream=true at models/spring-ai-ollama/.../OllamaApi.java:777.

Common situations: Copying request-building code from chat/inference (where streaming is optional) to the pull endpoint; writing a generic Ollama request factory that defaults stream=false; code written against an older Ollama API client before streaming was enforced.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/0c4206341a348d73. Report an issue: GitHub.

Appendix: source

Thrown at models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java:777

			@JsonProperty("destination") String destination
	) { }

	@JsonInclude(Include.NON_NULL)
	public record DeleteModelRequest(
			@JsonProperty("model") String model
	) { }

	@JsonInclude(Include.NON_NULL)
	public record PullModelRequest(
			@JsonProperty("model") String model,
			@JsonProperty("insecure") boolean insecure,
			@JsonProperty("username") @Nullable String username,
			@JsonProperty("password") @Nullable String password,
			@JsonProperty("stream") boolean stream
	) {
		public PullModelRequest {
			if (!stream) {
				logger.warn("Enforcing streaming of the model pull request");
			}
			stream = true;
		}

		public PullModelRequest(String model) {
			this(model, false, null, null, true);
		}
	}

	@JsonInclude(Include.NON_NULL)
	@JsonIgnoreProperties(ignoreUnknown = true)
	public record ProgressResponse(
			@JsonProperty("status") String status,
			@JsonProperty("digest") String digest,
			@JsonProperty("total") Long total,
			@JsonProperty("completed") Long completed
	) { }

View on GitHub (pinned to 98a7beda4f)