[PR #24649] feat: auto-fill name, id, and description for tools and functions from frontmatter #115066

Open
opened 2026-05-18 16:00:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24649
Author: @silentoplayz
Created: 5/13/2026
Status: 🔄 Open

Base: devHead: feat/autofill-tool-function-metadata


📝 Commits (1)

  • 282a943 feat(ui): auto-fill name, id, and description for tools and functions from frontmatter

📊 Changes

2 files changed (+63 additions, -4 deletions)

View changed files

📝 src/lib/components/admin/Functions/FunctionEditor.svelte (+31 -2)
📝 src/lib/components/workspace/Tools/ToolkitEditor.svelte (+32 -2)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.

This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.

Before submitting, make sure you've checked the following:

  • Linked Issue/Discussion: This PR references an existing Issue or Discussion — Relates to #24648. If one does not exist, create one first. PRs without a linked issue or discussion may be closed without review.
  • Target branch: The pull request targets the dev branch. PRs targeting main will be immediately closed.
  • Description: A concise description of the changes is provided below.
  • Changelog: A changelog entry following Keep a Changelog format is included at the bottom.
  • Documentation: Relevant documentation has been added or updated in the Open WebUI Docs Repository.
  • Dependencies: Any new or updated dependencies are explained, tested, and documented.
  • Testing: Manual tests have been performed to verify the fix/feature works correctly and does not introduce regressions. Screenshots or recordings are included where applicable.
  • No Unchecked AI Code: This PR is either human-written or has undergone thorough human review AND manual testing. Unreviewed AI-generated PRs may be closed immediately.
  • Self-Review: A self-review of the code has been performed, ensuring adherence to project coding standards.
  • Architecture: Smart defaults are preferred over new settings. Local state is used for ephemeral UI logic. Major architectural or UX changes have been discussed first.
  • Git Hygiene: The PR is atomic (one logical change), rebased on dev, and contains no unrelated commits.
  • Title Prefix: The PR title uses one of the following prefixes:
    • feat: New features or enhancements

Changelog Entry

Description

Problem: When creating a new Tool or Function in Open WebUI, users must manually type the Name, ID, and Description fields even when the pasted code already contains this metadata in its frontmatter header. This is inconsistent with the Skill editor, which already auto-fills these fields from the skill's YAML frontmatter when code is pasted.

Solution: This PR extends the same auto-fill behavior to the Tool and Function editors. When a user pastes (or types) Python code containing a valid """ triple-quote frontmatter block into a new Tool or Function, the title: and description: fields are automatically extracted and used to populate:

  • Name — title-cased from the title: frontmatter key
  • ID — slugified from the title: frontmatter key using the existing nameToId() utility
  • Description — directly from the description: frontmatter key

This reuses the existing extractFrontmatter() utility from $lib/utils (the same function already used by the ImportModal and the create/edit page wrappers for version checking), so no new utilities or dependencies are introduced.

Key design decisions:

  • Manual override tracking: Each field (Name, ID, Description) tracks whether the user has manually typed into it via on:input handlers. Once a field is manually edited, the frontmatter auto-fill stops overwriting it — giving the user full control.
  • Create-mode only: The auto-fill logic is skipped entirely in edit mode, preventing accidental overwrites of existing metadata.
  • Clone-safe: The handleContentChange function is only invoked from the CodeEditor's onChange callback (user-initiated edits), not from the initial prop-based content assignment, so cloning a Tool or Function does not trigger unwanted auto-fill overwrites.
  • Consistent with Skills: The pattern mirrors the existing SkillEditor.svelte implementation (which uses parseFrontmatter() for --- YAML headers), adapted for the Python """ triple-quote format that Tools and Functions use.

Added

  • Auto-fill of Name, ID, and Description fields in the ToolkitEditor (src/lib/components/workspace/Tools/ToolkitEditor.svelte) from Python triple-quote frontmatter when creating a new Tool.
  • Auto-fill of Name, ID, and Description fields in the FunctionEditor (src/lib/components/admin/Functions/FunctionEditor.svelte) from Python triple-quote frontmatter when creating a new Function.
  • Manual override detection (hasManualName, hasManualId, hasManualDescription flags) on all three input fields in both editors to prevent auto-fill from overwriting user edits.

Changed

  • The reactive nameToId derivation in both editors is now additionally guarded by !isFrontmatterDetected to prevent the name-based ID from fighting with the frontmatter-derived ID.
  • The import statement in ToolkitEditor.svelte was consolidated to import both extractFrontmatter and nameToId from $lib/utils in a single import.

Additional Information

  • No new dependencies were added. This feature exclusively uses the existing extractFrontmatter() and nameToId() utilities already present in $lib/utils/index.ts.
  • Scope: 2 files changed, 63 insertions, 4 deletions. Single atomic commit.
  • Frontmatter format supported: The standard Open WebUI Python frontmatter format enclosed in triple quotes ("""), e.g.:
    """
    title: My Cool Tool
    description: A tool that does something useful
    author: username
    version: 1.0
    """
    

Screenshots or Videos

Screencast from 2026-05-13 03-49-25.webm

Manual Verification Performed

  1. Tool auto-fill: Navigate to Workspace → Tools → Create New Tool. Paste a Python tool with valid """ frontmatter containing title: and description: keys. Verify the Name, ID, and Description fields auto-populate.
  2. Function auto-fill: Navigate to Admin → Functions → Create New Function. Paste a Python function with valid """ frontmatter. Verify the same auto-population behavior.
  3. Manual override: After auto-fill, manually type into the Name field. Verify that subsequent code edits no longer overwrite the manually-entered name (same for ID and Description).
  4. No frontmatter: Paste Python code without a """ frontmatter block. Verify the fields remain empty and the fallback nameToId derivation from the Name field still works as before.
  5. Edit mode: Open an existing Tool/Function for editing. Verify the auto-fill does NOT trigger and existing metadata is preserved.
  6. Clone mode: Clone an existing Tool/Function. Verify the cloned Name/ID/Description are preserved and not overwritten by frontmatter.

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/24649 **Author:** [@silentoplayz](https://github.com/silentoplayz) **Created:** 5/13/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `feat/autofill-tool-function-metadata` --- ### 📝 Commits (1) - [`282a943`](https://github.com/open-webui/open-webui/commit/282a9437571af4210df2c56fe0524ec3a7119e7e) feat(ui): auto-fill name, id, and description for tools and functions from frontmatter ### 📊 Changes **2 files changed** (+63 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/admin/Functions/FunctionEditor.svelte` (+31 -2) 📝 `src/lib/components/workspace/Tools/ToolkitEditor.svelte` (+32 -2) </details> ### 📄 Description <!-- ⚠️ CRITICAL CHECKS FOR CONTRIBUTORS (READ, DON'T DELETE) ⚠️ 1. Target the `dev` branch. PRs targeting `main` will be automatically closed. 2. Do NOT delete the CLA section at the bottom. It is required for the bot to accept your PR. --> # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request. This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR. <!-- ### ⚠️ Important: Your PR is a contribution, not a guarantee of merge. The most impactful way to contribute to Open WebUI is through well-written bug reports, detailed feature discussions, and thoughtful ideas. These directly shape the project. If you do open a pull request, please know that Open WebUI is held to the highest standard of code quality, consistency, and architectural coherence, and every line merged becomes something the core team must own, maintain, and support indefinitely. Submitted code may be refactored, rewritten, or used as inspiration for a different implementation. This is not a reflection of your work's quality. It is how we ensure that a small team can deeply understand and evolve every part of the codebase. --> **Before submitting, make sure you've checked the following:** - [x] **Linked Issue/Discussion:** This PR references an existing [Issue](https://github.com/open-webui/open-webui/issues) or [Discussion](https://github.com/open-webui/open-webui/discussions) — Relates to [#24648](https://github.com/open-webui/open-webui/discussions/24648). If one does not exist, create one first. PRs without a linked issue or discussion may be closed without review. - [x] **Target branch:** The pull request targets the `dev` branch. **PRs targeting `main` will be immediately closed.** - [x] **Description:** A concise description of the changes is provided below. - [x] **Changelog:** A changelog entry following [Keep a Changelog](https://keepachangelog.com/) format is included at the bottom. - [ ] **Documentation:** Relevant documentation has been added or updated in the [Open WebUI Docs Repository](https://github.com/open-webui/docs). - [x] **Dependencies:** Any new or updated dependencies are explained, tested, and documented. - [x] **Testing:** Manual tests have been performed to verify the fix/feature works correctly and does not introduce regressions. Screenshots or recordings are included where applicable. - [x] **No Unchecked AI Code:** This PR is either human-written or has undergone thorough human review AND manual testing. Unreviewed AI-generated PRs may be closed immediately. - [x] **Self-Review:** A self-review of the code has been performed, ensuring adherence to project coding standards. - [x] **Architecture:** Smart defaults are preferred over new settings. Local state is used for ephemeral UI logic. Major architectural or UX changes have been discussed first. - [x] **Git Hygiene:** The PR is atomic (one logical change), rebased on `dev`, and contains no unrelated commits. - [x] **Title Prefix:** The PR title uses one of the following prefixes: - **feat**: New features or enhancements # Changelog Entry ### Description **Problem:** When creating a new **Tool** or **Function** in Open WebUI, users must manually type the Name, ID, and Description fields even when the pasted code already contains this metadata in its frontmatter header. This is inconsistent with the **Skill** editor, which already auto-fills these fields from the skill's YAML frontmatter when code is pasted. **Solution:** This PR extends the same auto-fill behavior to the Tool and Function editors. When a user pastes (or types) Python code containing a valid `"""` triple-quote frontmatter block into a new Tool or Function, the `title:` and `description:` fields are automatically extracted and used to populate: - **Name** — title-cased from the `title:` frontmatter key - **ID** — slugified from the `title:` frontmatter key using the existing `nameToId()` utility - **Description** — directly from the `description:` frontmatter key This reuses the existing `extractFrontmatter()` utility from `$lib/utils` (the same function already used by the `ImportModal` and the create/edit page wrappers for version checking), so no new utilities or dependencies are introduced. **Key design decisions:** - **Manual override tracking:** Each field (Name, ID, Description) tracks whether the user has manually typed into it via `on:input` handlers. Once a field is manually edited, the frontmatter auto-fill stops overwriting it — giving the user full control. - **Create-mode only:** The auto-fill logic is skipped entirely in edit mode, preventing accidental overwrites of existing metadata. - **Clone-safe:** The `handleContentChange` function is only invoked from the CodeEditor's `onChange` callback (user-initiated edits), not from the initial prop-based content assignment, so cloning a Tool or Function does not trigger unwanted auto-fill overwrites. - **Consistent with Skills:** The pattern mirrors the existing `SkillEditor.svelte` implementation (which uses `parseFrontmatter()` for `---` YAML headers), adapted for the Python `"""` triple-quote format that Tools and Functions use. ### Added - Auto-fill of Name, ID, and Description fields in the **ToolkitEditor** (`src/lib/components/workspace/Tools/ToolkitEditor.svelte`) from Python triple-quote frontmatter when creating a new Tool. - Auto-fill of Name, ID, and Description fields in the **FunctionEditor** (`src/lib/components/admin/Functions/FunctionEditor.svelte`) from Python triple-quote frontmatter when creating a new Function. - Manual override detection (`hasManualName`, `hasManualId`, `hasManualDescription` flags) on all three input fields in both editors to prevent auto-fill from overwriting user edits. ### Changed - The reactive `nameToId` derivation in both editors is now additionally guarded by `!isFrontmatterDetected` to prevent the name-based ID from fighting with the frontmatter-derived ID. - The import statement in `ToolkitEditor.svelte` was consolidated to import both `extractFrontmatter` and `nameToId` from `$lib/utils` in a single import. --- ### Additional Information - **No new dependencies** were added. This feature exclusively uses the existing `extractFrontmatter()` and `nameToId()` utilities already present in `$lib/utils/index.ts`. - **Scope:** 2 files changed, 63 insertions, 4 deletions. Single atomic commit. - **Frontmatter format supported:** The standard Open WebUI Python frontmatter format enclosed in triple quotes (`"""`), e.g.: ```python """ title: My Cool Tool description: A tool that does something useful author: username version: 1.0 """ ``` ### Screenshots or Videos [Screencast from 2026-05-13 03-49-25.webm](https://github.com/user-attachments/assets/42afc1e8-8200-40de-a81c-d2c504fd94fc) ### Manual Verification Performed 1. **Tool auto-fill:** Navigate to Workspace → Tools → Create New Tool. Paste a Python tool with valid `"""` frontmatter containing `title:` and `description:` keys. Verify the Name, ID, and Description fields auto-populate. 2. **Function auto-fill:** Navigate to Admin → Functions → Create New Function. Paste a Python function with valid `"""` frontmatter. Verify the same auto-population behavior. 3. **Manual override:** After auto-fill, manually type into the Name field. Verify that subsequent code edits no longer overwrite the manually-entered name (same for ID and Description). 4. **No frontmatter:** Paste Python code without a `"""` frontmatter block. Verify the fields remain empty and the fallback `nameToId` derivation from the Name field still works as before. 5. **Edit mode:** Open an existing Tool/Function for editing. Verify the auto-fill does NOT trigger and existing metadata is preserved. 6. **Clone mode:** Clone an existing Tool/Function. Verify the cloned Name/ID/Description are preserved and not overwritten by frontmatter. ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-18 16:00:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#115066