tfrere HF Staff Cursor commited on
Commit
e8173b7
·
1 Parent(s): 7814104

fix(agent): forbid re-pasting tool output in the text reply

Browse files

After calling \`createEmbed\` / \`patchEmbed\` (embed chat) or
\`insertAtCursor\` / \`applyDiff\` (main chat), the model would
re-emit the just-inserted code/prose verbatim inside its text
reply. The chart is already live in the preview pane and the
doc is already updated, so the dump is pure noise - it pollutes
the chat history, looks like a "did it stream?" stall to the
user (the long reply only appears once the full text is buffered
on the client), and bloats the next turn's context window.

Tighten both prompts:

- embed-system-prompt: new "Reply format (STRICT)" section.
Caps the reply at 1-2 sentences, explicitly forbids fenced
code blocks of the chart source, bullet "feature" lists and
phrases like "Voici le code" / "Just paste this where you
want the banner". Keeps an escape hatch for "show me the
code" requests (short relevant snippet only).
- system-prompt: extend the anti-patterns list with a "NEVER
paste the content you just inserted/replaced back into your
text reply" rule, with examples of the kind of one-line
summary expected instead.

Co-authored-by: Cursor <cursoragent@cursor.com>

backend/src/agent/embed-system-prompt.ts CHANGED
@@ -186,7 +186,32 @@ NEVER hardcode categorical palettes - always go through
186
  readDataFile on the best match, and inline a parsed subset into the chart.
187
  Never fabricate column names - only use what the file actually contains.
188
  5. **Be creative with design.** Make charts visually appealing with clean typography, proper spacing, and smooth transitions.
189
- 6. **Keep it concise.** Don't explain what you're doing unless asked.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
  ## Context
192
 
 
186
  readDataFile on the best match, and inline a parsed subset into the chart.
187
  Never fabricate column names - only use what the file actually contains.
188
  5. **Be creative with design.** Make charts visually appealing with clean typography, proper spacing, and smooth transitions.
189
+
190
+ ## Reply format (STRICT)
191
+
192
+ After your tool calls run, you reply with **one or two sentences max**,
193
+ describing only what changed (NOT how). The chart is already live in
194
+ the preview pane next to the chat - the user sees the result, they
195
+ don't need to read its source.
196
+
197
+ **FORBIDDEN in the text reply:**
198
+ - The full HTML / CSS / JS of the chart (you just sent it via
199
+ \`createEmbed\` or \`patchEmbed\`, repeating it is pure noise).
200
+ - Any \`<div>\`, \`<style>\`, \`<script>\` blocks or fenced code blocks
201
+ containing the chart source.
202
+ - Bullet lists of "features" / "responsive ✓" / "theme-aware ✓" -
203
+ these are baked into your guidelines, not user-facing news.
204
+ - Phrases like "Here is the code:", "Just paste this where you want
205
+ the banner", "Voici le code", "Il suffit de placer ce code".
206
+
207
+ **Good replies** (pick one tone, match the user's language):
208
+ - "Done - particle field with reduced-motion fallback."
209
+ - "Switched to a sequential palette and bumped the bar gap."
210
+ - "Refait avec un flow field plus subtil."
211
+
212
+ If the user explicitly asks "show me the code" / "explique le code",
213
+ then you can quote a short snippet - but only the relevant block,
214
+ never the whole file.
215
 
216
  ## Context
217
 
backend/src/agent/system-prompt.ts CHANGED
@@ -135,6 +135,12 @@ staying in a tool-call loop without emitting text looks broken to the user.
135
  - NEVER call \`toggleBold\` right after \`insertAtCursor\` or \`applyDiff\` - the selection is gone.
136
  - NEVER guess Tiptap positions - use \`selectText\` with text content instead.
137
  - NEVER end a turn with only tool calls - always conclude with a one-line text reply.
 
 
 
 
 
 
138
 
139
  ## Guidelines
140
 
 
135
  - NEVER call \`toggleBold\` right after \`insertAtCursor\` or \`applyDiff\` - the selection is gone.
136
  - NEVER guess Tiptap positions - use \`selectText\` with text content instead.
137
  - NEVER end a turn with only tool calls - always conclude with a one-line text reply.
138
+ - NEVER paste the content you just inserted/replaced back into your text
139
+ reply. The doc is already updated and visible to the user; restating
140
+ the new paragraph as a markdown block is pure noise. Reply with a
141
+ one-line summary of what changed ("rephrased the abstract for
142
+ clarity", "moved the methods section above results"), not the new
143
+ prose itself.
144
 
145
  ## Guidelines
146