feat(assistant): instruct agent to fence tables and fixed-width content for Discord#9
Merged
Conversation
…nt for Discord Discord's markdown renderer doesn't handle native tables — unwrapped tabular output (`| col1 | col2 |` rows) displays as raw text instead of an aligned grid. Same problem for ASCII art, tree output, and any aligned-column content. Add a one-line guideline to the assistant's system prompt telling the model to wrap such content in triple-backtick fences. Cheap, reliable, and applies to every assistant response without per-message overhead. Note: this only covers the `Assistant` (the bot's concierge thread). Per- session prompts to coding agents in their own session threads still need the same instruction — out of scope here, can ship as a separate change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0xmrpeter
approved these changes
May 9, 2026
0xmrpeter
left a comment
Contributor
There was a problem hiding this comment.
Clean, well-scoped fix for a real Discord rendering issue. The LLM-instruction approach is the right call — the model knows when it's producing tabular content better than any regex heuristic could, and it handles tree output / aligned text naturally. The inline rationale in the prompt is good prompt engineering.
One thing to track separately: per-session agent prompts (owned by Claude Code) aren't covered here. Worth opening an issue to revisit once the assistant-side fix is validated.
LGTM — merge after manual smoke test.
4 tasks
kevin-david
added a commit
to kevin-david/discord-adapter
that referenced
this pull request
May 9, 2026
The agent (Claude Code, etc.) running in a per-session thread doesn't see the assistant's system prompt, so a separate injection point is needed to give it the same Discord-rendering guidance: wrap tables, ASCII art, tree output, and aligned/fixed-column text in triple-backtick fences (Discord's markdown renderer doesn't handle native tables). Prepend a one-time '[Discord rendering note: ...]' to the user's first message of any new Discord session (gated by promptCount === 0 so lazy-resumed sessions don't re-prepend mid-conversation). Counterpart to Open-ACP#9, which covered the assistant session. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Discord's markdown renderer doesn't handle native tables — unwrapped tabular output (
| col1 | col2 |rows) displays as raw text instead of an aligned grid. Same problem for ASCII art, tree output, and any aligned-column content.What changes
One-line addition to the assistant's system prompt (
src/assistant.ts) instructing the model to wrap tables / ASCII art / tree output / aligned-column text in triple-backtick fences.Why an LLM instruction (not adapter-side detection)
Tables and fixed-width content are intent-laden — the model knows when it's making one. A targeted instruction in the system prompt is reliable and free; adapter-side regex detection works for markdown tables but breaks on tree output, aligned text, and is fragile mid-stream when text arrives as deltas.
Scope
Only the assistant session (the bot's concierge thread). Per-session prompts to coding agents in their own session threads aren't covered — a separate, slightly different injection point would be needed for those (the agent's system prompt is owned by Claude Code, not us).
Test plan
```fences🤖 Generated with Claude Code