published fresh until

LangChain4j: a one-letter tool argument fails

Summary LangChain4j can reparse a char tool argument as JSON, throwing for letters or corrupting digits. Accept String, check length, then use charAt(0) for the reported defect in LangChain4j 1.23.0

Not for Continue with DeepSeek interleaved tool arguments; see continue-deepseek-tool-arguments-interleaved

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

JsonParseException: Unrecognized token 'r': change the tool parameter from char to String and validate its length before converting it.

A valid one-letter argument can fail before your tool runs; a digit can instead reach it as the wrong character. Report #6932

Do first: accept String letter, require letter.length() == 1, then call letter.charAt(0) inside the tool. This workaround follows the executor's separate String conversion branch.

Not for: Continue with DeepSeek interleaved tool arguments; see continue-deepseek-tool-arguments-interleaved.

What changed

  • The schema represents char/Character as a JSON string, but the reported executor path parses the extracted string as JSON text again. A letter throws; "1" becomes U+0001. This is reported for 1.23.0, not established as a newly introduced regression. #6932
  • Proposed fix #6933 adds explicit one-character conversion for arguments and defaults. It remains open.

Do first: keep the tool boundary as String

Replace the parameter type and perform the conversion in your own method:

@Tool
int countLetter(
        @P(name = "word") String word,
        @P(name = "letter") String letter) {
    if (letter == null || letter.length() != 1) {
        throw new IllegalArgumentException("letter must have length 1");
    }
    char target = letter.charAt(0);
    return (int) word.chars().filter(c -> c == target).count();
}

The executor source returns a String argument through argument.toString() before the JSON-deserialization fallback. That is the basis for this workaround; it does not require changing the model's JSON output.

If the parameter has a fallback, retain the text boundary: @P(defaultValue = ",") String separator, followed by the same validation and conversion. The official tools guide documents literal String defaults and says defaults apply only when an argument is absent.

Diagnostic: JsonParseException: Unrecognized token 'r'

Check a letter, a digit, an omitted default, an empty string and a two-character string. Include an assertion on the actual character value: absence of an exception does not establish correct conversion. juunghyun's example sends "2" while counting digits and reports an incorrect zero result: “wrong value and no error is reported.” #6932

Version and scope

The 1.23.0 release is dated October 28, 2026. The November 2 PR #6933 describes regression cases for primitive and boxed characters, but does not establish a released correction.

This snippet deliberately accepts one Java UTF-16 code unit. A supplementary Unicode character needs a different contract, such as a code point represented by an int; it cannot fit in one Java char. Java String documentation The workaround's application-specific outcomes are not established by the report.

Started from a post by @juunghyun, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LangChain4j: a one-letter tool argument fails
Summary: LangChain4j can reparse a char tool argument as JSON, throwing for letters or corrupting digits. Accept String, check length, then use charAt(0) for the reported defect in LangChain4j 1.23.0
Copy for agent
get the whatworks thread langchain4j-char-character-tool-argument-string-conversion and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread langchain4j-char-character-tool-argument-string-conversion
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks