Skip to content

fix(frontend): surface nameless tools (workflow references) in the commit-diff Tools section - #5038

Merged
ardaerzin merged 4 commits into
big-agentsfrom
fe-fix/agent-commit-diff-nameless-tools
Jul 2, 2026
Merged

ardaerzin merged 4 commits into
big-agentsfrom
fe-fix/agent-commit-diff-nameless-tools

Conversation

@ardaerzin

@ardaerzin ardaerzin commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

What

Follow-up to #5035. The commit-diff classifier's normalizeTool dropped any tool without a function.name (return null). The agent tool flow adds workflow-reference tools ({type: "reference", slug}) via "Reference a workflow" — these have no function.name, so they were invisible to the Tools section:

  • adding / removing / editing a reference tool never appeared in the commit-modal summary, and
  • the config panel's Tools header never tinted for them — even though the per-item row indicator did flag them (it uses the canonical agentItemIdentity), so the header and its rows disagreed.

Note: the agent tool picker (AgentToolSelectorPopover) offers no builtin tools ("No built-in tools here") — only reference / third-party gateway / create-definition. Builtins live in the prompt playground's ToolSelectorPopover, which reuses this same classifier — so the fix also keeps builtin/platform tools from being dropped there (plus legacy/defensive cover).

Fix

normalizeTool now surfaces every tool subtype instead of dropping the nameless ones:

  • keyed by the canonical agentItemIdentity (function name → reference slug → platform op → positional fallback), so entries never collapse;
  • a fingerprint (whole-tool stable hash) drives edit detection across all subtypes — function tools keep their field-level detail (diffToolFields); reference/builtin edits register via the fingerprint;
  • NormalizedTool gains rawKey (technical name shown in the detail view), fingerprint, and isFunction.

Labels: function/gateway via parseGatewayToolName, reference → slug, builtin → humanized type.

Testing

  • New unit tests: reference tool added; reference tool edited (no function fields); builtin tool diffed via the prompt shape. Existing tool tests updated to assert on rawKey. 31/31 pass.
  • tsc --noEmit clean for @agenta/entities and @agenta/entity-ui; eslint/prettier/turbo-lint green.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 2, 2026
@vercel

vercel Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jul 2, 2026 8:02pm

Request Review

@dosubot dosubot Bot added the frontend label Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c4ce9402-cf27-4e41-9ce1-8dee935dd182

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR reworks tool normalization and diff classification in the commitDiff module. NormalizedTool gains rawKey, fingerprint, and isFunction. normalizeTool now handles function, workflow-reference, and builtin tool shapes with a fallback instead of returning null. Tool identity generation supports legacy flat function shapes, and classification uses fingerprint comparison and rawKey for display identifiers.

Changes

Tool identity and diff classification

Layer / File(s) Summary
NormalizedTool type contract
web/packages/agenta-entities/src/workflow/commitDiff/types.ts
Extends NormalizedTool interface with rawKey, fingerprint, and isFunction.
Tool normalization with multi-shape support
web/packages/agenta-entities/src/workflow/commitDiff/accessors.ts
Imports agentItemIdentity, rewrites normalizeTool(raw, index) to compute key via agentItemIdentity, generate fingerprint via stableStringify, and explicitly handle function/gateway, workflow-reference, and builtin tool shapes with a fallback entry instead of returning null. Updates readAgentConfig to pass the tool index during normalization.
Identity key generation for legacy tool shapes
web/packages/agenta-entities/src/workflow/commitDiff/identity.ts
Extends agentItemIdentity tool logic to support legacy flat function shape {name, ...} by deriving fn:<name> when function.name is unavailable but rec.name is present.
Classification using fingerprint and rawKey
web/packages/agenta-entities/src/workflow/commitDiff/classify.ts
Changes toolsSection edit detection to compare fingerprint instead of description/paramsJson, updates toolRowDetail fallback to return "changed" instead of undefined, and switches added/edited/removed tool items from using key to using rawKey.
Test updates for rawKey and non-function tool diffing
web/packages/agenta-entities/tests/unit/agent-commit-diff.test.ts
Updates existing readAgentConfig test assertions to check rawKey instead of key, adds classifyAgentChanges tests exercising workflow-reference and builtin tool diffing, and adds agentItemIdentity test confirming legacy flat function shape identity matches wrapped function shape.

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

Possibly related PRs

  • Agenta-AI/agenta#4877: Both PRs handle type: "reference" workflow tools in the same commitDiff normalization and classification path.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: surfacing nameless workflow-reference tools in the commit-diff Tools section.
Description check ✅ Passed The description directly explains the Tools classifier fix, related tool subtypes, and tests, matching the change set.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fe-fix/agent-commit-diff-nameless-tools

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.

…mmit-diff Tools section

The agent tool flow adds workflow-reference tools ({type:"reference", slug}) via "Reference a workflow" — they have no function.name, so normalizeTool dropped them (return null) and they were invisible to the classifier's Tools diff: adding/removing/editing one never showed in the commit summary, and the config panel's Tools header never tinted for them (the per-item row indicator already handled them via agentItemIdentity, so header and rows disagreed).

normalizeTool now surfaces every tool subtype, keyed by the canonical agentItemIdentity (function name / reference slug / platform op / positional fallback), with a fingerprint (whole-tool hash) for edit detection across subtypes; field-level detail stays function-only. NormalizedTool gains rawKey, fingerprint, isFunction. Note: the agent picker offers no builtin tools ("No built-in tools here") — the builtin/platform handling covers the prompt playground, which reuses this classifier and does have them, plus legacy/defensive cover.
@ardaerzin
ardaerzin force-pushed the fe-fix/agent-commit-diff-nameless-tools branch from a7200b6 to c2983b7 Compare July 2, 2026 15:25
@ardaerzin ardaerzin changed the title fix(frontend): surface builtin and reference tools in the commit-diff Tools section fix(frontend): surface nameless tools (workflow references) in the commit-diff Tools section Jul 2, 2026
@ardaerzin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/agenta-entities/src/workflow/commitDiff/classify.ts (1)

96-103: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fingerprint-based edit detection can yield "edited" rows with no visible detail.

Broadening edit detection to whole-object fingerprint is a net improvement (catches changes the old description/paramsJson check missed), but for isFunction tools it introduces a new possibility: a function tool's fingerprint can change due to fields diffToolFields doesn't inspect (anything besides description/params.properties), yielding an "edited" item with empty fieldChanges and toolRowDetail returning undefined. Previously this couldn't happen because "edited" itself was derived from the description/paramsJson diff.

Consider a fallback detail (e.g. "tool changed") in toolRowDetail/edited.map when fields is empty but the tool is a function tool, so users aren't shown an unexplained "edited" badge.

💡 Suggested fallback detail
 function toolRowDetail(fields: ToolFieldChange[]): string | undefined {
     const descChanged = fields.some((f) => f.field === "description")
     const paramCount = fields.filter((f) => f.field !== "description").length
     const parts: string[] = []
     if (descChanged) parts.push("description")
     if (paramCount) parts.push(paramCount === 1 ? "1 parameter" : `${paramCount} parameters`)
-    if (!parts.length) return undefined
+    if (!parts.length) return "changed"
     return `${parts.join(" & ")} changed`
 }
🧹 Nitpick comments (1)
web/packages/agenta-entities/tests/unit/agent-commit-diff.test.ts (1)

151-180: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Good coverage for reference/builtin tools; consider adding added/edited builtin cases too.

Current tests cover reference-tool add/edit and builtin-tool remove. An added/edited builtin (e.g. {type:"web_search"}) case would round out coverage of the fallback branches in normalizeTool/toolsSection.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c113df24-45f1-428c-af42-fa40b1150f6f

📥 Commits

Reviewing files that changed from the base of the PR and between f0e8b58 and c2983b7.

📒 Files selected for processing (4)
  • web/packages/agenta-entities/src/workflow/commitDiff/accessors.ts
  • web/packages/agenta-entities/src/workflow/commitDiff/classify.ts
  • web/packages/agenta-entities/src/workflow/commitDiff/types.ts
  • web/packages/agenta-entities/tests/unit/agent-commit-diff.test.ts

Comment on lines +77 to +83
const fn = isObj(raw.function) ? raw.function : undefined
const fnName = fn && typeof fn.name === "string" ? fn.name : undefined

// Function / gateway tool.
if (fnName) {
const parsed = parseGatewayToolName(fnName)
const params = isObj(fn?.parameters) ? (fn?.parameters as Record<string, unknown>) : {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve flat function-tool shapes.

The previous normalizer handled function data from raw.function or raw; this now only checks raw.function. A tool shaped like {name, description, parameters} falls through as generic "Tool" with positional identity, no rawKey, no params, and no field-level diffs. Update both normalization and agentItemIdentity so flat function tools still key as fn:<name>.

Proposed fix
-    const fn = isObj(raw.function) ? raw.function : undefined
+    const fn = isObj(raw.function)
+        ? raw.function
+        : (raw.type === undefined || raw.type === "function") && typeof raw.name === "string"
+          ? raw
+          : undefined

Also align web/packages/agenta-entities/src/workflow/commitDiff/identity.ts:

         const fn = isObj(rec.function) ? rec.function : undefined
         if (fn && typeof fn.name === "string" && fn.name) return `fn:${fn.name}`
+        if (
+            (rec.type === undefined || rec.type === "function") &&
+            typeof rec.name === "string" &&
+            rec.name
+        )
+            return `fn:${rec.name}`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const fn = isObj(raw.function) ? raw.function : undefined
const fnName = fn && typeof fn.name === "string" ? fn.name : undefined
// Function / gateway tool.
if (fnName) {
const parsed = parseGatewayToolName(fnName)
const params = isObj(fn?.parameters) ? (fn?.parameters as Record<string, unknown>) : {}
const fn = isObj(raw.function)
? raw.function
: (raw.type === undefined || raw.type === "function") && typeof raw.name === "string"
? raw
: undefined
const fnName = fn && typeof fn.name === "string" ? fn.name : undefined
// Function / gateway tool.
if (fnName) {
const parsed = parseGatewayToolName(fnName)
const params = isObj(fn?.parameters) ? (fn?.parameters as Record<string, unknown>) : {}

…ly edits

Address review feedback on #5038. (1) Regression fix: the rewritten normalizeTool only checked raw.function, so a flat legacy function tool {name,description,parameters} (no wrapper) fell through to the generic 'Tool' branch — lost its fn:<name> identity, rawKey, params and field diffs. Restore flat-function detection in BOTH normalizeTool (accessors) and agentItemIdentity (identity), guarded on type undefined/"function" so reference/builtin tools aren't misread. (2) toolRowDetail now returns "changed" instead of undefined when fingerprint-based edit detection flags a change diffToolFields can't itemize, so an 'edited' badge is never unexplained. Added flat-function + added/removed builtin tests (33/33).
@ardaerzin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/agenta-entities/src/workflow/commitDiff/classify.ts (1)

103-105: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Gate field-level diffs by isFunction.

Line 105 still computes diffToolFields for every fingerprint change, but the NormalizedTool contract says only function tools get field-level diffs. Reference/builtin edits should register as edited with the generic "changed" detail.

Proposed fix
-            edited.push({tool, fields: diffToolFields(prev, tool)})
+            edited.push({
+                tool,
+                fields: prev.isFunction && tool.isFunction ? diffToolFields(prev, tool) : [],
+            })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fe169db3-3e32-4945-a591-b18d752a130c

📥 Commits

Reviewing files that changed from the base of the PR and between c2983b7 and 85e051c.

📒 Files selected for processing (4)
  • web/packages/agenta-entities/src/workflow/commitDiff/accessors.ts
  • web/packages/agenta-entities/src/workflow/commitDiff/classify.ts
  • web/packages/agenta-entities/src/workflow/commitDiff/identity.ts
  • web/packages/agenta-entities/tests/unit/agent-commit-diff.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/packages/agenta-entities/tests/unit/agent-commit-diff.test.ts
  • web/packages/agenta-entities/src/workflow/commitDiff/accessors.ts

Address review feedback on #5038. diffToolFields was called for every fingerprint change; only function tools have inspectable fields (the NormalizedTool contract). Reference/builtin edits now skip it and register as edited with the generic "changed" detail. No behavior change today (non-function tools carry empty params so diffToolFields already returned []), but makes the contract explicit and defensive.
@ardaerzin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ardaerzin
ardaerzin merged commit a015e36 into big-agents Jul 2, 2026
21 of 23 checks passed

This branch was successfully deployed

1 active deployment
Preview — a72c1f32 Deployed Jul 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant