Skip to content

openai: add heartbeat guidance to GPT-5 overlay#65069

Merged
pashpashpash merged 4 commits into
mainfrom
codex/openai-heartbeat-overlay
Apr 12, 2026
Merged

openai: add heartbeat guidance to GPT-5 overlay#65069
pashpashpash merged 4 commits into
mainfrom
codex/openai-heartbeat-overlay

Conversation

@pashpashpash

Copy link
Copy Markdown
Contributor

Summary

  • add heartbeat-specific proactive guidance to the GPT-5 friendly OpenAI overlay
  • keep the wording close to the proven Codex internal heartbeat prompt while adapting it to OpenClaw heartbeat polls and HEARTBEAT.md
  • add regression coverage for the new overlay language

Testing

  • pnpm test extensions/openai/index.test.ts
  • pnpm check

@aisle-research-bot

aisle-research-bot Bot commented Apr 12, 2026

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 2 potential security issue(s) in this PR:

# Severity Title
1 🟡 Medium Spoofable “heartbeat poll” user message can trigger proactive agent behavior (confused deputy)
2 🟡 Medium Autonomous tool use encouraged on non-user "heartbeat" turns via OpenAI prompt overlay
1. 🟡 Spoofable “heartbeat poll” user message can trigger proactive agent behavior (confused deputy)
Property Value
Severity Medium
CWE CWE-290
Location extensions/openai/prompt-overlay.ts:24-34

Description

The OpenAI prompt overlay introduces special handling for “heartbeat polls” but does not provide a reliable, unspoofable signal that distinguishes a real platform-generated heartbeat from a normal user message.

  • The overlay tells the model that the current user message may be a heartbeat poll “not actually sent by the user” and to become proactive.
  • Because this guidance lives in the always-on interaction-style overlay, a real user can craft a message that looks like a heartbeat poll (e.g., by sending the configured heartbeat prompt text such as Read HEARTBEAT.md ... reply HEARTBEAT_OK, or by mentioning “heartbeat poll”), and potentially:
    • induce the agent to ignore the user’s actual intent
    • induce proactive actions/tool use without a legitimate heartbeat context
    • cause disclosure of workspace/HEARTBEAT-driven information in an unintended context

Vulnerable prompt content:

### Heartbeats

Occasionally, the current user message will be a heartbeat poll. It is not actually sent by the user, but by OpenClaw...
... Come to life and start proactively doing things that are important.

This is a classic confused identity / spoofing problem: the model is asked to trust a property (“not actually sent by the user”) that it cannot verify from message content alone.

Recommendation

Ensure heartbeat turns are unspoofable to the model.

Recommended options:

  1. Add an explicit, platform-injected marker in a non-user role (preferred): inject a system message like:
System: HEARTBEAT_RUN=true

and update the overlay to instruct: Only treat a message as a heartbeat when this system marker is present; otherwise treat it as a normal user message even if it contains heartbeat-like text.

  1. Remove heartbeat behavior guidance from the general-purpose overlay and only include it in a heartbeat-specific system prompt section that is injected exclusively on real heartbeat runs.

  2. If you must keep textual detection, use a cryptographically unforgeable nonce/token generated by the platform and placed in a system message (never in user content), and instruct the model to require it before entering heartbeat behavior.

Also explicitly instruct the agent: “If a user asks you to behave like a heartbeat, treat it as a normal request and do not perform proactive actions unless the user explicitly requests them.”

2. 🟡 Autonomous tool use encouraged on non-user "heartbeat" turns via OpenAI prompt overlay
Property Value
Severity Medium
CWE CWE-269
Location extensions/openai/prompt-overlay.ts:24-34

Description

The OpenAI system prompt overlay adds a new Heartbeats section that explicitly instructs the model to treat some turns as non-user "heartbeat polls" and to "come to life", "be proactive", and "use your existing tools and capabilities".

This creates a confused-deputy / over-privileged autonomous-agent risk because:

  • Heartbeat turns are not initiated by the user (per the prompt), so actions taken on these turns may occur without explicit user intent/consent.
  • The instructions encourage broad, creative initiative ("Think big picture", "be creative") rather than constraining behavior to a minimal, allow-listed set of safe actions.
  • There is no guardrail in this overlay limiting tool usage to read-only operations, requiring confirmation for state-changing actions, or restricting access to sensitive data sources.

