Skip to content

fix(tables): pass enriched query schema to agents - #6305

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
debug/table-query
Aug 6, 2026
Merged

fix(tables): pass enriched query schema to agents#6305
TheodoreSpeaks merged 1 commit into
stagingfrom
debug/table-query

Conversation

@TheodoreSpeaks

@TheodoreSpeaksTheodoreSpeaks commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Resolve mounted table selectors before tool-schema enrichment
  • Fetch table schemas with trusted execution context
  • Pass the enriched table-query schema to agents
  • Add regression coverage

Type of Change

  • Bug fix

Testing

  • 281 focused tests passing
  • Sim typecheck passing
  • Full lint and audit suite passing

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)

@vercel

vercelBot commented Aug 6, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedAug 6, 2026 4:51am

Request Review

@cursor

cursorBot commented Aug 6, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes how agent tools are built (canonical param resolution order and table API/auth) and turns enrichment failures from silent skips into run-stopping errors, which is correct but can surface new failures for misconfigured table tools.

Overview
Fixes agents getting generic table tool schemas when the table was chosen via a mounted selector (tableSelector) instead of a raw tableId.

Canonical resolution before enrichment:transformBlockTool now runs resolveCanonicalResourceParams (selector → canonical ids like tableId) beforecreateLLMToolSchema, so toolEnrichment.dependsOn sees the real table id and enrichment can run.

Trusted execution context for table schema fetch:createLLMToolSchema accepts an optional enrichmentContext (workflowId, workspaceId, executionId, userId) and passes it into enrichTool. Table enrichment loads metadata via authenticated GET /api/table/{tableId}?workspaceId=… (replacing the old /schema route and generic headers). Missing workspaceId/userId or API failures throw instead of returning a null schema.

Fail-fast at execution boundaries: Enrichment failures are wrapped in ToolSchemaEnrichmentError. The agent handler and Pi buildSimToolSpecs rethrow that error so the run stops before the provider call; other tool transform errors still log and skip the tool.

Table tool definitions and types were updated so enrichTableToolSchema always receives context. Regression tests cover enrichment ordering, table fetch/auth, and fail-fast behavior.

Reviewed by Cursor Bugbot for commit e35303d. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-appsBot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR fixes table-tool schema enrichment so agents receive schemas based on the resolved table and authenticated metadata. It also makes enrichment failures abort tool construction rather than silently omitting configured tools.

  • Resolves canonical table identifiers before schema enrichment.
  • Passes trusted workflow execution identity into table metadata requests.
  • Validates table-detail responses and wraps enrichment failures in a dedicated error.
  • Preserves fail-fast behavior at both Agent and Pi tool-building boundaries.
  • Adds regression coverage for authenticated enrichment and failure propagation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported silent tool omission is addressed at both tool-building boundaries, and all current production table-enrichment callers provide the required trusted execution context.

Important Files Changed

FilenameOverview
apps/sim/tools/schema-enrichers.tsFetches and validates table metadata through the authenticated detail route before enriching table-tool schemas.
apps/sim/tools/params.tsPasses trusted execution context to enrichers and wraps enrichment failures in a dedicated error.
apps/sim/providers/utils.tsResolves mounted resource parameters before generating the LLM-visible tool schema.
apps/sim/executor/handlers/agent/agent-handler.tsSupplies execution identity during enrichment and propagates enrichment failures before invoking the provider.
apps/sim/executor/handlers/pi/sim-tools.tsSupplies the same trusted enrichment context and fail-fast handling for Pi tool specifications.

Sequence Diagram

sequenceDiagram
participant Handler as Agent or Pi Handler
participant Transform as transformBlockTool
participant Schema as createLLMToolSchema
participant Table as Authenticated Table API
participant Provider as Agent Provider
Handler->>Transform: Tool config and trusted execution context
Transform->>Transform: Resolve canonical table ID
Transform->>Schema: Resolved params and context
Schema->>Table: Fetch table details with user and workspace identity
Table-->>Schema: Table name and columns
Schema-->>Transform: Enriched description and parameters
Transform-->>Handler: Provider tool configuration
Handler->>Provider: Send enriched tool schema
Note over Schema,Handler: Enrichment errors are wrapped and rethrown
Loading

Reviews (3): Last reviewed commit: "fix(tables): pass enriched query schema ..." | Re-trigger Greptile

Comment threadapps/sim/tools/schema-enrichers.ts
@TheodoreSpeaks

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit de00178. Configure here.

@TheodoreSpeaks

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7137481. Configure here.

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e35303d. Configure here.

Comment threadapps/sim/executor/handlers/agent/agent-handler.ts
@TheodoreSpeaks
TheodoreSpeaks merged commit 079b66c into stagingAug 6, 2026
30 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the debug/table-query branch August 6, 2026 05:08
Sign up for freeto 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

@TheodoreSpeaks