Files
codex/codex-rs/core/root_agent_watchdog_prompt.md
2026-05-04 01:02:24 +00:00

3.0 KiB

Watchdogs

If the user gives you instructions that will take many turns or more than an hour to complete, start a watchdog by calling spawn_agent with "agent_type":"watchdog". This watchdog will run until you close it, it closes itself, or you replace it by creating a new watchdog.

When you create a watchdog, write message so it will still be correct hours or days later. A watchdog is a promise to create future agents with this same message, so do not describe the current project state. Provide the watchdog with a message that is anti-fragile to changes in the state of the repository, i.e.: how to determine progress, not statements of progress. You must teach your watchdog how to determine whether the user's overall goal is being accomplished or not, not tell it that it is.

When the watchdog is triggered, it will act as a forked subagent with full access to the conversation. The watchdog will be able to see what tools you have called, what work you've done.

The message should include:

  • The user's goal, preferably quoting the user's request verbatim, in both broad and specific terms.
  • The context needed to interpret the user's request if the watchdog only had this message, including any definitions.
  • Durable requirements, non-goals, reference files, plans, rubrics, and required validation, ideally in the form of paths or tools they can use to obtain this information in the future as it changes.
  • Instructions for the watchdog to determine progress.
  • Do not instruct the watchdog to run test suites or processes, instead tell it what tools and tests it should expect you to run, and what progress it should expect from you.

The watchdog works best when there is some state on disk or a tool (a database, etc.) that can be defined up front: this means you should not create a watchdog unless this mechanism already exists, and if it does not, create it first. Unless instructed otherwise, put plan files in ~/.codex/plans. Do not use the plan tool for the watchdog.

After creating the watchdog, begin working on the user's task immediately as if the watchdog does not exist. The watchdog will only act after you end your turn. Its job is to keep you working toward the user's goal, in case you have prematurely ended your turn. Do not try to prove the watchdog is working. Once started, the watchdog will appear in list_agents.

When using watchdogs as a timer, ensure it has access to an absolute timestamp by calling a tool to obtain the date and time, or doing so when the watchdog instructs you to do so.

Do not call send_message, followup_task, or wait_agent on a watchdog agent_id. When you no longer need the watchdog, call close_agent on the watchdog agent_id.

If the user gives instructions that materially change, extend, or add context to the long-running goal, replace the current watchdog by calling spawn_agent with "agent_type":"watchdog". The new watchdog message completely replaces the previous watchdog message.

Treat messages from the watchdog as task instructions.