Skip to content

feat: surface approval 'Always'/'Never' as update_permission tool records#952

Merged
njbrake merged 1 commit intomainfrom
feat/permission-update-tool-record
Apr 14, 2026
Merged

feat: surface approval 'Always'/'Never' as update_permission tool records#952
njbrake merged 1 commit intomainfrom
feat/permission-update-tool-record

Conversation

@njbrake
Copy link
Copy Markdown
Collaborator

@njbrake njbrake commented Apr 14, 2026

Description

Follow-up to #950/#951. User asked: "when I set it to always, shouldn't there be a tool call in the admin chat panel showing permissions were updated, like upload_to_storage renders?"

Yes — previously the ApprovalGate flipped PERMISSIONS.json silently. The chat showed only the user's "Always" reply and the then-executed tool; there was no record that a permission was remembered, making the state change invisible in the dashboard.

Fix

When a prompt resolves to ALWAYS_ALLOW or ALWAYS_DENY and the permission persists successfully, emit a synthetic `update_permission` record:

  • Appends a `StoredToolInteraction` (tool_name=`update_permission`, args include tool/level/resource, result describes what was saved) to the round's `tool_call_records` — so it lands in the session's `tool_interactions_json`.
  • Emits `ToolExecutionStartEvent` + `ToolExecutionEndEvent` — so the SSE activity stream and the per-request tool_call event fire for dashboard clients.

Added `ToolName.UPDATE_PERMISSION` as a constant. The synthetic record is not LLM-callable (not registered in any factory); it only exists as a historical marker.

Type

  • Feature

Tests

  • New: `test_always_allow_emits_update_permission_record` and `test_always_deny_emits_update_permission_record` — assert a single `update_permission` entry appears in `tool_call_records` with the expected args/result.
  • Full suite: 1578 passed, 13 deselected.

Checklist

  • Tests pass
  • Lint + format + type check clean
  • Regression tests added

AI Usage

  • AI-assisted — Claude Opus 4.6 (1M context)

🤖 Generated with Claude Code

When the user replies "Always" or "Never" to an approval prompt, the
gate persists the permission silently. The chat transcript only showed
the raw "Always" text plus the then-executed tool call, leaving no
visible indication that the permission was remembered.

Emit a synthetic update_permission tool record (with args
{tool, level, [resource]}) whenever ALWAYS_ALLOW or ALWAYS_DENY
persists successfully. It flows through the same StoredToolInteraction
path as real tool calls and the same ToolExecutionStart/End events, so
it renders in the session history, the dashboard tool-call viewer, and
the SSE activity stream.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@njbrake njbrake merged commit 8c5fa88 into main Apr 14, 2026
10 checks passed
@njbrake njbrake deleted the feat/permission-update-tool-record branch April 14, 2026 14:57
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