Skip to content

[Go] Prompts with "WithTools" and "WithOutputType" results in error #3626

@check24-axel-nitzsche

Description

@check24-axel-nitzsche

Describe the bug
If we define a prompt with both ai.WithOutputType and ai.WithTool, the generated "toolRequest" result fail with the error:
model failed to generate output matching expected schema: data is not valid JSON: unexpected end of JSON input.

Without ai.WithOutputType, the "toolRequest" is handled correctly.

To Reproduce

tool := genkit.DefineTool(....)

prompt := genkit.DefinePrompt(
  g,
  "prompt",
  ai.WithPrompt("my prompt"),
  ai.WithInputType(Input{}),
  ai.WithOutputType(Output{}),
  ai.WithTools(tool),
)

prompt.Execute(ctx, ai.WithInput(in))

Expected behavior
"toolRequests" should be handled correctly when used in combination with ai.WithOutputType

Screenshots
If applicable, add screenshots to help explain your problem.

Runtime (please complete the following information):

  • OS: MacOS
  • Version 15.7

** Go version

  • 1.25.1

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggo

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions