feat(gateway): hard-enforce read-only tools for plan/review mode (P4b gateway)#79
Merged
Merged
Conversation
The Aurelius Command Console exposes Ask/Auto/Plan/Review agency modes; Plan and Review must HARD-restrict the agent to read-only tools (not merely self-honor). The /v1/chat/completions ingress now reads the `x-openclaw-tools-mode` header (forwarded by relay-v3 from the operator's mode pick). For plan/review it sets `toolsAllow = SAFE_READ_ONLY_TOOLS` on the agent command input; AgentCommandIngressOpts already carries `toolsAllow`, which the embedded runner enforces as the runtime tool allow-list (run/attempt.ts "runtime toolsAllow"). ask/auto (and absent/unknown) leave the full toolset. - agent-consult-tool.ts: export SAFE_READ_ONLY_TOOLS (single source of truth; previously used only for voice consults). - openai-http.ts: read the header → compute toolsAllow → thread through buildAgentCommandInput → agentCommandFromIngress. Pairs with the mono-repo console PR that sends the header. No effect unless the header is present, so safe to deploy independently. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
LightDriverCS
marked this pull request as ready for review
June 20, 2026 06:14
Agent-Aurelius
added a commit
that referenced
this pull request
Jun 23, 2026
…82) These power the Aurelius web console under ultracode but were running ONLY as uncommitted floating patches on the live detached gateway worktree (backed up at origin/backup/gateway-patches-2026-06-22), NOT on main: - C1: salvage clean assistant text from leaked raw Claude-CLI stream-json (salvageClaudeStreamJsonText in agent-event-assistant-text.ts, applied in writeAssistantContentChunk). - C3: bridge a native AskUserQuestion into the console's openclaw_ask_choice card (buildAskChoiceFromArgs + request-scope blob buffering in the /v1/chat/completions handler) + extractAskUserQuestionFromClaudeStreamJson. Merged onto current main (#81); #79's read-only-tools enforcement is preserved (additive, different code paths). agent-event-assistant-text.ts + cli-runner/ execute.ts were untouched by main so taken whole; openai-http.ts merged (import superset + salvage in writeAssistantContentChunk + the ask_choice bridge). Companion to the gateway durability reconcile: once merged, both live gateways rebuild from this main commit and stop running uncommitted detached patches. Co-authored-by: Aurelius <[email protected]>
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.
Intent
Pair PR for the Aurelius Command Console agency mode selector. Plan/Review must hard-restrict the agent to read-only tools at the gateway — not self-honor.
Mechanism
/v1/chat/completions(openai-http.ts) reads thex-openclaw-tools-modeheader (forwarded by relay-v3 from the operator's mode pick).plan/review→toolsAllow = SAFE_READ_ONLY_TOOLS(read, web_search, web_fetch, x_search, memory_search, memory_get).ask/auto/ absent / unknown → no restriction (full toolset).toolsAllowthreads throughbuildAgentCommandInput→agentCommandFromIngress(AgentCommandIngressOptsalready carriestoolsAllow) and is enforced by the embedded runner's runtime allow-list (run/attempt.ts"runtime toolsAllow",enforceWhenToolsDisabled: true).Surfaces touched (17 lines)
talk/agent-consult-tool.ts—export SAFE_READ_ONLY_TOOLS(single source of truth).gateway/openai-http.ts— read header → computetoolsAllow→ thread viabuildAgentCommandInput.Low-risk
toolsAllowlever (same mechanism as realtime-voice consults).Pairs with
aurelius/console-p4b-mode(mode selector UI + relayx-openclaw-tools-modeheader).Deploy / verify (operator-coordinated)
dist→ needs adistrebuild + restart (durability hazard) + rollback. Could not build the full gateway locally; typecheck/build is the gate at the coordinated build.Follow-ups
asktrue per-action approval (todayask= full tools).chat.sendpath.