Skip to content

[Go] Ollama plugin hardcoded 30 seconds timeout #3506

@lukaszKielar

Description

@lukaszKielar

Describe the bug

This is duplicate of #719.

I have recently stumble upon same exact issue where local Ollama request to thinking model fails with timeout error.

2025/09/06 00:20:09 ERROR request end err="failed to send request: Post \"http://127.0.0.1:11434/api/chat\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"

Issue #719 was resolved by #1040, but main branch still have timeout hardcoded here.

To Reproduce

package main

import (
	"context"
	"errors"
	"fmt"
	"strconv"

	"github.com/firebase/genkit/go/ai"
	"github.com/firebase/genkit/go/core"
	"github.com/firebase/genkit/go/genkit"
	"github.com/firebase/genkit/go/plugins/ollama"
)

const (
	modelName = "deepseek-r1:8b"
)

func main() {
	ctx := context.Background()

	ollamaPlugin := ollama.Ollama{ServerAddress: "http://127.0.0.1:11434"}

	g := genkit.Init(
		ctx,
		genkit.WithPlugins(&ollamaPlugin),
	)

	model := ollamaPlugin.DefineModel(
		g,
		ollama.ModelDefinition{
			Name: modelName,
			Type: "chat",
		},
		nil,
	)

	type MenuItem struct {
		Name        string `json:"name"`
		Description string `json:"description"`
	}

	genkit.DefineFlow(g, "menuSuggestionFlowComplex",
		func(ctx context.Context, theme string) (string, error) {
			output, _, err := genkit.GenerateData[MenuItem](ctx, g,
				ai.WithModel(model),
				ai.WithPrompt("Invent a menu item for a %s themed restaurant.", theme),
			)
			if err != nil {
				return nil, err
			}
			return fmt.Sprintf("**%s**: %s", item.Name, item.Description), nil
		})

	<-ctx.Done()
}
  1. Create main.go (code above)
  2. Download deepseek-r1:8b and run Ollama ollama serve
  3. Run genkit genkit start -- go run .
  4. Submit query to the flow and wait for model's response.

Expected behavior

Timeout present as one of the configuration options.

Screenshots

N/A

Runtime (please complete the following information):

  • OS: MacOS
  • Version 15.6.1
  • Chip: Apple M2 Max

** Go version

  • 1.25.0

Additional context

N/A

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggo

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions