Skip to content

Apply workspace instructions to rewrites and summaries - #11

Merged
malpou merged 3 commits into
mainfrom
feat/ai-writing-rules
Nov 3, 2026
Merged

malpou merged 3 commits into
mainfrom
feat/ai-writing-rules

Conversation

@malpou

@malpou malpou commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

What

  • Adds the workspace instructions field to rewrites and summaries. It already reached reply drafts and copilot. Tag suggestions stay without it, because that prompt must return only JSON. Customer-facing assistants keep their own per-assistant instructions.
  • Tells the rewrite framing to keep the language of the draft and to use only facts from the draft.
  • Returns an error when a reply hits max_tokens. The client ignored finish_reason, so a cut-off reply came back as a normal result.

Testing

TestAppendInstructions covers the prompt assembly. TestChatCompletionRejectsTruncatedReply fails with the check removed. go test ./internal/ai ./internal/aiagent passes.

A live run against Sonnet 5.5 with synthetic Danish text covered all six rewrites, a summary and a reply draft with tools. With max_tokens=1024, a 4416 character draft was cut off at 2033 characters. With 4096 it came back whole. That run predates the finish_reason check, and it did not confirm what finish_reason Sonnet 5.5 returns at the limit through the OpenAI-compatible endpoint.

The instructions field reached reply drafts and copilot, but not the
rewrite actions or conversation summaries, so a style rule stored there
applied to some AI text and not the rest.

Tag suggestions stay without them: that prompt must return only JSON.

Tell the rewrite prompt to keep the draft's language and to add no facts.
The framing had neither rule.
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request in Libredesk.

Please give CONTRIBUTING.md a read if you haven't already, it covers the setup, code style and the checks this PR needs to pass. A maintainer will review this soon.

The client ignored finish_reason, so a reply cut off at the limit came
back as a normal result. A long rewrite then replaced the agent's draft
with text that stopped in the middle of a link.

Treat finish_reason "length" as an error and tell the agent to raise Max
tokens or shorten the text.
@malpou
malpou marked this pull request as ready for review November 3, 2026 16:48
@malpou
malpou merged commit 01744e0 into main Nov 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant