Skip to content

[Bug]:TruncateArgsConfig clips tool arguments to a hardcoded 20 chars instead of maxArgLength #4203

Open

Description

@coderzhn

Describe the bug

CompactionConfig.TruncateArgsConfig documents that large tool arguments "are clipped to
getMaxArgLength() characters" (CompactionConfig.java:443-444), with a default
maxArgLength of 2000. But ConversationCompactor.truncateToolUseBlock clips to a
hardcoded 20 characters:

// ConversationCompactor.java:971-972
if (entry.getValue() instanceof String s && s.length() > cfg.getMaxArgLength()) {
    newInput.put(entry.getKey(), s.substring(0, 20) + cfg.getTruncationText());
}

maxArgLength is only used as the "should I truncate" threshold; the kept prefix is always
20 chars. With the default config this means a 5 000-char argument is reduced to 20 chars
(not the documented 2000) — far more data loss than configured.

ConversationCompactorTruncateArgsTest enshrines the 20-char behavior
("x".repeat(20) + config.getTruncationText()), so either the Javadoc or the
implementation is wrong.

To Reproduce

var cfg = CompactionConfig.TruncateArgsConfig.builder()
.maxArgLength(2000) // default-like
.build();
// a ToolUseBlock with an input value of "x".repeat(5000) in an older (pre keep-window) message
// after compactor.truncateArgs(...): the value becomes "x".repeat(20) + truncationText

Expected

Large arguments are clipped to maxArgLength characters (per the class Javadoc), i.e.
substring(0, cfg.getMaxArgLength()); or the Javadoc should be corrected to state that only
the first 20 chars are kept.

Environment

  • AgentScope-Java: main (2.1.0-SNAPSHOT)
  • Java: 17

Activity

  1. added
    bug
    on Nov 15, 2026
  2. coderzhn commented on Nov 15, 2026

    @coderzhn
    ContributorAuthor

    Opened PR #4204 for this: clip tool arguments to maxArgLength instead of a hardcoded 20,
    with the tests updated to assert the configured length. The getTruncationText Javadoc is
    corrected accordingly. This changes behavior for arguments longer than maxArgLength
    (clipped to maxArgLength rather than 20) — flagging in case you intended the 20-char prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions