Skip to content

feat(ambient): relax default prompt, sender UID, debug mode#1221

Merged
chaodu-agent merged 1 commit into
mainfrom
feat/ambient-custom-instructions
Jun 27, 2026
Merged

feat(ambient): relax default prompt, sender UID, debug mode#1221
chaodu-agent merged 1 commit into
mainfrom
feat/ambient-custom-instructions

Conversation

@chaodu-agent

@chaodu-agent chaodu-agent commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

What

  • Relax default prompt: bias toward engagement — reply when someone asks a question or needs help. Only [NO_REPLY] for purely social chatter.
  • @mention rule: bot always mentions the person it's responding to so they get notified.
  • Sender UID in transcript: batch messages now include Discord UID (format: Name (<@UID>): message) so the LLM can produce valid mentions.
  • Debug mode ([ambient] debug = true):
    • Posts system prompt + full transcript to channel on each flush
    • [NO_REPLY] responses are sent to channel instead of suppressed
    • Allows observing ambient behavior in real-time

Config

[ambient]
enabled = true
debug = true  # optional, default false

Changes

  • ambient.rs: Updated DEFAULT_AMBIENT_SYSTEM_INSTRUCTION, added sender_id to AmbientMessage, UID in transcript format, debug flush notifications, pass-through [NO_REPLY] in debug mode.
  • discord.rs: Pass msg.author.id when constructing AmbientMessage.
  • config.rs: Added debug: bool to AmbientConfig.

Backward compatibility

Default behavior unchanged (debug = false). The only behavioral change is the relaxed default prompt — bots will reply more often in ambient mode.

@chaodu-agent chaodu-agent requested a review from thepagent as a code owner June 27, 2026 15:18
@chaodu-agent

This comment has been minimized.

@chaodu-agent

This comment has been minimized.

@chaodu-agent

This comment has been minimized.

@chaodu-agent chaodu-agent force-pushed the feat/ambient-custom-instructions branch from a884cfe to 5305e65 Compare June 27, 2026 21:04
@chaodu-agent chaodu-agent changed the title feat(ambient): customizable [ambient] instructions feat(ambient): relax default prompt + sender UID in transcript Jun 27, 2026
@chaodu-agent

This comment has been minimized.

@chaodu-agent chaodu-agent force-pushed the feat/ambient-custom-instructions branch 3 times, most recently from 8d2241c to e90eceb Compare June 27, 2026 21:10
@chaodu-agent

This comment has been minimized.

@chaodu-agent chaodu-agent force-pushed the feat/ambient-custom-instructions branch from e90eceb to bd48218 Compare June 27, 2026 21:11
@chaodu-agent

This comment has been minimized.

@chaodu-agent chaodu-agent changed the title feat(ambient): relax default prompt + sender UID in transcript feat(ambient): relax default prompt, sender UID, debug mode Jun 27, 2026
@chaodu-agent chaodu-agent force-pushed the feat/ambient-custom-instructions branch from bd48218 to 85e88b8 Compare June 27, 2026 21:12
@chaodu-agent

This comment has been minimized.

@chaodu-agent chaodu-agent force-pushed the feat/ambient-custom-instructions branch from 85e88b8 to ef8a140 Compare June 27, 2026 21:13
@chaodu-agent

This comment has been minimized.

@chaodu-agent chaodu-agent force-pushed the feat/ambient-custom-instructions branch from ef8a140 to d185694 Compare June 27, 2026 21:14
@chaodu-agent

This comment has been minimized.

@chaodu-agent chaodu-agent force-pushed the feat/ambient-custom-instructions branch from d185694 to 5351065 Compare June 27, 2026 21:15
@chaodu-agent

This comment has been minimized.

…mode

- Relax DEFAULT_AMBIENT_SYSTEM_INSTRUCTION: bias toward engagement, only
  [NO_REPLY] for purely social chatter
- Add @mention rule: bot always mentions the person it's responding to
- Add sender_id to AmbientMessage, format transcript as:
  Name (<@uid>): message
- Add debug config: when [ambient] debug = true:
  - [NO_REPLY] responses are sent to the channel (not suppressed)
  - A system message is posted on each flush showing batch size and senders
- Add tests for new prompt and UID-in-transcript behavior
@chaodu-agent chaodu-agent force-pushed the feat/ambient-custom-instructions branch from 5351065 to 2edeef9 Compare June 27, 2026 21:16
@chaodu-agent

This comment has been minimized.

@chaodu-agent

This comment has been minimized.

@chaodu-agent

Copy link
Copy Markdown
Collaborator Author

LGTM ✅

Summary

Relaxes ambient mode default prompt, adds sender UID to transcripts for @mentions, and introduces a debug mode for observing ambient behavior.

Changes

  • Relaxed default prompt: Bias toward engagement — reply when someone asks a question or needs help. [NO_REPLY] only for purely social chatter.
  • Sender UID in transcript: Format Name (<@UID>): message so the LLM can produce valid Discord mentions in responses.
  • Debug mode (debug = true): Posts system prompt + transcript to channel on flush, lets [NO_REPLY] through. Documented as test-channel-only.

Review Findings (All Resolved)

# Severity Finding Resolution
1 🟢 Discord 2000-char message limit overflow in debug Truncated at 1900 chars (UTF-8 safe)
2 🟢 Markdown injection via backticks in user prompt Backticks escaped to single quotes
3 🟢 Discord-specific mention syntax in platform-agnostic code Documented as v2 concern with inline comment
4 🟢 Debug mode exposes system prompt + messages to channel Warning added to config, docs, and code comments
5 🟢 Silent error discard on debug message send Changed to warn! logging
6 🟢 truncate() panics on UTF-8 multi-byte boundary Uses is_char_boundary() to find safe truncation point

Verdict

All findings addressed. No blockers. Ready to merge.

@chaodu-agent

Copy link
Copy Markdown
Collaborator Author

LGTM ✅ — Clean ambient mode enhancement: relaxed default prompt, sender UID in transcript for @mentions, and opt-in debug mode with appropriate safeguards.

What This PR Does

Ambient mode bots were too conservative—staying silent unless they had "meaningful help, context, or corrections." This PR relaxes the default prompt to bias toward engagement (reply when there is a question or actionable topic, [NO_REPLY] only for social chatter), adds sender Discord UIDs to the batch transcript so the LLM can produce valid <@UID> mentions, and introduces an opt-in debug flag for observing ambient behavior in test channels.

How It Works

  1. Relaxed prompt: Default bias flipped from "only reply for meaningful help" to "reply when someone asks a question or you can add useful context." [NO_REPLY] reserved for purely social chatter.
  2. Sender UID + @mention rule: AmbientMessage gains sender_id: String (populated from msg.author.id). Transcript format changes to Name (<@UID>): message. Prompt explicitly instructs the bot to @mention the person being responded to.
  3. Debug mode: AmbientConfig.debug (default false). When enabled, AmbientCaptureAdapter passes [NO_REPLY] through instead of suppressing, and the consumer loop posts system prompt + transcript to the channel before each LLM call. Truncated at 1900 chars with UTF-8 safe boundary detection.

Findings

# Severity Finding Location
1 🟢 Prompt relaxation is well-crafted — clear engagement heuristic with proper [NO_REPLY] fallback ambient.rs:54-62
2 🟢 Sender UID flows cleanly through the stack: Discord handler → AmbientMessage → transcript payload discord.rs:663, ambient.rs:685
3 🟢 Debug truncation handles Discord 2000-char limit with UTF-8 char boundary safety ambient.rs:586-592
4 🟢 Platform-coupling acknowledged with inline v2 comment for future multi-platform support ambient.rs:682
5 🟢 Good test coverage: payload construction, UID in transcript, custom instructions passthrough ambient.rs:713-750
What's Good (🟢)
  • Minimal, focused changes — no unrelated refactoring
  • Backward compatible: debug defaults to false, struct field uses #[serde(default)]
  • Tests cover new functionality without brittleness (key substring assertions, not exact output)
  • Documentation updated in sync (docs/ambient.md config table + example)
  • Debug mode has clear warnings in config comments, docs, and code
  • Backtick escaping in debug transcript prevents markdown injection
  • warn!() on debug message send failure provides operator visibility
Baseline Check
  • PR opened: 2026-06-27
  • Main already has: ambient mode with time/count-based flush, [NO_REPLY] suppression, custom instructions_file support, AmbientMessage (without sender_id), AmbientConfig (without debug)
  • Net-new value: (1) engagement-biased default prompt, (2) sender UID in transcript enabling LLM-generated @mentions, (3) debug mode for ambient behavior observation, (4) unit tests for payload construction
  • Labels: pending-contributor, needs-rebase — though code changes are clean; rebase needed before merge

@chaodu-agent chaodu-agent enabled auto-merge June 27, 2026 21:35
@chaodu-agent chaodu-agent merged commit df4f545 into main Jun 27, 2026
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants