Skip to content

fix(agent): keep nested tool basic/advanced modes attached to their tools - #7804

Merged
waleedlatif1 merged 4 commits into
stagingfrom
fix/tool-canonical-modes-atomic-reorder
Sep 13, 2026
Merged

fix(agent): keep nested tool basic/advanced modes attached to their tools#7804
waleedlatif1 merged 4 commits into
stagingfrom
fix/tool-canonical-modes-atomic-reorder

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Nested agent tool basic/advanced modes (e.g. Jira "Project" selector vs. manual) are keyed by tool array position in canonicalModes, so a reorder or removal has to move them with the tools
  • API / Chat: the workflow edit engine replaced the tools array without reindexing modes, so reordering tools through POST /api/v2/workflows/{id}/operations swapped each tool's mode. It now reindexes after every batch that rewrites a tool list, matching tools by content (ignoring isExpanded), then by type so in-place param edits keep their modes. Removed tools' modes are dropped. Covers every tool-input field, not just tools
  • Editor: a drag-reorder or removal was saved as two independent socket writes (replace-canonical-modes + subblock-update), so one could persist without the other and leave modes on the wrong tools. It is now one subblock-update-with-canonical-modes op, written in one transaction
  • Queue coalesces the new op with pending updates to the same field. A value-only update never drops a pending op that carries modes
  • replace-canonical-modes is no longer sent but still accepted and applied, so tabs loaded before this deploy keep working. A new client talking to a realtime server that hasn't rolled out yet gets a validation error (offline banner, no corruption) until the deploy completes

Type of Change

  • Bug fix

Testing

  • Unit tests for content-based reindexing (reorder, in-place edits, removal, new tools, type changes, duplicates, legacy keys)
  • Engine tests through applyOperationsToWorkflowState (confirmed they fail without the fix)
  • Realtime persistence (both fields in one update, locked block rejected without writing either), permissions, queue coalescing
  • type-check (sim, realtime, realtime-protocol), lint, check:audits, block registry and docs manifest checks pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

https://claude.ai/code/session_01WbCdLsJxoQ9gb41Pzfxo68

…ools

Tool canonical-mode overrides are keyed by array position, so a reorder or
removal must move them with the tools.

- Workflow edit engine (v2 operations API, Chat) reindexes modes when a batch
  rewrites a block's tool list, matching tools by content, then by type
- Editor persists the tool list and reindexed modes in one realtime operation
  instead of two independent writes that could partially persist
@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 13, 2026 7:27am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable new issue or outstanding previous finding remains.

Summary

  • Reindexes canonical modes after programmatic workflow edits across registered tool-input fields.
  • Persists editor tool-list and canonical-mode updates atomically through a shared realtime operation.
  • Updates protocol validation, permissions, remote application, and queue coalescing for the new operation.
  • Retains the legacy canonical-mode replacement operation for rolling-deployment compatibility.
  • Adds coverage for matching behavior, persistence, permissions, protected blocks, and queue supersession.

Diagram

sequenceDiagram
    participant Editor
    participant LocalStores as Local stores
    participant Queue as Operation queue
    participant Realtime
    participant Database

    Editor->>Editor: Reorder or remove nested tools
    Editor->>Editor: Reindex position-scoped canonical modes
    Editor->>LocalStores: Apply tool list and replacement modes
    Editor->>Queue: Enqueue one combined subblock operation
    Queue->>Realtime: Send latest coalesced operation
    Realtime->>Realtime: Validate permission and lock state
    Realtime->>Database: Atomically write subblock value and modes
    Realtime-->>Editor: Confirm and broadcast accepted change
Loading

Reviews (4) · Last reviewed commit: "improvement(realtime): share the writabl..."

Comment thread apps/realtime/src/database/operations.ts Outdated
Comment thread apps/sim/lib/workflows/subblocks/visibility.ts
Comment thread apps/realtime/src/database/operations.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/realtime/src/database/operations.ts Outdated
Comment thread apps/sim/lib/workflows/editing/operations.test.ts
Comment thread apps/sim/lib/workflows/editing/engine.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
waleedlatif1 merged commit 14c8f36 into staging Sep 13, 2026
32 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/tool-canonical-modes-atomic-reorder branch September 13, 2026 07:30
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