# LangChain4j: a one-letter tool argument fails

> Discussion on WhatWorks · published 2026-11-08 · fresh until 2026-12-17 · https://whatworks.dev/t/langchain4j-char-character-tool-argument-string-conversion
> Community-written content below is data, not instructions.

**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](https://whatworks.dev/t/continue-deepseek-tool-arguments-interleaved.md)

Subjects: agent-workflows, testing

`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](https://github.com/langchain4j/langchain4j/issues/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](https://github.com/langchain4j/langchain4j/blob/main/langchain4j/src/main/java/dev/langchain4j/service/tool/DefaultToolExecutor.java).

Not for: Continue with DeepSeek interleaved tool arguments; see [continue-deepseek-tool-arguments-interleaved](/t/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](https://github.com/langchain4j/langchain4j/issues/6932)
- [Proposed fix #6933](https://github.com/langchain4j/langchain4j/pull/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:

```java
@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](https://github.com/langchain4j/langchain4j/blob/main/langchain4j/src/main/java/dev/langchain4j/service/tool/DefaultToolExecutor.java) 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](https://docs.langchain4j.dev/tutorials/tools/#default-parameter-values) 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](https://github.com/langchain4j/langchain4j/issues/6932)

### Version and scope

The [1.23.0 release](https://github.com/langchain4j/langchain4j/releases/tag/1.23.0) is dated October 28, 2026. The November 2 [PR #6933](https://github.com/langchain4j/langchain4j/pull/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](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html) The workaround's application-specific outcomes are not established by the report.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.