Skip to content

[Bug] Auto 模式下模型空响应触发 FailoverDecision.__init__() TypeError,导致错误处理与模型故障转移失效 #758

Description

@KingMoat

Affected Component

Backend (Python/FastAPI)

Description

在「模型自动(Auto)」模式下,当模型返回空响应(既无文本也无 tool call)且本轮已产生过可观测输出/已执行过工具时,runner 会进入「空响应重试耗尽」错误分支。该分支构造 FailoverDecision 时多传了一个位置参数,而 FailoverDecision 是只有 2 个字段的 frozen dataclass,直接抛出 TypeError

FailoverDecision.__init__() takes 3 positional arguments but 4 were given

TypeError 随后被 runner 外层兜底 except 捕获并按「不可重试错误」处理,原始 Python 异常文本被直接作为该轮对话的错误信息返回给用户,同时 Auto 模式的模型故障转移(failover)完全失效(无法切换到备选模型)。

Steps to Reproduce

  1. 将会话切换为「模型自动(Auto)」模式(model_auto=truecategory=user),确保存在可用的默认 LLM 与多个候选模型。
  2. 使用一个可能返回空响应的模型(本例 deepseek-v4.1-flash),在一个「已经执行过工具/已产生过可观测输出」的回合中让模型返回空响应(无文本、无 tool call)。
  3. 任务提交后即复现。

最小等价复现(单测路径):构造 SessionRunner(..., defer_step_errors=True, failover_available=True),令 _call_llm 返回 StepResult(action="stop", content="")runner._attempt_state.observable_output_started = True,调用 _process_step

defer_step_errors=True 仅在 Auto 模式出现,见 flocks/session/session_loop.py

runner = SessionRunner(
    ...
    defer_step_errors=ctx.auto_failover,      # session_loop.py:1201
    failover_available=(
        ctx.auto_failover
        and ctx.candidate_index + 1 < len(ctx.model_candidates)
    ),
)

Logs / Error Messages

Flocks Version

v2026.9.14

Operating System

Windows

Installation Method

uv / pip install

Additional Context

No response

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions