Repository navigation
Description
Original Request
We should create a read-only mode toggle, with it easily accessible via /readonly and in the dashboard with an additional context overflow toggle button thingy (I hope you know what I mean by that LOL). The core concept here would be that in read-only mode, there is no
write,edit, orbashtool use, in that session, and for all subagent sessions spawned by that session. The global setting would be the default state that a session starts in, and then inside any session it should be toggleable at any point. I am aware that this may cause some cache invalidation but its probably worth it.As a concept, additionally, it may be an alternative solution to issue #437. Or at least a first-step approach toward it. We can consider that we might have read-only mode automatically toggle on whenever the agent does
web_search,web_fetch, or usesgit cloneorbash curl/wgetetc. Would need some careful design to not make it useless, and it would need to be very clear in the UX (like a special border and making the button to toggle it suddenly visible?) what has happened and why, and how to undo it (return the model to edit-allowed mode).
Summary
Add a per-session read-only mode that removes the write, edit, and bash tools from the agent's tool set, both for the session itself and for every subagent session it spawns. A global setting controls the default state new sessions start in, and the mode can be toggled at any point mid-session via a /readonly slash command in the TUI and a toggle button in the dashboard session header overflow menu.
Current Behavior
- Tool availability is fixed at session start. The only existing mechanisms are the CLI flags
--tools <list>/--no-tools(packages/coding-agent/src/cli/args.ts), and the read-only tool factorycreateReadOnlyToolDefinitions()inpackages/coding-agent/src/core/tools/index.ts. There is no way to change the tool set mid-session. - There is no
/readonlyslash command (packages/coding-agent/src/core/slash-commands.ts). - Subagents are spawned as separate processes and receive their tool set via a
--toolsCLI argument computed byfilterSubagentTools()inpackages/coding-agent/src/core/tools/subagent.ts. They do not inherit the parent's in-memory settings; a child builds its own settings manager from disk. - The dashboard session header (
packages/dashboard/src/client/screens/session.tsx) has a⋯overflow menu with actions like "compact now", "expand tools", "fork", and "stop runtime", but no tool-mode toggle.
Proposed Behavior
- Global setting: a new global-only setting (e.g. under
~/.dreb/settings.json) that defines whether new sessions start in read-only mode by default. - Mid-session toggle:
- TUI: a
/readonlyslash command that toggles read-only mode for the current session at any point. - Dashboard: a toggle button in the session header overflow menu (the existing
⋯menu) that reflects the current state and switches it.
- TUI: a
- Tool gating: while read-only mode is active, the
write,edit, andbashtools are not available to the model in that session. When toggled off, the full tool set is restored. - Subagent propagation: every subagent session spawned while the parent is in read-only mode must also run without
write,edit, andbash. This needs to cross the process boundary (subagents are spawned with a--toolsargument), so read-only state must be passed explicitly to children rather than relying on settings inheritance. - Visibility: the current mode should be clearly visible in the UI (TUI and dashboard) so the user always knows whether the agent can modify files or run commands.
- Cache invalidation from changing the system prompt / tool list mid-session is an accepted trade-off.
Acceptance Criteria
- A global-only setting defines the default read-only state for new sessions.
-
/readonlyslash command toggles read-only mode in the TUI at any point during a session. - The dashboard session header overflow menu contains a read-only toggle that shows current state and switches it.
- While read-only mode is on,
write,edit, andbashare unavailable to the model in that session; toggling off restores the full tool set. - Read-only state propagates to all subagent sessions spawned by the session (including the
subagenttool's child processes), so they also lackwrite,edit, andbash. - The current mode is clearly indicated in the TUI and dashboard.
Future Considerations (out of scope for this issue)
As noted in the original request, read-only mode may become an alternative or first-step approach to issue #437 (external-content prompt-injection sentinel): read-only mode could automatically engage when the agent ingests untrusted external content (web_search, web_fetch, git clone, curl/wget via bash, etc.). This would need careful design to remain useful, and very clear UX (e.g. a special border, a suddenly-visible toggle button) explaining what happened, why, and how to return to edit-allowed mode. This auto-taint behavior is not part of this issue's scope; it is recorded here for future design discussion.
Technical Notes
- Tool registry and read-only factory:
packages/coding-agent/src/core/tools/index.ts(createReadOnlyToolDefinitions,readOnlyTools). - Session options apply
--toolsat startup inpackages/coding-agent/src/main.ts; a mid-session toggle needs a mechanism to swap the live tool set (the agent loop reads tools from session options; changing them mid-session invalidates the provider prompt cache — accepted). - Subagent spawn and tool filtering:
packages/coding-agent/src/core/tools/subagent.ts(filterSubagentTools,SUBAGENT_DEFAULT_TOOLS,SUBAGENT_EXCLUDED_TOOLS). Read-only state must be added to the child invocation (e.g. a dedicated flag or filtering the--toolslist), since children rebuild settings from disk and must not depend on project settings. - Slash command registration:
packages/coding-agent/src/core/slash-commands.ts(BUILTIN_SLASH_COMMANDS); dispatch inpackages/coding-agent/src/modes/interactive/interactive-mode.ts. - Dashboard: overflow menu in
packages/dashboard/src/client/screens/session.tsx; RPC pattern for per-session actions followssetThinking— clientapi.tswrapper → Express route inpackages/dashboard/src/server/server.ts→h.client.*RPC method on the agent process. A new RPC method (e.g.setReadOnly) plus a runtime-state field for current mode would follow the existing pattern. - Settings:
packages/coding-agent/src/core/settings-manager.ts— global vs project scopes; per the security architecture, the read-only default setting should be global-only if it is intended as a guardrail that project settings cannot weaken (mirroring the nested-context trust boundary policy).
Context
- Related: issue Add an external-content prompt-injection sentinel #437 (external-content prompt-injection sentinel) — read-only mode is a possible alternative or first step.
Activity
Hrovatin commentedon Aug 12, 2026
Worked on in Hrovatin#11
m-aebrer commentedon Aug 12, 2026
Prior Art: Read-Only / Safe-Mode Fallback at the External Data Boundary
Research notes for the read-only mode toggle and its possible future auto-engagement (see "Future Considerations" in the issue body, related to issue 437).
Academic / security-architecture prior art
Dual-LLM pattern (Simon Willison, 2023) — the foundational privilege-separation design: a Privileged LLM with tool access never sees untrusted content; a Quarantined LLM processes untrusted content but has no tools. They communicate only through symbolic references/typed handles. https://simonwillison.net/2023/Apr/25/dual-llm-pattern/
CaMeL — "Defeating Prompt Injections by Design" (Google, Google DeepMind, ETH Zurich; arXiv:2503.18813, Apr 2025) — the strongest formal prior art for the auto-taint concept. CaMeL extracts a control-flow plan from the trusted prompt, then a custom interpreter tracks data provenance and applies security policies as capabilities: flows derived from untrusted data can be forbidden from reaching consequential tools. This is exactly "crossing an external data boundary drops privileges", enforced by the host rather than the model. Simon Willison's writeup: https://simonwillison.net/2025/Apr/11/camel/ — code: https://github.com/google-research/camel-prompt-injection
"Design Patterns for Securing LLM Agents against Prompt Injections" (Beurer-Kellner et al., IBM/Invariant Labs/ETH/Google/Microsoft; arXiv:2506.08837, Jun 2025) — six patterns that constrain what agents can do once untrusted input is possible: Action-Selector, Plan-Then-Execute, LLM Map-Reduce, Dual LLM, Code-Then-Execute, Context-Minimization. Core thesis: general-purpose agents that can do anything are unsecurable; restrict the action space. Reference implementations: https://github.com/ReversecLabs/design-patterns-for-securing-llm-agents-code-samples
Progent — Privilege Control for LLM Agents (arXiv:2504.11703, Apr 2025) — least-privilege enforcement at the tool-call level via a policy DSL over JSON Schema, with fallbacks when a call is denied. Cut attack success rate from 41.2% to 2.2% on AgentDojo while preserving utility. Direct support for the "deny write/edit/bash at the tool boundary" mechanism (host-side gating beats prompt-side instructions).
Lethal trifecta (Simon Willison, Jun 2025) — private data + untrusted content + external communication = exploit. A read-only/no-bash mode triggered on untrusted ingestion is a structural way to break the trifecta (removes the exfiltration/mutation leg). https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/
Classic systems lineage — the general pattern is decades old: Perl taint mode and Android TaintDroid (dynamic information-flow tracking), and Chromium's renderer sandbox (the process that parses untrusted HTML runs with the fewest privileges). Dropping privilege upon contact with untrusted input is the standard answer in every domain that got serious about injection.
Practical implementations of read-only modes in coding agents
read-only/workspace-write/danger-full-access, switchable mid-session via/approvals, combined with approval policies. https://github.com/openai/codex/blob/main/docs/sandbox.md--read/ read-only file handling. Read-only-then-approve is now table stakes across the top tier of coding agents.Design implications for this issue
/approvalsequivalents) validates the/readonly+ dashboard toggle design. Match the familiar pattern: easy to enter, deliberate to exit (an explicit user action, not a model request).m-aebrer commentedon Aug 12, 2026
Superseded by #460 — the manual read-only toggle proposed here is absorbed into that unified design (read-only mode + quarantined external-content retriever), which solves the web-exfiltration gap this design left open.