Skip to content

[Bug]: Deprecated formatter.* DeepSeek/GLM formatters bypass provider fixes on the two-arg doFormat(List, GenerateOptions) production path (missed by #3272) #3556

Closed

Description

@zzz-ghost

OpenAIChatModel formats every request through the two-arg production path:

List<OpenAIMessage> openaiMessages = formatter.format(messages, effectiveOptions);

AbstractBaseFormatter.format(List<Msg>, GenerateOptions) dispatches to doFormat(msgs, options). The deprecated aliases in io.agentscope.extensions.model.openai.formatter only override the one-arg doFormat(List<Msg>), so the production two-arg path falls through to OpenAIChatFormatter and silently skips every provider fix:

  • formatter.DeepSeekFormatter / formatter.DeepSeekMultiAgentFormatter: the legacy name-field removal and the reasoning_content preservation/backfill never run → the old endpoint rejects name with HTTP 400, and thinking-mode requests fail with The reasoning_content in the thinking mode must be passed back to the API for any assistant turn lacking reasoning_content (e.g. framework-synthesized subagent completion notifications whose content is only a HintBlock).
  • formatter.GLMFormatter / formatter.GLMMultiAgentFormatter: ensureUserMessage never runs → requests without a user message hit GLM error 1214.

PR #3272 fixed exactly this class of bug for the compat formatters, and its commit message states the deprecated formatters were included:

"applyDeepSeekFixes never strips reasoning_content and backfills an empty string for assistant messages that lack it, in both the compat and the deprecated DeepSeekFormatter and DeepSeekMultiAgentFormatter; both formatters now override the two-arg doFormat(List, GenerateOptions) production path."
"the deprecated formatter additionally keeps its legacy name-field removal."

However, the merged diff of #3272 only touches the compat.deepseek / compat.glm classes — the four deprecated classes in formatter were not modified, so the described behavior does not match the code. This issue is about closing that gap.

To Reproduce

// io.agentscope.extensions.model.openai.formatter.DeepSeekFormatter (deprecated alias)
DeepSeekFormatter formatter = new DeepSeekFormatter();

// Framework notification: assistant message whose content is only a HintBlock,
// as synthesized by InboxMiddleware for subagent completion.
List<Msg> msgs = List.of(
        Msg.builder().role(MsgRole.USER)
                .content(List.of(TextBlock.builder().text("spawn two tasks").build())).build(),
        Msg.builder().role(MsgRole.ASSISTANT)
                .content(List.of(new HintBlock("hint-1", "Background task completed"))).build());

// Production path used by OpenAIChatModel:
List<OpenAIMessage> out = formatter.format(msgs, (GenerateOptions) null);

// out.get(1): role=assistant, reasoningContent == null  -> DeepSeek thinking mode HTTP 400
// One-arg formatter.format(msgs) has the same gap for reasoning backfill;
// additionally, msg name fields are only stripped on the one-arg path.

Expected behavior

Both format(msgs) and format(msgs, options) go through the same provider fixes on the deprecated aliases, matching the compat formatters after #3272 and matching the behavior described in #3272's commit message: names removed, reasoning_content preserved and backfilled with an empty string when missing (DeepSeek); at least one user message guaranteed (GLM).

Error messages

HTTP 400: The `reasoning_content` in the thinking mode must be passed back to the API.
HTTP 400 (old endpoint): ... name field not supported ...
GLM error 1214: ...

Environment

  • AgentScope-Java Version: 2.1.0-BETA1 (also reproducible on current main)
  • Java Version: 17+
  • OS: any (Windows / Linux)

Additional context

Verified on the v2.1.0-BETA1 tag with 4 JUnit cases:

  1. compat DeepSeekFormatter two-arg path backfills reasoning_content="" for a pure-hint assistant (fixed by fix(deepseek): pass reasoning_content back for all assistant turns #3272) — passes.
  2. deprecated formatter.DeepSeekFormatter two-arg path leaves the same message without reasoning_content — bug reproduced.
  3. deprecated formatter.DeepSeekFormatter two-arg path keeps the name field — bug reproduced.
  4. deprecated formatter.DeepSeekFormatter one-arg path strips name — confirms the gap is specific to the two-arg entry.

We have a fix + regression tests ready (adds the two-arg doFormat override to the four deprecated classes and aligns the legacy DeepSeek fixes with the #3272 semantics while keeping the legacy name removal) and are happy to open a PR referencing this issue.

Activity

  1. jujn commented on Oct 14, 2026

    @jujn
    Collaborator

    直接用新的不好吗?不打算修了,也许某天哪个版本直接移除了

  2. zzz-ghost commented on Oct 14, 2026

    @zzz-ghost
    ContributorAuthor

    了解,那我们项目侧就切到新的 compat formatter 了,等 2.1.0 正式版发布就升级迁移。旧别名未来如果移除也合理,省得两套行为不一致。感谢回复!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions