Skip to content

feat(ambient): add instructions_file for custom system prompt#1222

Merged
pahud merged 4 commits into
mainfrom
feat/ambient-instructions-file
Jun 27, 2026
Merged

feat(ambient): add instructions_file for custom system prompt#1222
pahud merged 4 commits into
mainfrom
feat/ambient-instructions-file

Conversation

@chaodu-agent

Copy link
Copy Markdown
Collaborator

Summary

Add support for loading ambient mode system instructions from an external file (~/.openab/config/ambient.md) instead of using the hardcoded default.

Changes

  • config.rs: Added instructions_file field to AmbientConfig (default: ~/.openab/config/ambient.md)
  • ambient.rs: Added load_instructions() that reads from the configured path (first 2000 chars), falls back to built-in default if file is missing
  • docs/ambient.md: Documented the new feature with usage examples
  • config.toml.example: Added ambient section with the new field

Behavior

  • On startup, reads ~/.openab/config/ambient.md (or custom path from config)
  • If file exists: uses first 2000 characters as the ambient system prompt
  • If file missing: uses the built-in default (no behavior change for existing users)
  • Zero config required — works out of the box with convention-based path

Testing

  • Existing unit tests pass (no behavioral change when file is absent)
  • Manual: create ~/.openab/config/ambient.md → bot uses custom instructions

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

This comment has been minimized.

Load ambient system instructions from ~/.openab/config/ambient.md
(configurable via instructions_file field). First 2000 characters
are used; falls back to built-in default if the file is missing.

This allows users to customize ambient behavior by editing a single
file without touching config.toml.
@chaodu-agent chaodu-agent force-pushed the feat/ambient-instructions-file branch from 9fe3014 to de9c5e3 Compare June 27, 2026 16:15
@chaodu-agent

This comment has been minimized.

@chaodu-agent

This comment has been minimized.

- Warn when instructions_file path is outside $HOME
- Warn when file content is truncated at 2000 chars
- Add unit tests: file exists, file missing fallback, truncation
@chaodu-agent

This comment has been minimized.

@chaodu-agent

This comment has been minimized.

@chaodu-agent

This comment has been minimized.

- F1: Differentiate NotFound from other IO errors in load_instructions()
- F2: Fix contradictory doc (No restart → Restart required)
- F3: Revert default prompt to original conservative wording
@chaodu-agent

This comment has been minimized.

@chaodu-agent

Copy link
Copy Markdown
Collaborator Author

LGTM ✅ — Clean, minimal feature addition with proper fallback behavior and good test coverage.

What This PR Does

Adds support for loading ambient mode system instructions from an external file (~/.openab/config/ambient.md) instead of the hardcoded default, giving operators control over the ambient system prompt without code changes.

How It Works

  • New instructions_file field in AmbientConfig (default: ~/.openab/config/ambient.md)
  • load_instructions() reads the file at startup, truncates to 2000 chars, falls back to built-in default if missing or unreadable
  • The loaded instruction string is stored in AmbientDispatcher and cloned into each channel consumer loop
  • Tilde expansion handles ~/ paths; warns if path is outside $HOME

Findings

# Severity Finding Location
1 🟢 Clean fallback chain: file → warn on error → default. All IO errors handled gracefully ambient.rs:80-97
2 🟢 Good test coverage: exists, missing, and truncation cases ambient.rs:765-798
3 🟢 Docs clearly state restart-required semantics and provide a working example docs/ambient.md
4 🟢 Config example is well-commented and follows existing patterns config.toml.example
Baseline Check
  • PR opened: 2026-06-27
  • Main already has: hardcoded AMBIENT_SYSTEM_INSTRUCTION constant with no external file loading
  • Net-new value: operator-configurable ambient system prompt via external file, with safe defaults and documentation
What's Good (🟢)
  • Zero-config default — existing deployments unaffected
  • Defensive coding: warns on paths outside $HOME, handles all io::Error variants
  • Truncation prevents unbounded memory from large files
  • Tests cover the three key paths (happy, missing, truncation)
  • Documentation is clear with a practical example

@pahud pahud merged commit 4adbbb2 into main Jun 27, 2026
35 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.

3 participants