codexapi 0.5.0__tar.gz → 0.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codexapi
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Minimal Python API for running the Codex CLI.
5
5
  License: MIT
6
6
  Keywords: codex,agent,cli,openai
@@ -93,10 +93,12 @@ Use `--no-yolo` to run Codex with `--full-auto` instead.
93
93
  Ralph loop mode repeats the same prompt until a completion promise or a max
94
94
  iteration cap is hit (0 means unlimited). Cancel by deleting
95
95
  `.codexapi/ralph-loop.local.md` or running `codexapi ralph --cancel`.
96
+ By default each iteration starts with a fresh Agent context; use
97
+ `--ralph-reuse` to keep a single shared context across iterations.
96
98
 
97
99
  ```bash
98
100
  codexapi ralph "Fix the bug." --completion-promise DONE --max-iterations 5
99
- codexapi ralph --ralph-fresh "Try again from scratch." --max-iterations 3
101
+ codexapi ralph --ralph-reuse "Try again from the same context." --max-iterations 3
100
102
  codexapi ralph --cancel --cwd /path/to/project
101
103
  ```
102
104
 
@@ -79,10 +79,12 @@ Use `--no-yolo` to run Codex with `--full-auto` instead.
79
79
  Ralph loop mode repeats the same prompt until a completion promise or a max
80
80
  iteration cap is hit (0 means unlimited). Cancel by deleting
81
81
  `.codexapi/ralph-loop.local.md` or running `codexapi ralph --cancel`.
82
+ By default each iteration starts with a fresh Agent context; use
83
+ `--ralph-reuse` to keep a single shared context across iterations.
82
84
 
83
85
  ```bash
84
86
  codexapi ralph "Fix the bug." --completion-promise DONE --max-iterations 5
85
- codexapi ralph --ralph-fresh "Try again from scratch." --max-iterations 3
87
+ codexapi ralph --ralph-reuse "Try again from the same context." --max-iterations 3
86
88
  codexapi ralph --cancel --cwd /path/to/project
87
89
  ```
88
90
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "codexapi"
7
- version = "0.5.0"
7
+ version = "0.5.1"
8
8
  description = "Minimal Python API for running the Codex CLI."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -15,4 +15,4 @@ __all__ = [
15
15
  "task",
16
16
  "task_result",
17
17
  ]
18
- __version__ = "0.5.0"
18
+ __version__ = "0.5.1"
@@ -920,8 +920,8 @@ def main(argv=None):
920
920
  " --completion-promise after trimming/collapsing whitespace. CRITICAL RULE:\n"
921
921
  " Only output the promise when it is completely and unequivocally TRUE.\n"
922
922
  " Cancel by deleting .codexapi/ralph-loop.local.md or running codexapi ralph --cancel.\n"
923
- " Default reuses a single Codex thread; use --ralph-fresh for a new Agent\n"
924
- " each iteration (no shared context).\n"
923
+ " Default starts each iteration with a fresh Agent context; use --ralph-reuse\n"
924
+ " to reuse a single Codex thread across iterations.\n"
925
925
  )
926
926
  parser = argparse.ArgumentParser(
927
927
  prog="codexapi",
@@ -1026,10 +1026,20 @@ def main(argv=None):
1026
1026
  "--completion-promise",
1027
1027
  help="Promise text to match in <promise>...</promise>.",
1028
1028
  )
1029
- ralph_parser.add_argument(
1029
+ ralph_fresh_group = ralph_parser.add_mutually_exclusive_group()
1030
+ ralph_fresh_group.add_argument(
1030
1031
  "--ralph-fresh",
1031
1032
  action="store_true",
1032
- help="Start each iteration with a fresh Agent context.",
1033
+ dest="ralph_fresh",
1034
+ default=None,
1035
+ help="Start each iteration with a fresh Agent context (default).",
1036
+ )
1037
+ ralph_fresh_group.add_argument(
1038
+ "--ralph-reuse",
1039
+ action="store_false",
1040
+ dest="ralph_fresh",
1041
+ default=None,
1042
+ help="Reuse the same Agent context each iteration.",
1033
1043
  )
1034
1044
  ralph_parser.add_argument("--cwd", help="Working directory for the Codex session.")
1035
1045
  ralph_parser.add_argument(
@@ -1104,12 +1114,16 @@ def main(argv=None):
1104
1114
  if args.cancel:
1105
1115
  if args.prompt:
1106
1116
  raise SystemExit("ralph --cancel takes no prompt.")
1107
- if args.completion_promise or args.ralph_fresh:
1108
- raise SystemExit("--completion-promise/--ralph-fresh are not allowed with --cancel.")
1117
+ if args.completion_promise or args.ralph_fresh is not None:
1118
+ raise SystemExit(
1119
+ "--completion-promise/--ralph-fresh/--ralph-reuse are not allowed with --cancel."
1120
+ )
1109
1121
  if args.max_iterations != 0:
1110
1122
  raise SystemExit("--max-iterations is not allowed with --cancel.")
1111
1123
  print(cancel_ralph_loop(args.cwd))
1112
1124
  return
1125
+ if args.ralph_fresh is None:
1126
+ args.ralph_fresh = True
1113
1127
 
1114
1128
  if args.command == "task" and args.task_file:
1115
1129
  if args.prompt:
@@ -19,7 +19,7 @@ def run_ralph_loop(
19
19
  flags=None,
20
20
  max_iterations=0,
21
21
  completion_promise=None,
22
- fresh=False,
22
+ fresh=True,
23
23
  ):
24
24
  """Run a Ralph Wiggum-style loop that repeats the same prompt.
25
25
 
@@ -37,8 +37,8 @@ def run_ralph_loop(
37
37
  may ONLY output it when the statement is completely and unequivocally TRUE.
38
38
  Do not output false promises to escape the loop.
39
39
 
40
- By default a single Agent instance is reused for shared context. Set
41
- `fresh=True` to create a new Agent each iteration for a clean context.
40
+ By default each iteration uses a fresh Agent for a clean context. Set
41
+ `fresh=False` to reuse a single Agent instance for shared context.
42
42
  Cancel by deleting the state file or running `codexapi ralph --cancel`.
43
43
  """
44
44
  if not isinstance(prompt, str) or not prompt.strip():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codexapi
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Minimal Python API for running the Codex CLI.
5
5
  License: MIT
6
6
  Keywords: codex,agent,cli,openai
@@ -93,10 +93,12 @@ Use `--no-yolo` to run Codex with `--full-auto` instead.
93
93
  Ralph loop mode repeats the same prompt until a completion promise or a max
94
94
  iteration cap is hit (0 means unlimited). Cancel by deleting
95
95
  `.codexapi/ralph-loop.local.md` or running `codexapi ralph --cancel`.
96
+ By default each iteration starts with a fresh Agent context; use
97
+ `--ralph-reuse` to keep a single shared context across iterations.
96
98
 
97
99
  ```bash
98
100
  codexapi ralph "Fix the bug." --completion-promise DONE --max-iterations 5
99
- codexapi ralph --ralph-fresh "Try again from scratch." --max-iterations 3
101
+ codexapi ralph --ralph-reuse "Try again from the same context." --max-iterations 3
100
102
  codexapi ralph --cancel --cwd /path/to/project
101
103
  ```
102
104
 
File without changes
File without changes
File without changes
File without changes