Skip to content

fix: use %v to format script tool args, fixing number type interpolation#2172

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/fix-https-github-com-docker-docker-agent-2c36a0a8
Mar 19, 2026
Merged

fix: use %v to format script tool args, fixing number type interpolation#2172
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/fix-https-github-com-docker-docker-agent-2c36a0a8

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 19, 2026

Summary

Fix script tool arguments with type: number being interpolated as %!s(float64=42) instead of 42.

Problem

When a script tool argument has type: number, the LLM sends a JSON number which Go unmarshals as float64. The execute method used fmt.Sprintf("%s=%s", key, value) to build environment variables, but %s on a float64 produces %!s(float64=42) instead of 42.

Fix

Changed %s to %v in the format string so all JSON types are formatted correctly:

  • string → unchanged behavior
  • float64 (JSON numbers) → proper numeric representation (e.g. 42, 3.14)
  • booltrue/false

Added a test that exercises a tool with a number-typed argument end-to-end.

Fixes #2169

When script tool arguments have type: number, the LLM sends JSON numbers
which are unmarshaled as float64 in Go. Formatting float64 with %s produces
'%!s(float64=42)' instead of '42'. Using %v correctly formats all types.

Fixes docker#2169

Assisted-By: docker-agent
@dgageot dgageot requested a review from a team as a code owner March 19, 2026 14:16
@dgageot dgageot merged commit cb201e0 into docker:main Mar 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Script tool args with type: number are interpolated as %s

2 participants