Skip to content

[codex] Add interruptible sleep tool#28429

Merged
pakrym-oai merged 7 commits into
mainfrom
pakrym/sleep-tool
Jun 16, 2026
Merged

[codex] Add interruptible sleep tool#28429
pakrym-oai merged 7 commits into
mainfrom
pakrym/sleep-tool

Conversation

@pakrym-oai

@pakrym-oai pakrym-oai commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Why

Models sometimes need to pause briefly while waiting for external work, but using a shell command for that delay ties the wait to a process and does not naturally resume when new turn input arrives.

What changed

  • add a built-in sleep tool behind the under-development sleep_tool feature
  • accept a bounded duration_ms argument, matching the millisecond convention used by unified exec
  • end the sleep early when either steered user input or mailbox input arrives
  • include elapsed wall-clock time in completed and interrupted outputs
  • emit a dedicated core SleepItem through item/started and item/completed
  • expose the sleep item as app-server v2 ThreadItem::Sleep and retain it in reconstructed thread history
  • regenerate the configuration schema for the new feature flag
  • regenerate app-server JSON and TypeScript schema fixtures

Test plan

  • just test -p codex-core sleep_tool_follows_feature_gate
  • just test -p codex-core any_new_input_interrupts_sleep
  • just test -p codex-app-server-protocol
  • just test -p codex-app-server sleep_emits_started_and_completed_items

@avinashkamat48 avinashkamat48 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation validates duration_ms after deserialization, but the tool schema still exposes it as a generic JSON number while the Rust type is u64. That leaves the model/tool caller with a schema that allows fractional values even though parse_arguments will reject them before the explicit range check runs. It would be cleaner to expose this as an integer with min/max constraints if the schema helper supports that, or add a small parse/validation test for fractional input so the model-visible error remains intentional. This matters more here because the tool description says 1..=3600000, but the machine-readable schema currently only says number.

@pakrym-oai
pakrym-oai marked this pull request as ready for review June 16, 2026 04:07
@pakrym-oai
pakrym-oai requested a review from a team as a code owner June 16, 2026 04:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e0bb90c77

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread codex-rs/app-server-protocol/src/protocol/thread_history.rs
async fn any_new_input_interrupts_sleep() {
const FIRST_SLEEP_CALL_ID: &str = "sleep-call-1";
const SECOND_SLEEP_CALL_ID: &str = "sleep-call-2";
const SLEEP_DURATION_MS: u64 = 60_000;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any harm in having a u64::MAX for the interruptible sleep to avoid the potential for flakes w/ infra weirdness?

@pakrym-oai
pakrym-oai merged commit 08901fc into main Jun 16, 2026
31 checks passed
@pakrym-oai
pakrym-oai deleted the pakrym/sleep-tool branch June 16, 2026 04:39
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants