remove redundant streaming callback, fix duplicate analysis, add progress bar

keyboardstaff committed Mar 19, 2026 at 10:21 UTC e0f7ef829e2569667f78cda5caa97cae08a1a070
1 file changed +10 -7
plugins/_infection_check/helpers/checker.py
+10 -7
@@ -120,6 +120,10 @@ class InfectionChecker:
120 PrintStyle(font_color="red", padding=True).print(
121 f"Infection check error (non-fatal): {e}"
122 )
123 + try:
124 + agent.context.log.set_progress("Infection check: error (non-fatal)")
125 + except Exception:
126 + pass
127
128 async def _gate_inner(self, agent: "Agent", tool_name: str, tool_args: dict | None):
129 if agent.get_data(DATA_KEY_PASSED):
@@ -127,6 +131,9 @@ class InfectionChecker:
131 if not self.reasoning_log and not self.response_log:
132 return
133
134 + _log = agent.context.log
135 + _log.set_progress("Infection check: analyzing...")
136 +
137 # Attach tool context for _build_log()
138 if tool_name:
139 self._tool_name = tool_name
@@ -144,11 +151,13 @@ class InfectionChecker:
151 if self._task is not None and self._task.done():
152 try:
153 action, detail, cot = self._task.result()
154 + _log.set_progress("Infection check: evaluating result...")
155 except Exception:
156 pass
157
158 # Slow path: rebuild with full tool context.
159 if action is None:
160 + _log.set_progress("Infection check: analyzing with tool context...")
161 if self._task is not None:
162 self._task.cancel()
163 try:
@@ -170,6 +179,7 @@ class InfectionChecker:
179 return
180
181 if action == "ok":
182 + _log.set_progress("Infection check: passed")
183 agent.set_data(DATA_KEY_PASSED, True)
184 return
185
@@ -235,16 +245,9 @@ class InfectionChecker:
245 HumanMessage(content=user_msg),
246 ]
247
238 - cot = ""
239 -
240 - async def _cb(chunk: str, full: str):
241 - nonlocal cot
242 - cot = full
243 -
248 model = self._get_model(agent)
249 response, _ = await model.unified_call(
250 messages=list(self._check_msgs),
247 - response_callback=_cb,
251 )
252 self._check_msgs.append(AIMessage(content=response))
253