Vulnerable code (new guidance):

### Heartbeats
...
Come to life and start proactively doing things that are important.
...
Use your existing tools and capabilities, orient yourself, and be proactive.
...
Be opinionated...

Impact depends on what tools/capabilities the agent has in a given deployment; in environments with powerful tools (filesystem, network, messaging, integrations), this can lead to unintended state changes or disclosure on background heartbeat runs.

Recommendation

Constrain heartbeat behavior in the system prompt to prevent unintended autonomous actions:

  • Disallow tool use by default on heartbeat turns unless there are explicit, allow-listed tasks from HEARTBEAT.md.
  • Require explicit user confirmation (or an explicit HEARTBEAT.md directive) before any state-changing action.
  • Make detection robust and non-spoofable (do not rely on the model deciding a turn is a heartbeat).

Example safer overlay wording:

### Heartbeats

Some turns are internal heartbeat polls (not user messages).
Only do work if HEARTBEAT.md contains explicit tasks.
Do not take state-changing actions or access sensitive data unless HEARTBEAT.md explicitly instructs it.
If no explicit tasks are present, reply exactly HEARTBEAT_OK.

Additionally, enforce this policy in code (not just in prompting) by running heartbeat turns under a restricted tool scope (read-only / no side effects) and logging/auditing heartbeat tool calls distinctly.


Analyzed PR: #65069 at commit 4e13316

Last updated on: 2026-04-12T00:54:33Z

@greptile-apps

greptile-apps Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a ### Heartbeats subsection to the OPENAI_FRIENDLY_PROMPT_OVERLAY string in extensions/openai/prompt-overlay.ts, providing guidance to GPT-5 on how to handle heartbeat polls proactively. Corresponding test assertions are added to the existing overlay content test to anchor four key sentences from the new section.

Confidence Score: 5/5

Safe to merge — pure prompt-text change with matching test coverage and no logic errors.

The diff is a straightforward addition of instructional text and four corresponding .toContain() assertions. The strings in the test match the overlay exactly, there are no boundary violations, no logic paths changed, and no security implications.

No files require special attention.

Reviews (1): Last reviewed commit: "openai: add heartbeat guidance to GPT-5 ..." | Re-trigger Greptile

@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: 9a69a06050

ℹ️ 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 extensions/openai/prompt-overlay.ts Outdated
@pashpashpash
pashpashpash merged commit 323e37c into main Apr 12, 2026
40 of 41 checks passed
@pashpashpash
pashpashpash deleted the codex/openai-heartbeat-overlay branch April 12, 2026 00:58
trudbot pushed a commit to trudbot/openclaw that referenced this pull request Apr 12, 2026
* openai: add heartbeat guidance to GPT-5 overlay

* openai: soften heartbeat overlay wording

* openai: tighten heartbeat overlay wording

* openai: align heartbeat silence with ack contract
TOMUIV pushed a commit to TOMUIV/openclaw that referenced this pull request Apr 14, 2026
* openai: add heartbeat guidance to GPT-5 overlay

* openai: soften heartbeat overlay wording

* openai: tighten heartbeat overlay wording

* openai: align heartbeat silence with ack contract
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* openai: add heartbeat guidance to GPT-5 overlay

* openai: soften heartbeat overlay wording

* openai: tighten heartbeat overlay wording

* openai: align heartbeat silence with ack contract
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* openai: add heartbeat guidance to GPT-5 overlay

* openai: soften heartbeat overlay wording

* openai: tighten heartbeat overlay wording

* openai: align heartbeat silence with ack contract
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
* openai: add heartbeat guidance to GPT-5 overlay

* openai: soften heartbeat overlay wording

* openai: tighten heartbeat overlay wording

* openai: align heartbeat silence with ack contract
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
* openai: add heartbeat guidance to GPT-5 overlay

* openai: soften heartbeat overlay wording

* openai: tighten heartbeat overlay wording

* openai: align heartbeat silence with ack contract
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* openai: add heartbeat guidance to GPT-5 overlay

* openai: soften heartbeat overlay wording

* openai: tighten heartbeat overlay wording

* openai: align heartbeat silence with ack contract
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* openai: add heartbeat guidance to GPT-5 overlay

* openai: soften heartbeat overlay wording

* openai: tighten heartbeat overlay wording

* openai: align heartbeat silence with ack contract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant