Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Use a virtual environment to isolate dependencies:
- `python .github/scripts/check_notebooks.py` to validate notebook structure before pushing

## Coding Style & Naming Conventions
Write Python to PEP 8 with four-space indentation, descriptive variable names, and concise docstrings that explain API usage choices. Name new notebooks with lowercase, dash-or-underscore-separated phrases that match their directory—for example `examples/gpt-5/prompt-optimization-cookbook.ipynb`. Keep markdown cells focused and prefer numbered steps for multi-part workflows. Store secrets in environment variables such as `OPENAI_API_KEY`; never hard-code keys inside notebooks.
Write Python to PEP 8 with four-space indentation, descriptive variable names, and concise docstrings that explain API usage choices. Name new notebooks with lowercase, dash-or-underscore-separated phrases that match their directory—for example `examples/prompting/prompt-optimization-cookbook.ipynb`. Keep markdown cells focused and prefer numbered steps for multi-part workflows. Store secrets in environment variables such as `OPENAI_API_KEY`; never hard-code keys inside notebooks.

## Testing Guidelines
Execute notebooks top-to-bottom after installing dependencies and clear lingering execution counts before committing. For Python modules or utilities, include self-check cells or lightweight `pytest` snippets and show how to run them (for example, `pytest examples/object_oriented_agentic_approach/tests`). When contributions depend on external services, mock responses or gate the cells behind clearly labeled opt-in flags.
Expand Down
29 changes: 26 additions & 3 deletions authors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# You can optionally customize how your information shows up cookbook.openai.com over here.
# If your information is not present here, it will be pulled from your GitHub profile.

joanneshin-openai:
name: "Joanne Shin"
website: "https://www.linkedin.com/in/jeongminshin"
avatar: "https://avatars.githubusercontent.com/u/206945323?v=4"

daveleo-openai:
name: "Dave Leo"
website: "https://www.linkedin.com/in/davidanthonyleo/"
Expand Down Expand Up @@ -493,10 +498,28 @@ heejingithub:
website: "https://www.linkedin.com/in/heejc/"
avatar: "https://avatars.githubusercontent.com/u/169293861"


himadri:
himadri518:
name: "Himadri Acharya"
website: "https://www.linkedin.com/in/himadri-acharya-086ba261/"
avatar: "https://avatars.githubusercontent.com/u/14100684?v=4"


neelk-oai:
name: "Neel Kapse"
website: "https://www.linkedin.com/in/neel-kapse/"
avatar: "https://media.licdn.com/dms/image/v2/D4E03AQEegSR4W4Ylmg/profile-displayphoto-scale_400_400/B4EZkLjdrcIQAk-/0/1756835470622?e=1762387200&v=beta&t=HETTFnoh3nV_Yc84tHGkahKgOFdvnPlesfi3ki8mWFg"

hamel:
name: "Hamel Husain"
website: "https://www.linkedin.com/in/hamelhusain/"
avatar: "https://media.licdn.com/dms/image/v2/C5603AQGoyHYtA2QIXw/profile-displayphoto-shrink_400_400/profile-displayphoto-shrink_400_400/0/1572471557655?e=1762387200&v=beta&t=wZrq-Nfc8-4Xq-nJ5g2jt9gZ1KLTg23KOIBGHk2xkZ0"

jhall-openai:
name: "Josh Hall"
website: "https://www.linkedin.com/in/jhall14/"
avatar: "https://avatars.githubusercontent.com/u/198997750?v=4"

charlie-openai:
name: "Charlie Weems"
website: "https://wee.ms"
avatar: "https://avatars.githubusercontent.com/u/181146176?v=4"

