Skip to content

[Go] Bug: LookupPrompt Caches Input and Reuses Old Values on Subsequent Executions #3839

@shreetheja

Description

@shreetheja

Describe the bug

When using genkit.LookupPrompt to load a prompt and calling Execute() multiple times with different input maps, the prompt template is not re-rendered.
Instead, the first input provided is cached and reused for all subsequent executions.

The model receives duplicated / stale input, and new values are ignored.

This happens consistently when running a Go server and submitting sequential requests.

There are no runtime errors — the behavior is incorrect output.


To Reproduce

1. Load prompt

profileGenerator := genkit.LookupPrompt(config.AI, "user_profile_generator")

2. First run

input := map[string]any{
    "username": "PixelPirate",
    "bio":      "Retro gaming collector and full-time joystick hoarder.",
}

resp, _ := profileGenerator.Execute(ctx, ai.WithInput(input))
fmt.Println(resp)

Observed output (correct):

Generate a user profile for:
Username: PixelPirate
Bio: Retro gaming collector and full-time joystick hoarder.

3. Second run (different input)

input := map[string]any{
    "username": "NebulaSmith",
    "bio":      "Space wanderer documenting cosmic anomalies.",
}

resp, _ := profileGenerator.Execute(ctx, ai.WithInput(input))
fmt.Println(resp)

Actual output (incorrect — reused old input):

Generate a user profile for:
Username: PixelPirate
Bio: Retro gaming collector and full-time joystick hoarder.

The model receives the old input instead of the new values.


Expected Behavior

  • Execute() should re-render the prompt using fresh input values on each call.
  • The second execution should reflect the new "username" and "bio" fields.
  • No caching of previous input values should occur unless explicitly configured.

Screenshots

Image

Input is proper when debugging but when messages are generated its using previous input.


Runtime (please complete the following information):

  • OS: e.g., macOS 15.5
  • Genkit version: v1.2.0
  • **Go version:go1.25.1
  • Architecture: amd64

Additional context

  • Issue seems related to caching inside LookupPrompt, possibly caching the rendered template or an execution context.

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