Skip to content

--export 与 --list-models 等查询命令组合使用时,查询结果被静默吞掉 #593

Description

@jensenli-cn

--export 与 --list-models 等查询命令组合使用时,查询结果被静默吞掉
问题描述
当 --export 与 --list-models(以及其他 list 命令)组合使用时,--export 的结果会"吞掉"后续的查询命令,用户看不到模型列表:

$ loushang --list-models --export
Exported to: D:\test_export.html # 用户期望看到模型列表,但只看到 export 消息
复现步骤:

loushang --list-models --export
loushang --list-sessions --export
loushang --list-plugins --export
根因分析
host_operations.py:366-452 中,操作按顺序排列,export 在第一个(第 367 行),list_models 在最后一个(第 441 行)。

runtime.py:160-167 中,CliOperationSequence.run() 在遇到第一个返回非 None 结果的操作后就 短路退出:

async def run(self) -> int | None:
for stage in self._stages:
result = stage.handler()
if inspect.isawaitable(result):
result = await result
if result is not None:
return result # ← 短路!
return None
host_operations.py:509 中,run_export_operation 成功时返回 0:

return 0
因此 export 返回 0(非 None),导致 list_models 永远不会执行。

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions