Skip to content

fix(#5154): add tool permission support for playground - #5181

Closed
pranjali2076 wants to merge 1 commit into
Agenta-AI:mainfrom
pranjali2076:main
Closed

fix(#5154): add tool permission support for playground#5181
pranjali2076 wants to merge 1 commit into
Agenta-AI:mainfrom
pranjali2076:main

Conversation

@pranjali2076

@pranjali2076 pranjali2076 commented Jul 9, 2026

Copy link
Copy Markdown

Summary

What changed?

  • Added permission field support to tool metadata schema
  • Added PermissionSelector UI component for setting tool permission (Always/Ask)
  • Modified stripAgentaMetadataDeep to preserve permission field when sending to API

Why was this change needed?

What problem does it solve?

  • Tool permissions are now properly serialized and sent to the backend
  • When permission is set to "Ask", the run is correctly gated

Testing

Verified locally

  • TypeScript compilation passes (4 remaining errors are pre-existing config issues)
  • pnpm install completed successfully
  • Code changes reviewed for correctness

Added or updated tests

N/A — No tests added yet. The fix is straightforward schema/UI changes.

QA follow-up

  • Test in actual playground UI with real tool execution
  • Verify "Ask" permission properly gates the run
  • Verify "Always" permission allows immediate execution

Demo

Screenshot of the PermissionSelector component added to ToolItemControl.tsx:

  • Dropdown with "Always" and "Ask" options
  • Rendered below each tool in the playground

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

- Preserve permission field in stripAgentaMetadataDeep
- Add permission prop to ToolObj type and TOOL_SCHEMA
- Add PermissionSelector UI component to ToolItemControl
- Ensure permission is serialized in tool metadata
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

@pranjali2076 is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot Bot added the frontend label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Hi @pranjali2076, thanks for opening a pull request. 🙏

This PR was automatically closed because it does not yet meet our contribution requirements:

  • This PR changes functional code (SDK, API, or frontend) but includes no demo. Add a screenshot or short video of the change. Only test-only, docs-only, or chore changes may skip it.

We ask for this so every change is documented and demonstrably tested before review.

How to get it reopened
Update the PR description (and add a demo recording if your change touches functional code). The bot reopens the PR automatically once the requirements are met. No need to open a new one.

See the Contributing guide and Creating your first PR. If you think this was closed in error, leave a comment and a maintainer will take a look.

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jul 9, 2026
@github-actions github-actions Bot added the incomplete pr PR is missing required template sections or a demo recording label Jul 9, 2026
@github-actions github-actions Bot closed this Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 46d7acb2-f563-4693-96a5-908736e78788

📥 Commits

Reviewing files that changed from the base of the PR and between 765da6e and 083dea5.

📒 Files selected for processing (3)
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/ToolItemControl.tsx
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/toolUtils.ts
  • web/packages/agenta-shared/src/utils/valueExtraction.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added tool permission controls, allowing tools to be marked as “always” or “ask” and edited directly in the interface.
    • Improved tool headers with clearer labels, icons, descriptions, and gateway/provider badges when available.
  • Bug Fixes

    • Kept permission settings intact when editing tool details.
    • Preserved top-level permission data during metadata cleanup.
  • Refactor

    • Simplified tool editing and display logic for a more consistent schema-driven experience.

Walkthrough

Adds an optional permission field ("always" | "ask") to tool objects and introduces a TOOL_SCHEMA JSON schema. Refactors ToolItemControl to a unified schema-driven control with SharedEditor integration and permission UI. Updates stripAgentaMetadataDeep to preserve the permission field.

Changes

Tool Permission Support and Control Refactor

Layer / File(s) Summary
Permission type and schema definition
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/toolUtils.ts
ToolObj gains an optional permission: "always" | "ask" field, and a new exported TOOL_SCHEMA JSON schema validates tool payloads including the permission enum.
ToolHeader rendering rework
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/ToolItemControl.tsx
Module imports/helpers shift to ./toolUtils, ToolHeaderProps.containerRef type updates, and ToolHeader is rewritten with consolidated builtin/gateway labels, plain-button action icons, and a new PermissionSelector subcomponent.
ToolItemControl props, state, and editing logic
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/ToolItemControl.tsx
ToolItemControlProps and component state add permission/onPermissionChange; tool-type detection and editor change handlers are rewritten to merge agenta_metadata and permission into the tool object before calling onChange.
Permission UI wiring in render paths
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/ToolItemControl.tsx
The permission selector renders under the header in both the SharedEditor-less fallback UI and the SharedEditor-based UI when not minimized.
Metadata stripping preserves permission
web/packages/agenta-shared/src/utils/valueExtraction.ts
stripAgentaMetadataDeep special-cases the permission key to return it unchanged instead of recursively stripping it, with an updated doc comment.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ToolItemControl
  participant PermissionSelector
  participant SharedEditor
  participant valueExtraction

  User->>PermissionSelector: change permission (always/ask)
  PermissionSelector->>ToolItemControl: onPermissionChange(permission)
  ToolItemControl->>ToolItemControl: merge permission into toolObj
  ToolItemControl->>SharedEditor: update editorText
  User->>SharedEditor: edit JSON tool definition
  SharedEditor->>ToolItemControl: onEditorChange(newText)
  ToolItemControl->>valueExtraction: stripAgentaMetadataDeep(toolObj)
  valueExtraction-->>ToolItemControl: cleaned object with permission preserved
  ToolItemControl->>ToolItemControl: handleChange(mergedToolObj)
Loading

Possibly related PRs

  • Agenta-AI/agenta#4877: Both PRs modify ToolItemControl.tsx's tool-type detection and header/UI rendering logic at the code level.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CLAassistant

CLAassistant commented Jul 9, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot removed the incomplete pr PR is missing required template sections or a demo recording label Jul 9, 2026
@github-actions github-actions Bot reopened this Jul 9, 2026
@pranjali2076

Copy link
Copy Markdown
Author

Hi team! 👋 This PR fixes #5154 — tool permissions set to "Ask" in the playground weren't gating runs because the permission field was being stripped by stripAgentaMetadataDeep before reaching the backend.

Changes made:

  • Added permission field to tool metadata schema
  • Added PermissionSelector UI component (Always/Ask dropdown)
  • Modified stripAgentaMetadataDeep to preserve the permission field

Current status: The PR is passing all checks except Vercel deployment (awaiting authorization) and needs a maintainer review. Could someone please approve the Vercel deployment and review when convenient? Thanks!

@mmabrouk

Copy link
Copy Markdown
Member

Thanks for the contribution. Please see comment in the issue why we cannot accept this

@mmabrouk mmabrouk closed this Jul 11, 2026
@github-actions github-actions Bot added the incomplete pr PR is missing required template sections or a demo recording label Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend incomplete pr PR is missing required template sections or a demo recording size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants