Skip to content

Add agent constraints — per-session and global guardrails (Settings UI + /constraints slash command) - #3

Open
neerajdad123-byte wants to merge 1 commit into
LCorleone:mainfrom
neerajdad123-byte:main
Open

Add agent constraints — per-session and global guardrails (Settings UI + /constraints slash command)#3
neerajdad123-byte wants to merge 1 commit into
LCorleone:mainfrom
neerajdad123-byte:main

Conversation

@neerajdad123-byte

Copy link
Copy Markdown
Contributor

Add agent constraints — per-session and global guardrails (Settings UI + /constraints slash command)

Description:
This PR adds a new Constraints feature that lets users set permanent guardrails the agent must follow — things like
"never edit .env files" or "only work in src/."

What it does:

  • New Constraints section in Settings with scope toggle (Session / Global), text input, Add and Remove buttons
  • /constraints slash command opens settings directly to the Constraints section
  • Constraints are prepended to every prompt as a XML block the agent sees
  • Session constraints persist per-project in workspace state; global constraints persist across all projects in
    localStorage
  • Fully backward-compatible — old workspace data without constraints defaults to empty

How to test:

  1. Open the app → Settings → Constraints (or type /constraints)
  2. Select "Global" scope, type "never edit .env files", click Add
  3. Switch to "Session" scope, add "only suggest changes, don't apply them"
  4. Go to chat, type a prompt — the agent receives both constraints
  5. Remove a constraint via the ✕ button
  6. Restart the app — global constraints persist, session constraints persist per project

Files changed: 6 files, +178 −4

  • New: src/rpc/constraints.ts — shared module for constraint storage and prompt prefix generation
  • src/main.ts — workspace state field, persistence wiring, /constraints routing
  • src/components/settings-panel.ts — Constraints section UI and state
  • src/components/chat-view/send-message-flow.ts — prepend constraints to prompts
  • src/commands/slash-command-catalog.ts — /constraints registration
  • src/components/chat-view/slash-builtin-command.ts — /constraints handler

Screenshot:

image

- Settings panel: new Constraints section with add/remove, session vs global scope
- /constraints slash command opens settings to constraints section
- Constraints prepended to every prompt as <constraints> XML block
- Session constraints persist with workspace state; global in localStorage
- Ponytail: 179 lines across 6 files, no new deps
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