From e39e0c4332042df49955b3da60d96a1d3bf5fd23 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Thu, 30 Oct 2025 21:33:47 +0000 Subject: [PATCH] Better prompt --- codex-rs/core/templates/compact/prompt.md | 74 +++++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/templates/compact/prompt.md b/codex-rs/core/templates/compact/prompt.md index 2390735ac7..3c58f1968a 100644 --- a/codex-rs/core/templates/compact/prompt.md +++ b/codex-rs/core/templates/compact/prompt.md @@ -1,6 +1,72 @@ -You have exceeded the maximum number of tokens. Stop coding and respond with a JSON object that has exactly these two string fields: +You are performing a CONTEXT CHECKPOINT COMPACTION for a tool. You must output a single valid JSON object with the following schema: -1. `intent_user_message` – Combine the user's intent and what they expect next into a single actionable user message you would send after compaction. -2. `summary` – Concisely capture the current status: what finished, what remains, outstanding TODOs with file paths / line numbers, missing tests, open bugs, quirks, setup steps, and (if present) the most recent update_plan steps verbatim. +{ +"type": "object", +"properties": { +"intent_user_message": { "type": "string" }, +"summary": { "type": "string" } +}, +"required": ["intent_user_message", "summary"], +"additionalProperties": false +} -Return only the JSON object. +STRICT OUTPUT RULES +- Output a single valid JSON object only (no Markdown, no fences, no commentary). +- Must parse with serde_json::from_str. +- UTF-8 only. +- Up to ~4000 tokens total. + +GOAL +Reconstruct the SINGLE ACTIVE TASK THREAD and all critical short-term context so the conversation can continue seamlessly after reset. + +ACTIVE TASK SELECTION +- Identify the task thread with in-progress work (code edits, plans, tests, IDs, env state). +- Do not switch tasks due to incidental questions. +- If uncertainty exists, include the candidate context and mark unknowns. + +OUTPUT FIELDS + +"intent_user_message" +A consolidated user-side directive for re-injection after reset, containing: + +1) Minimal machine-only context necessary to interpret the task + (paths, APIs, configs, constraints, design notes, etc.) + +2) The ORIGINAL user request that defined the active task, verbatim: + + ...original user text... + + +3) The most recent user messages relevant to continuing execution, + **including clarifications, corrections, follow-ups, parameter overrides, and sub-tasks**. + +Use this delimiter block for that (raw text, no quotes or escapes): + +...verbatim recent user messages (~2–6 turns or whatever is needed)... + + +Rules for both blocks: +- EXACT text. +- Put the start/end tags on their own lines without indentation. + +"summary" +A machine continuation context containing: + +- current status/phase +- authoritative excerpts (files, functions, diffs, snippets) +- internal state and intermediate values +- pending steps and design notes +- environment context (paths, branches, configs, run IDs) +- test state or execution buffer if relevant +- explicit unknowns as "UNKNOWN" +- brief note on non-active threads only if helpful +- final cursor line: + RESUME_AT: + +SELF-CHECK BEFORE EMITTING (do not output) +- Valid JSON object only? +- intent_user_message includes both blocks: + … + … +- Enough granular state to continue without prior messages? +- summary ends with a concrete RESUME_AT? \ No newline at end of file