Repository navigation
fix(prompt): keep code fences on their own lines - #22614
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that dropping the worked [DESIGN-REVIEWED] cefbc31 Description read[DESCRIPTION-READ] b9087eeb2c2e092d66ea2c09551374ef64fa3aab0859b3796cd5d6025c54f64a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check whether removing the six-line example diff from Not justified as shipped
What this change shipsInventory (4 items) — 3 justifiedIntent: get models to keep code fences on their own lines, so a reply's summary no longer disappears inside a diff block. FIX (it adds a prompt instruction that complements the render-time recovery from #18405).
[FIRST-PRINCIPLES-REVIEWED] cefbc31 Description read[DESCRIPTION-READ] 4f9ff5c8cc7a356742a6594d642bce7716210d5a7af09321fe38c4a6be175808 That sha256 names the PR description this verdict read. Recompute it with |
|
note (non-blocking): "Answer first, diffs after" is a deliberate change to output order The order rule is intended. In the reply that #18405 fixed, the summary came after a diff block whose closing fence was glued to it, so the summary was the text that went missing. If the answer comes before any diff, a malformed diff fence can only swallow the diff blocks after it, not the answer. The dashboard rule already says built-in edits render as diff cards and should not be repeated, so on the dashboard this rule only covers shell-made changes. You're right that nothing here measures whether glued fences become less common. The tests pin the delivered text, and the PR body says they can't show model behaviour. The render-time recovery from #18405 stays in place either way, so the prompt change is extra protection, and the renderer doesn't depend on it. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
note: E2E (stub ACP backend, offline) at 778b9cd is the known gateway-stall flake The job failed with "the gateway exited with -14 after 878s; stopped Playwright instead of letting its retries replay against it". Exit -14 is the loop-stall alarm killing the E2E gateway, the failure tracked in #18632 and #22314. This PR changes only prompt and rule text: |
|
issue (non-blocking): "Answer first, diffs after" reorders every reply outside the Goal Outcome: fixed in cefbc31 by deleting the sentence from |
778b9cd to
cefbc31
Compare
|
issue (non-blocking): the shorter diff wording drops emphasis from the channel rule for a 10 to 12 byte saving Outcome: fixed in cefbc31. |
|
note (non-blocking): dropping the worked Kept as is. A minimal-context run still gets main's format sentence word for word: unified diff with |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (5 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the output rules now say every code fence stands on its own line with a blank line after it, so a widget tag is not glued to a closing fence; golden test hashes and sizes updated to match.
Problem / Motivation
Goal: Models are told to keep code fences on their own lines, so fewer replies hide their summary inside a diff chip.
A closing fence glued to prose, such as
```**Summary**, makes the renderer treat the rest of the reply as code. #18405 recovers from this at render time. This PR adds the matching instruction at write time.Why it matters
The render-time recovery only fixes a fence the parser can recognise as glued. Asking for well-formed fences up front reduces how often the parser has to guess.
Not a goal
What changed (motivation → approach → change)
context_assembly/output_contract.pygains one constant,_FENCE_RULE: "Each opening and closing ``` stands alone on its line, and a blank line follows a closing fence." It is appended to both_DIFF_RULE_DASHBOARDand `_DIFF_RULE_CHANNEL`. Their existing wording is unchanged.config/prompt.md's Output Format section states the same sentence. To keepprompt.mdunder its 41385-byte ceiling intest_prompt_compact_contract.pywithout raising it, the six-line example diff block above it is removed; the format sentence before it already names the headers, the hunk and/dev/null. The file goes from 38364 to 38360 bytes.The widget skill gains one line saying
<mcwidget>goes on its own line after a blank line, never glued to a closing fence.The sentence is in both prompt.md and the critical rules on purpose. A minimal-context run gets prompt.md but returns before the critical rules are appended, and a custom agent gets the critical rules without prompt.md. A code comment above
_FENCE_RULErecords this.Backwards compatibility
Compatible: the diff requirement and its wording on each surface are unchanged; each surface gains one sentence.
Removes nothing: no setting, key, export or stored data is removed or renamed.
Tests
test/test_context_composition_contract.pyre-pins thecritical_rulesandcritical_rules_channelsha256 entries. The_GOLDENscenario hashes are unchanged.test/test_memory_v1_golden.pyupdates the[CRITICAL RULESextent from 3192 to 3289 andEXPECTED_TOTALfrom 6788 to 6885.scripts/run_scoped_tests.py --surface backendpasses, 1067 tests, including the prompt byte ceiling.Manual verification
N/A. The change is prompt text; the tests pin the delivered bytes. They cannot show how often models now keep fences on their own lines.
Screenshots / video
Why no screenshot: no UI code changes; only prompt and rule text sent to the model changes.
Related Issues
Fixes #22613
Follows #18405.
Pattern harvest
Rule candidate: none
Pattern: a rule that must reach every session needs a copy on each delivery path. I checked
src/kiro_crew/context_assemblyandsrc/kiro_crew/config/prompt.md: the critical rules and prompt.md are the two paths, and both now carry the sentence.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.