no-polling-agents

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

No Polling for Background Agents

避免对后台Agent进行轮询

When launching parallel background agents, do NOT poll with sleep loops.
在启动并行后台Agent时,请勿使用睡眠循环进行轮询。

Pattern

模式

Background agents write to status files when complete. Wait for them naturally.
后台Agent完成后会写入状态文件。自然等待它们完成即可。

DO

推荐做法

  • Launch agents with
    run_in_background: true
  • Continue with other work while agents run
  • Check status file only when user asks or when you need results to proceed
  • Trust the agent completion system
  • 使用
    run_in_background: true
    启动Agent
  • 在Agent运行期间继续处理其他工作
  • 仅在用户询问或需要结果来推进任务时检查状态文件
  • 信任Agent完成系统

DON'T

不推荐做法

  • Run
    sleep 10 && cat status.txt
    in loops
  • Continuously poll for completion
  • Waste tokens checking status repeatedly
  • Block on agents unless absolutely necessary
  • 在循环中执行
    sleep 10 && cat status.txt
  • 持续轮询完成状态
  • 反复检查状态以浪费令牌
  • 除非绝对必要,否则不要阻塞等待Agent

When to Check Status

何时检查状态

  1. User explicitly asks "are they done?"
  2. You need agent output to proceed with next task
  3. Significant time has passed and user is waiting
  1. 用户明确询问“它们完成了吗?”
  2. 你需要Agent的输出来推进下一个任务
  3. 已经过去较长时间且用户在等待

Example

示例

typescript
// Launch agents
Task({ ..., run_in_background: true })
Task({ ..., run_in_background: true })

// Continue with other work or conversation
// Agents will write to status file when done

// Only check when needed
cat .claude/cache/status.txt
typescript
// Launch agents
Task({ ..., run_in_background: true })
Task({ ..., run_in_background: true })

// Continue with other work or conversation
// Agents will write to status file when done

// Only check when needed
cat .claude/cache/status.txt

Source

来源

User feedback: "You can just wait until everyone pings you"
用户反馈:“你只需等待所有人通知你即可”