Skip to content

Conversation

@katia-openai
Copy link
Collaborator

No description provided.

@katia-openai katia-openai merged commit 625edfe into main Nov 13, 2025
1 check passed
@katia-openai katia-openai deleted the katia/add-coding-agent-cookbook branch November 13, 2025 18:34
Copy link

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

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.

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +878 to +920
"def apply_unified_diff(original: str, diff: str, create: bool = False) -> str:\n",
" \"\"\"\n",
" Simple \"diff\" applier (adapt this based on your environment)\n",
"\n",
" - For create_file, the diff can be the full desired file contents,\n",
" optionally with leading '+' on each line.\n",
" - For update_file, we treat the diff as the new file contents:\n",
" keep lines starting with ' ' or '+', drop '-' lines and diff headers.\n",
"\n",
" This avoids context/delete mismatch errors while still letting the model\n",
" send familiar diff-like patches.\n",
" \"\"\"\n",
" if not diff:\n",
" return original\n",
"\n",
" lines = diff.splitlines()\n",
" body: list[str] = []\n",
"\n",
" for line in lines:\n",
" if not line:\n",
" body.append(\"\")\n",
" continue\n",
"\n",
" # Skip typical unified diff headers / metadata\n",
" if line.startswith(\"@@\") or line.startswith(\"---\") or line.startswith(\"+++\"):\n",
" continue\n",
"\n",
" prefix = line[0]\n",
" content = line[1:]\n",
"\n",
" if prefix in (\"+\", \" \"):\n",
" body.append(content)\n",
" elif prefix in (\"-\", \"\\\\\"):\n",
" # skip deletions and \"\\ No newline at end of file\"\n",
" continue\n",
" else:\n",
" # If it doesn't look like diff syntax, keep the full line\n",
" body.append(line)\n",
"\n",
" text = \"\\n\".join(body)\n",
" if diff.endswith(\"\\n\"):\n",
" text += \"\\n\"\n",
" return text\n",

Choose a reason for hiding this comment

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

P1 Badge Fix apply_patch diff application

The apply_unified_diff helper (lines 878‑920 of examples/Build_a_coding_agent_with_GPT-5.1.ipynb) ignores the existing file contents and simply concatenates the lines that appear in the diff hunk. Standard unified diffs only include the modified region plus a little context, so when the agent issues an update_file operation, the resulting file is replaced with just that tiny hunk and every other line disappears. Running the second half of the tutorial will therefore corrupt any non‑trivial file as soon as apply_patch is used. The patch function needs to actually apply the diff against original (or require the model to send the full file contents) instead of discarding all untouched lines.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants