codex - 💡(How to fix) Fix Ambients Suggestions feature uses `UserPromptSubmit` hook without `Stop` hook afterwards [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#18541Fetched 2026-04-19 15:11:08
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2unlabeled ×1

Fix Action

Fix / Workaround

A few thoughts on how that might be fixed:

  1. Being able to activate/deactivate Ambients Suggestions feature on the project level (Codex App settings, config.toml, etc) — [I doubt you do that, cause it really has a product value]
  2. Don't run hooks for Ambient Suggestion feature — [still not the best solution]
  3. Fix running Stop hooks — [will be a workaround, cause it is still not obvious why should I wait for something CodexApp is doing in the background]
  4. Being able to control which hook should be run during Ambient Suggestion. In the hooks.json set something like runWithAmbientSuggestions for each hook (with true by default)

Severity: This thing is really annoying. Thankfully, my connector has a Force End feature, which is a workaround for now

Code Example

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/bin/sh -lc 'dir=\"$PWD\"; while :; do script=\"$dir/.codex/hooks/unity-ai-agent-connector/user_prompt_submit.py\"; if [ -f \"$script\" ]; then exec /usr/bin/python3 \"$script\"; fi; parent=$(dirname \"$dir\"); if [ \"$parent\" = \"$dir\" ]; then printf \"%s\\n\" \"Managed Codex hook script not found: /.codex/hooks/unity-ai-agent-connector/user_prompt_submit.py\" >&2; exit 127; fi; dir=\"$parent\"; done'",
            "timeout": 610,
            "statusMessage": "Starting Unity task"
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/bin/sh -lc 'dir=\"$PWD\"; while :; do script=\"$dir/.codex/hooks/unity-ai-agent-connector/stop.py\"; if [ -f \"$script\" ]; then exec /usr/bin/python3 \"$script\"; fi; parent=$(dirname \"$dir\"); if [ \"$parent\" = \"$dir\" ]; then printf \"%s\\n\" \"Managed Codex hook script not found: /.codex/hooks/unity-ai-agent-connector/stop.py\" >&2; exit 127; fi; dir=\"$parent\"; done'",
            "timeout": 610,
            "statusMessage": "Ending Unity task"
          }
        ]
      }
    ]
  }
}
RAW_BUFFERClick to expand / collapse

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.415.40636 (1799)

What subscription do you have?

Pro

What platform is your computer?

Darwin 25.4.0 arm64 arm

What issue are you seeing?

I am using Codex CLI/App with Unity Editor. I wrote a custom Unity AI Agent Connector that enables Codex to behave appropriately in a Unity environment, especially in an AI-agentic loop. During agent work, I need to show in the UnityEditor that the task is in progress and its status, and block any user input to prevent interference with the agent work.

For that, I am utilizing 2 hooks: UserPromptSubmit and Stop.

It worked great until the recent CodexApp update that added ambient suggestions feature. It looks like they run after any thread is done and/or archived, and call the UserPromptSubmit hook without Stop at the end. That led to infinite "In progress" task in the Unity Editor

Here is how it looks in the Unity Editor: <img width="554" height="333" alt="Image" src="https://github.com/user-attachments/assets/6585e30a-7b90-49e1-b2a9-9ab09b900fe2" />

My hooks.json:

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/bin/sh -lc 'dir=\"$PWD\"; while :; do script=\"$dir/.codex/hooks/unity-ai-agent-connector/user_prompt_submit.py\"; if [ -f \"$script\" ]; then exec /usr/bin/python3 \"$script\"; fi; parent=$(dirname \"$dir\"); if [ \"$parent\" = \"$dir\" ]; then printf \"%s\\n\" \"Managed Codex hook script not found: /.codex/hooks/unity-ai-agent-connector/user_prompt_submit.py\" >&2; exit 127; fi; dir=\"$parent\"; done'",
            "timeout": 610,
            "statusMessage": "Starting Unity task"
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/bin/sh -lc 'dir=\"$PWD\"; while :; do script=\"$dir/.codex/hooks/unity-ai-agent-connector/stop.py\"; if [ -f \"$script\" ]; then exec /usr/bin/python3 \"$script\"; fi; parent=$(dirname \"$dir\"); if [ \"$parent\" = \"$dir\" ]; then printf \"%s\\n\" \"Managed Codex hook script not found: /.codex/hooks/unity-ai-agent-connector/stop.py\" >&2; exit 127; fi; dir=\"$parent\"; done'",
            "timeout": 610,
            "statusMessage": "Ending Unity task"
          }
        ]
      }
    ]
  }
}

A few thoughts on how that might be fixed:

  1. Being able to activate/deactivate Ambients Suggestions feature on the project level (Codex App settings, config.toml, etc) — [I doubt you do that, cause it really has a product value]
  2. Don't run hooks for Ambient Suggestion feature — [still not the best solution]
  3. Fix running Stop hooks — [will be a workaround, cause it is still not obvious why should I wait for something CodexApp is doing in the background]
  4. Being able to control which hook should be run during Ambient Suggestion. In the hooks.json set something like runWithAmbientSuggestions for each hook (with true by default)

Severity: This thing is really annoying. Thankfully, my connector has a Force End feature, which is a workaround for now

What steps can reproduce the bug?

Already explained in the What issue are you seeing? field

What is the expected behavior?

Already explained in the What issue are you seeing? field

Additional information

No response

extent analysis

TL;DR

Modify the hooks.json to include a conditional check for ambient suggestions and skip running the UserPromptSubmit hook when it's triggered by the ambient suggestions feature.

Guidance

  • Investigate the Codex App's documentation to see if there's an official way to disable or control the ambient suggestions feature.
  • Consider modifying the UserPromptSubmit hook to detect when it's being triggered by the ambient suggestions feature and exit early to prevent the infinite "In progress" task.
  • Look into implementing a runWithAmbientSuggestions flag in the hooks.json file, as suggested, to control which hooks are run during ambient suggestions.
  • As a temporary workaround, use the Force End feature in the connector to manually end the task when it gets stuck.

Example

No code example is provided as the issue lacks specific details about the Codex App's API or the hooks.json file's syntax.

Notes

The provided solution is based on the assumption that the ambient suggestions feature is the root cause of the issue. However, without more information about the Codex App's internal workings, it's difficult to provide a more definitive solution.

Recommendation

Apply a workaround by modifying the hooks.json file to include a conditional check for ambient suggestions, as this seems to be the most feasible solution given the current information. This will allow the user to regain control over the task's status and prevent the infinite "In progress" task.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Ambients Suggestions feature uses `UserPromptSubmit` hook without `Stop` hook afterwards [2 comments, 2 participants]