65 changes: 21 additions & 44 deletions examples/codex/Autofix-github-actions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "e2884696",
"metadata": {},
"source": [
"# Autofix CI failures on GitHub with Codex-cli\n",
"# Autofix CI failures on GitHub with Codex CLI\n",
"\n",
"## Purpose of this cookbook\n",
"\n",
Expand All @@ -15,7 +15,8 @@
"\n",
"Below is the pipeline flow we’ll implement:\n",
"\n",
"![](images/ci-codex-workflow.png)"
"\n",
"<img src=\"../../images/ci-codex-workflow.png\" width=\"700\"/>"
]
},
{
Expand All @@ -33,7 +34,8 @@
"\n",
"- You’ll need to check the setting to enable actions to create PRs on your repo, and also in your organization:\n",
"\n",
"![](images/github-pr-settings.png)"
"\n",
"<img src=\"../../images/github-pr-settings.png\" width=\"700\"/>\n"
]
},
{
Expand All @@ -42,7 +44,7 @@
"metadata": {},
"source": [
"\n",
"## Step 3: Insert Codex in your CI pipeline\n",
"## Step 1: Add the Github Action to your CI Pipeline\n",
"\n",
"The following YAML shows a GitHub action that auto triggers when CI fails, installs Codex, uses codex exec and then makes a PR on the failing branch with the fix. Replace \"CI\" with the name of the workflow you want to monitor. "
]
Expand All @@ -53,7 +55,6 @@
"metadata": {},
"source": [
"```yaml\n",
"\n",
"name: Codex Auto-Fix on Failure\n",
"\n",
"on:\n",
Expand All @@ -78,14 +79,13 @@
" FAILED_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}\n",
" FAILED_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}\n",
" steps:\n",
" - name: Check prerequisites\n",
" - name: Check OpenAI API Key Set\n",
" run: |\n",
" if [ -z \"$OPENAI_API_KEY\" ]; then\n",
" echo \"OPENAI_API_KEY secret is not set. Skipping auto-fix.\" >&2\n",
" exit 1\n",
" fi\n",
"\n",
" - name: Checkout failing ref\n",
" - name: Checkout Failing Ref\n",
" uses: actions/checkout@v4\n",
" with:\n",
" ref: ${{ env.FAILED_HEAD_SHA }}\n",
Expand All @@ -100,34 +100,13 @@
" - name: Install dependencies\n",
" run: |\n",
" if [ -f package-lock.json ]; then npm ci; else npm i; fi\n",
"\n",
" - name: Prepare Codex prerequisites\n",
" shell: bash\n",
" run: |\n",
" # Ensure python3 exists for Codex' login helper\n",
" if ! command -v python3 >/dev/null 2>&1; then\n",
" sudo apt-get update\n",
" sudo apt-get install -y python3\n",
" fi\n",
"\n",
" # Ensure Codex config dir exists and is writable\n",
" mkdir -p \"$HOME/.codex\"\n",
" # (Optional) pin an explicit home for Codex config/logs\n",
" echo \"CODEX_HOME=$HOME/.codex\" >> $GITHUB_ENV\n",
"\n",
" - name: Install Codex CLI\n",
" run: npm i -g @openai/codex\n",
"\n",
" - name: Authenticate Codex (non-interactive)\n",
" env:\n",
" # if you set CODEX_HOME above, export it here too\n",
" CODEX_HOME: ${{ env.CODEX_HOME }}\n",
" OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n",
" run: codex login --api-key \"$OPENAI_API_KEY\"\n",
"\n",
" - name: Run Codex to fix CI failure\n",
" run: |\n",
" codex exec --full-auto --sandbox workspace-write \"You are working in a Node.js monorepo with Jest tests and GitHub Actions. Read the repository, run the test suite, identify the minimal change needed to make all tests pass, implement only that change, and stop. Do not refactor unrelated code or files. Keep changes small and surgical.\"\n",
" - name: Run Codex\n",
" uses: openai/codex-action@main\n",
" id: codex\n",
" with:\n",
" openai_api_key: ${{ secrets.OPENAI_API_KEY }}\n",
" prompt: \"You are working in a Node.js monorepo with Jest tests and GitHub Actions. Read the repository, run the test suite, identify the minimal change needed to make all tests pass, implement only that change, and stop. Do not refactor unrelated code or files. Keep changes small and surgical.\"\n",
" codex_args: '[\"--config\",\"sandbox_mode=\\\"workspace-write\\\"\"]'\n",
"\n",
" - name: Verify tests\n",
" run: npm test --silent\n",
Expand All @@ -142,10 +121,8 @@
" title: \"Auto-fix failing CI via Codex\"\n",
" body: |\n",
" Codex automatically generated this PR in response to a CI failure on workflow `${{ env.FAILED_WORKFLOW_NAME }}`.\n",
"\n",
" Failed run: ${{ env.FAILED_RUN_URL }}\n",
" Head branch: `${{ env.FAILED_HEAD_BRANCH }}`\n",
"\n",
" This PR contains minimal changes intended solely to make the CI pass.\n",
"```\n"
]
Expand All @@ -155,12 +132,11 @@
"id": "8148024b",
"metadata": {},
"source": [
"## Step 4: Actions Workflow kicked off\n",
"## Step 2: Actions Workflow kicked off\n",
"\n",
"You can navigate to the Actions tab under Repo to view the failing jobs in your Actions workflow. \n",
"\n",
"\n",
"![](images/failing-workflow.png)\n"
"<img src=\"../../images/failing-workflow.png\" width=\"700\"/>\n"
]
},
{
Expand All @@ -171,7 +147,7 @@
"The Codex workflow should be triggered upon completion of the failed workflow. \n",
"\n",
"\n",
"![](images/codex-workflow.png)\n",
"<img src=\"../../images/codex-workflow.png\" width=\"700\"/>\n",
"\n"
]
},
Expand All @@ -180,10 +156,11 @@
"id": "d08a3ecc",
"metadata": {},
"source": [
"## Step 5: Codex generated PR for review\n",
"## Step 3: Verify that Codex Created a PR for Review\n",
"And after the Codex workflow completes execution, it should open a pull request from the feature branch codex/auto-fix. Check to see if everything looks good and then merge it.\n",
"\n",
"![](images/codex-pr.png)"
"<img src=\"../../images/codex-pr.png\" width=\"700\"/>\n",
"\n"
]
},
{
Expand Down
Loading