mini-coder 0.0.7 → 0.0.9

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.
@@ -0,0 +1,76 @@
1
+ # Codex Autonomy Issues & Fix Analysis
2
+
3
+ ## Behaviours
4
+ When using `zen/gpt-5.3-codex` as the agent, the model consistently exhibits "lazy" or permission-seeking behaviour. Specifically:
5
+ 1. **Initial Compliance**: It starts by reading files or globbing the directory.
6
+ 2. **Immediate Stall**: Instead of executing edits or implementing the plan, it outputs a multi-paragraph text explaining what it *plans* to do and ends the turn.
7
+ 3. **Permission Seeking**: It explicitly asks the user for permission (e.g., "Reply **'proceed'** and I'll start implementing batch 1").
8
+ 4. **Ralph Mode Incompatibility**: In `/ralph` mode, the agent loops continuously. Because it restarts with a fresh context on each loop and stalls after gathering context, it never actually writes any files. It just loops through the same read-and-plan phase until it hits the max iteration limit.
9
+ 5. **Model Differences**: Both Claude and Gemini models do not exhibit this behaviour. They are not subjected to the same conversational RLHF that pushes the model to ask the user to double check its work.
10
+
11
+ ## Root Cause Analysis
12
+ An analysis of both OpenAI's open-source `codex-rs` client and `opencode` source code reveals that Codex models (like `gpt-5.3-codex`) are highly RLHF-tuned for safety and collaborative pair-programming. By default, the model prefers to break tasks into chunks and explicitly ask for sign-off.
13
+
14
+ To override this, the model requires three things which `mini-coder` was failing to provide correctly:
15
+
16
+ ### 1. Dual-Anchored System Prompts (`system` + `instructions`)
17
+ `mini-coder` implemented a check `useInstructions` that placed the system prompt into the `instructions` field of the `/v1/responses` API payload. However, doing so stripped the `system` role message from the conversation context (`input` array).
18
+
19
+ By looking at `opencode` and `codex-rs`, they both ensure that the context array *also* contains the system prompt:
20
+ - `opencode` maps its environment variables and system instructions to `role: "system"` (or `role: "developer"`) inside `input.messages`, **while also** passing behavioral instructions to the `instructions` field in the API payload.
21
+ - `codex-rs` directly injects `role: "developer"` into the message list (as seen in `codex-rs/core/src/compact.rs` and their memory tracing implementations).
22
+
23
+ Without the `system` / `developer` message anchored at the start of the `input` array, the AI SDK and the model deprioritized the standalone `instructions` field, allowing the model's base permission-seeking behaviors to take over.
24
+
25
+ ### 2. Explicit "Do Not Ask" Directives
26
+ Both `opencode` and `codex-rs` employ heavy anti-permission prompts.
27
+ - **Opencode** (`session/prompt/codex_header.txt`):
28
+ > "- Default: do the work without asking questions... Never ask permission questions like 'Should I proceed?' or 'Do you want me to run tests?'; proceed with the most reasonable option and mention what you did."
29
+ - **Codex-RS** (`core/templates/model_instructions/gpt-5.2-codex_instructions_template.md`):
30
+ > "Persist until the task is fully handled end-to-end within the current turn whenever feasible: do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you."
31
+
32
+ `mini-coder` introduced `CODEX_AUTONOMY` in a previous commit, but because of Issue #1, it was never adequately anchored in the `input` array.
33
+
34
+ ## Evidence & Tests
35
+ We introduced a fetch wrapper interceptor in `src/llm-api/providers.ts` that logs the full outbound API requests to `~/.config/mini-coder/api.log`.
36
+
37
+ A test script `test-turn.ts` running a dummy turn showed the exact payload generated by the AI SDK before our fix:
38
+ ```json
39
+ "body": {
40
+ "model": "gpt-5.3-codex",
41
+ "input": [
42
+ {
43
+ "role": "user",
44
+ "content": [
45
+ { "type": "input_text", "text": "hello" }
46
+ ]
47
+ }
48
+ ],
49
+ "store": false,
50
+ "instructions": "You are a test agent.",
51
+ ...
52
+ ```
53
+ ```json
54
+ "body": {
55
+ "model": "gpt-5.3-codex",
56
+ "input": [
57
+ {
58
+ "role": "developer",
59
+ "content": "You are mini-coder, a small and fast CLI coding agent... [CODEX_AUTONOMY directives]"
60
+ },
61
+ {
62
+ "role": "user",
63
+ "content": [
64
+ { "type": "input_text", "text": "hello" }
65
+ ]
66
+ }
67
+ ],
68
+ "instructions": "You are mini-coder, a small and fast CLI coding agent... [CODEX_AUTONOMY directives]"
69
+ }
70
+ ```
71
+ This perfectly mirrors the behavior seen in `opencode` and `codex-rs`.
72
+
73
+ ## Actions Taken
74
+ 1. Added an `api.log` request interceptor in `providers.ts` to capture and inspect the exact JSON payloads sent to the OpenAI/AI SDK endpoints.
75
+ 2. Cloned and analyzed both `opencode` and `codex` repos to observe how they communicate with `gpt-5.*` codex endpoints.
76
+ 3. Updated `src/llm-api/turn.ts` so `system: systemPrompt` is *always* passed to the AI SDK, guaranteeing a `developer` message anchors the `input` array, even when `instructions` is also used.