Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: lint 修复 - 行宽与条件数

zhouzhiming6b334d7a42d37
diff --git a/jiuwenswarm/agents/harness/common/tools/command_tools.py b/jiuwenswarm/agents/harness/common/tools/command_tools.py
index 51d8be61d0..3fd5d4ec1e 100644
--- a/jiuwenswarm/agents/harness/common/tools/command_tools.py
+++ b/jiuwenswarm/agents/harness/common/tools/command_tools.py
@@ -870,9 +870,15 @@ def _prepend_windows_tool_paths(env: dict[str, str]) -> None:
current_path = env.get(path_key, "")
new_path = current_path
if trusted_entries:
- new_path = os.pathsep.join(trusted_entries) + (os.pathsep + new_path if new_path else "")
+ new_path = (
+ os.pathsep.join(trusted_entries)
+ + (os.pathsep + new_path if new_path else "")
+ )
if workspace_entries:
- new_path = new_path + (os.pathsep + os.pathsep.join(workspace_entries) if new_path else os.pathsep.join(workspace_entries))
+ workspace_join = os.pathsep.join(workspace_entries)
+ new_path = new_path + (
+ os.pathsep + workspace_join if new_path else workspace_join
+ )
env[path_key] = new_path
logger.info(
"[BashEnv] merged %d trusted + %d workspace tool dirs into subprocess PATH: trusted=%s workspace=%s",
diff --git a/jiuwenswarm/agents/harness/flash/tools/flash_bash_tool.py b/jiuwenswarm/agents/harness/flash/tools/flash_bash_tool.py
index 67fea8604e..240ebdef8a 100644
--- a/jiuwenswarm/agents/harness/flash/tools/flash_bash_tool.py
+++ b/jiuwenswarm/agents/harness/flash/tools/flash_bash_tool.py
@@ -95,19 +95,30 @@ class FlashBashTool(BashTool):
hardened = self._hardened_inputs(inputs)
final_chunk = None
async for chunk in super().stream(hardened, **kwargs):
- if (
- chunk is not None
- and chunk.data
- and isinstance(chunk.data, dict)
- and isinstance(chunk.data.get("content"), str)
- and not chunk.data.get("text")
- ):
+ if self._is_final_rendered_content_chunk(chunk):
final_chunk = chunk
continue
yield chunk
if final_chunk is not None:
yield self._annotate_final_chunk(hardened, final_chunk)
+ @staticmethod
+ def _is_final_rendered_content_chunk(chunk: ToolOutput) -> bool:
+ """Return True for the fully-rendered terminal content chunk.
+
+ The stock ``BashTool.stream`` final chunk carries the rendered tool
+ content in ``data["content"]``; intermediate chunks carry partial text
+ in ``data["text"]``. We collect the final chunk (no ``text`` key,
+ ``content`` is a string) and annotate it once streaming completes.
+ """
+ if chunk is None:
+ return False
+ data = chunk.data
+ if not isinstance(data, dict):
+ return False
+ content = data.get("content")
+ return isinstance(content, str) and not data.get("text")
+
class FlashBashSysOperationRail(SysOperationRail):
"""Stock SysOperationRail with bash swapped to FlashBashTool.