mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
Add session forking to codex exec (#37367)
## What changed - Add `codex exec fork <SESSION_ID> [PROMPT]` for creating a new thread from an existing session ID or thread name. - Allow creating the fork without starting a turn, or immediately continue it with a prompt and optional images. - Preserve the source thread ID in the emitted session configuration while leaving the source session unchanged. ## Testing - Add CLI parsing coverage and an end-to-end test for promptless and prompted forks, thread naming, copied history, and unsupported promptless options. GitOrigin-RevId: b8f28b238a1526cc486c5beb886a63f68b8e7986
This commit is contained in:
@@ -61,6 +61,30 @@ fn resume_accepts_output_flags_after_subcommand() {
|
||||
assert_eq!(args.prompt.as_deref(), Some(PROMPT));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fork_parses_prompt_after_global_flags() {
|
||||
const PROMPT: &str = "continue on the fork";
|
||||
let cli = Cli::parse_from([
|
||||
"codex-exec",
|
||||
"fork",
|
||||
"session-123",
|
||||
"--json",
|
||||
"--model",
|
||||
"gpt-5.2-codex",
|
||||
"--skip-git-repo-check",
|
||||
"--ephemeral",
|
||||
PROMPT,
|
||||
]);
|
||||
|
||||
assert!(cli.json);
|
||||
assert!(cli.ephemeral);
|
||||
let Some(Command::Fork(args)) = cli.command else {
|
||||
panic!("expected fork command");
|
||||
};
|
||||
assert_eq!(args.session_id, "session-123");
|
||||
assert_eq!(args.prompt.as_deref(), Some(PROMPT));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_config_isolation_flags() {
|
||||
let cli = Cli::parse_from([
|
||||
|
||||
Reference in New Issue
Block a user