MCPcopy
hub / github.com/shareAI-lab/learn-claude-code / collect_background_results

Function collect_background_results

s16_team_protocols/code.py:311–331  ·  view source on GitHub ↗

Collect completed background results as task_notification messages.

()

Source from the content-addressed store, hash-verified

309
310
311def collect_background_results() -> list[str]:
312 """Collect completed background results as task_notification messages."""
313 with background_lock:
314 ready_ids = [bid for bid, task in background_tasks.items()
315 if task["status"] == "completed"]
316 notifications = []
317 for bg_id in ready_ids:
318 with background_lock:
319 task = background_tasks.pop(bg_id)
320 output = background_results.pop(bg_id, "")
321 summary = output[:200] if len(output) > 200 else output
322 notifications.append(
323 f"<task_notification>\n"
324 f" <task_id>{bg_id}</task_id>\n"
325 f" <status>completed</status>\n"
326 f" <command>{task['command']}</command>\n"
327 f" <summary>{summary}</summary>\n"
328 f"</task_notification>")
329 print(f" \033[32m[background done] {bg_id}: "
330 f"{task['command'][:40]} ({len(output)} chars)\033[0m")
331 return notifications
332
333
334# ── MessageBus (from s15) ──

Callers 1

agent_loopFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected