MCPcopy Create free account
hub / github.com/Louisym/MiniCC / _default_spawn

Method _default_spawn

mini_claude_code/multi_agent.py:423–455  ·  view source on GitHub ↗

默认 spawn: 启动后台线程运行 agent。源码: lib.rs:1424-1449

(self, job: AgentJob)

Source from the content-addressed store, hash-verified

421 # --------------------------------------------------------
422
423 def _default_spawn(self, job: AgentJob) -> None:
424 """默认 spawn: 启动后台线程运行 agent。源码: lib.rs:1424-1449"""
425
426 def _worker() -> None:
427 try:
428 # 这里是 agent 实际执行的地方
429 # CC 的 run_agent_job (lib.rs:1451-1458) 会:
430 # 1. build_agent_runtime → 创建独立的 ConversationRuntime
431 # 2. runtime.run_turn(prompt) → 执行对话循环
432 # 3. 提取最终文本 → persist completed
433 #
434 # 我们的 mini 版目前没有完整 runtime,
435 # 所以这里只是占位 — 实际集成时替换为 runtime 调用。
436 #
437 # 重要: 即使是占位,错误处理框架已经完整:
438 # - 正常完成 → complete_agent
439 # - 异常 → fail_agent
440 pass # TODO: 集成 runtime 后替换
441 except Exception as exc:
442 # 对应 CC 的 Ok(Err(error)) 分支 (lib.rs:1433-1436)
443 try:
444 self._persist_terminal_state(
445 job.manifest, "failed", error=str(exc),
446 )
447 except Exception:
448 pass # manifest 写入失败也不能 crash 线程
449
450 thread = threading.Thread(
451 target=_worker,
452 name=f"agent-{job.manifest.agent_id}",
453 daemon=True,
454 )
455 thread.start()
456
457
458# ============================================================

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected