Preserve current branch with Codex Remote Agent

Please remember that last selected branch of an Environment. Currently, when you refresh the page it defaults back to main. If you are not paying attention, you can think you are sending the task on the branch you’ve been using.

Unfortunately, you have to refresh the page to get it to update correctly and accurately reflect current state.

I think I just ran into this. I was not aware that different tasks refer directly to a different branch. There was a bug in the “most recent” (to me) branch after making a pull request to GitHub. I went back to the task window I’d been working in, and asked about that commit (3 or 4 prior). It said it only had a shallow get of a couple of branches at a time, and the commit was not in its context. Your comment helps me understand why. While working on a DIFFERENT task, suddenly it found the bug while running a test. Same bug I’d found. “I thought you couldn’t see this?”

Thanks for your comment!

Yeah, it’s more a context visibility problem. Assuming the main branch has what you need, you can easily change the PR to target the branch you really intended. But, if the main branch doesn’t have the context to complete the task correctly, then you have to create another task.

Duplicate of: feature-request-maintain-branch-selection-for-new-tasks-in-codex-across-sessions/1286601/2

This would be very appreciated, have currently switched default repo branch to develop to help avoid this issue (it seems they implemented default branch detection).

Some GPT generated work arounds until this is properly implemented. I don’t really like either option, I’m still manually clicking the new repo, but maybe these will work for your team size / workflows?


Quick ways to make Codex open on your branch

Codex always starts in the repository’s default branch. Until an “open where I left off” feature lands, use one of the methods below to skip the manual branch switch.


1. Change the repo’s default branch

(fine for solo or very small teams)

  1. GitHub → Settings → General
  2. Under Default branch, choose the branch you actually work in
  3. Click Update

Every new Codex environment will now launch on that branch.
Caution: On a shared repo this may confuse teammates who expect main or master to remain the default.


2. Open Codex with a branch-specific URL

(safe for any team size)

Codex recognises a branch= flag in the query string.
Because the branch is applied only when the task composer opens, add an empty prompt= (or any task text) so the composer always loads:

https://chatgpt.com/codex?environment=<ENV_ID>
&branch=<your-branch-name>
&prompt=
  • Replace <ENV_ID> with your environment ID
  • Replace <your-branch-name> with the exact branch name
  • Optionally append &tab=archived (or any other parameters)

Bookmark or share that link and Codex will jump straight into the right branch without altering repository settings.

Just to note, the <ENV_ID> is the hexadecimal string from the URL that you will see, for example, when editing an environment.