Skip to content

fix(blocks): read the mapper operation from the tool-call context and ratchet raw reads - #10070

Merged
waleedlatif1 merged 5 commits into
stagingfrom
fix/mapper-operation-context
Nov 15, 2026
Merged

waleedlatif1 merged 5 commits into
stagingfrom
fix/mapper-operation-context

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

When an Agent calls a block-backed tool (and likewise Pi and Human-in-the-loop v2), the block's tools.config.params mapper receives the stored tool row's params plus the model's args. The operation arrives only as context.operation, because a stored tool row keeps its operation outside its params. A mapper that branches on params.operation therefore runs its no-operation path on every tool call.

On staging that causes real failures:

  • Google Drive drops the file the user picked in the tool row.
  • Jira sends labels: "bug, urgent" as a string, which fails validation.
  • Bitbucket, the AWS blocks, Google Forms and Word throw Invalid operation: undefined, so the tool gets unmerged raw params.

Injecting the operation centrally would make branches live that have never run on the agent path, and some of them overwrite model args (Jira comment body, GitLab search/orderBy, Slack edit_canvas). So the fix is per block, and this PR adds the guard rail for that work:

  • mapperOperation(params, context) in @/blocks/utils reads the trusted context first and falls back to the canvas input. Context comes first because six tools declare their own operation param (Slack edit_canvas), which the model fills with a tool value.
  • The 18 mappers that already used a context fallback now call the helper. Each had exactly one read site that already fell back to context, so behavior is unchanged except where both values are set and differ; in that case the trusted context now wins.
  • check:mapper-operation is a per-file ratchet, built on the TypeScript AST, over raw reads of the operation inside mappers. It catches property and element access, aliases, rest bindings, used destructured bindings, and same-file helpers. Strip-only destructuring is exempt. The baseline is 505 reads in 173 files and can only shrink. Follow-up PRs fix those mappers one family at a time, each with a review of the branches that become live.

Test plan

  • scripts/check-mapper-operation.test.ts covers each read form and each exemption.
  • bun run check:mapper-operation passes against the generated baseline.
  • Existing vitest suites for the 18 migrated blocks pass (15 files, 137 tests).

🤖 Generated with Claude Code

… ratchet raw reads

A block's tools.config.params mapper gets the operation only as context.operation on a tool
call (Agent tool rows, Pi, Human v2), so branches on params.operation take the no-operation
path there. Add mapperOperation(params, context), move the mappers that already fell back to
context onto it, and add check:mapper-operation, a per-file ratchet over the remaining
raw reads (505 in 173 files) so they can only shrink.
@waleedlatif1
waleedlatif1 requested a review from a team as a code owner November 15, 2026 22:17
@vercel

vercel Bot commented Nov 15, 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 Ignored Ignored Preview Nov 15, 2026 11:03pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with one non-blocking audit issue.

Findings

  1. P2 Safe helper results get flagged ▶

Summary

The PR adds mapperOperation and moves 18 block mappers to it. It also adds an audit that limits raw operation reads.

  • Block tools now choose their operation from the tool-call context.
  • A new check tracks raw operation reads in block mappers.

Reviews (4) · Last reviewed commit: "fix(audits): follow local copies when de..." · Reviewed by Greptile

Comment thread apps/sim/blocks/blocks/gauge.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread apps/sim/blocks/blocks/box.ts Resolved

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

Turn on auto-fix | Re-trigger cubic

Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
…per results, and shadowed names in check:mapper-operation; drop _operation strips
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 23 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/blocks/blocks/intercom.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
Comment thread scripts/check-mapper-operation.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread scripts/check-mapper-operation.ts Resolved

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 23 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread scripts/check-mapper-operation.ts Resolved

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 23 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread scripts/check-mapper-operation.ts Resolved
@waleedlatif1
waleedlatif1 merged commit 41a5f38 into staging Nov 15, 2026
96 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/mapper-operation-context branch November 15, 2026 23:40
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