fix(codex): strip intermediary updates from prompts#4131
Conversation
|
This pull request targeted The base branch has been automatically changed to |
|
This pull request targeted The base branch has been automatically changed to |
There was a problem hiding this comment.
Code Review
This pull request introduces logic to strip "## Intermediary updates" sections from Codex payloads, recursively processing nested strings within JSON structures, and includes comprehensive unit tests. Feedback on the changes highlights a potential issue in isCodexIntermediaryUpdatesStopHeading where other Markdown heading levels (such as H3 to H6) are not recognized as stop headings, and duplicate intermediary headings could prematurely stop the skipping process. A code suggestion is provided to handle all standard Markdown heading levels robustly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| func isCodexIntermediaryUpdatesStopHeading(trimmedLine string) bool { | ||
| return strings.HasPrefix(trimmedLine, "# ") || strings.HasPrefix(trimmedLine, "## ") | ||
| } |
There was a problem hiding this comment.
The current implementation of isCodexIntermediaryUpdatesStopHeading only stops skipping when it encounters # or ## headings. If the prompt contains subheadings of other levels (such as ### , #### , etc.) after the ## Intermediary updates section, they will be skipped and incorrectly stripped from the payload.\n\nAdditionally, if another ## Intermediary updates heading is encountered while skipping, it will be treated as a stop heading and stop the skipping process, which is also unintended.\n\nWe should update this function to:\n1. Avoid stopping if the heading is exactly ## Intermediary updates.\n2. Support all standard Markdown heading levels (H1 to H6, i.e., 1 to 6 # characters followed by a space).
func isCodexIntermediaryUpdatesStopHeading(trimmedLine string) bool {\n\tif trimmedLine == codexIntermediaryUpdatesHeading {\n\t\treturn false\n\t}\n\tfor i := 1; i <= 6; i++ {\n\t\tif strings.HasPrefix(trimmedLine, strings.Repeat(\"#\", i)+\" \") {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}5bf97af to
270c4b3
Compare
Summary
## Intermediary updatessection from request payload strings before forwarding upstream.## Final answer instructions.instructions.Why
Some Codex Desktop prompts can include intermediary-update instructions that are useful for local UX but can affect high-stakes upstream requests. Removing that section before forwarding keeps the prompt focused on the task and final-answer contract.
Validation
go test ./internal/runtime/executor -run 'TestStripCodexIntermediaryUpdates|TestCodex'\n