Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Jan 18, 2026

Summary

  • Abstraction to enrich agent context generally
  • Used for KB tags to give Agent knowledge of what tags are available
  • Visibility helpers that were consolidated earlier will also be used here
  • Workflow tool should behave like workflow block in terms of child workflow state usage

Type of Change

  • Bug fix
  • New feature

Testing

Tested manually

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
Copy link

vercel bot commented Jan 18, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 18, 2026 2:58am

Request Review

@icecrasher321 icecrasher321 changed the title improvement( improvement(tool-input): general abstraction to enrich agent context, reuse visibility helpers Jan 18, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 18, 2026

Greptile Summary

This PR introduces a general abstraction for enriching agent context with runtime-dependent schema information, with the primary use case being Knowledge Base tags. The implementation consolidates visibility helpers and improves parameter handling across the codebase.

Key Changes:

  • Created schema-enrichers.ts with enrichKBTagsSchema() and enrichKBTagFiltersSchema() to dynamically fetch KB tag definitions and build schemas for LLM consumption
  • Added SchemaEnrichmentConfig interface to ToolConfig allowing tools to declare parameters that need runtime schema enrichment based on dependency values
  • Consolidated visibility helper functions into params-resolver.ts for reuse across UI and executor contexts
  • Replaced static tag parameters (tag1-tag7) in create_document tool with dynamic documentTags parameter using schema enrichment
  • Added tag parsing utilities (parseDocumentTags, parseTagFilters) to handle various input formats from UI and LLM
  • Migrated tag definitions API endpoint to hybrid auth to support internal JWT access from executors
  • Improved isDeployedContext propagation through handlers and changed workflow executor to use it instead of triggerType
  • Enhanced UI components to use previewContextValues for proper dependency resolution with canonical parameters

Issues Found:

  • Logic issue in resolveSubBlockForParam where fallback matching could miss valid subblocks with different conditions
  • Missing validation for empty dependency values in schema enrichment could cause unnecessary API calls
  • Type validation for boolean tag values could be stricter to prevent malformed data

Confidence Score: 4/5

  • Safe to merge with minor issues - the logic bugs identified are edge cases that may not occur in typical usage
  • The PR implements a solid abstraction pattern with good test coverage (workflow executor tests updated). However, there are a few logic edge cases in parameter resolution and validation that should be addressed. The schema enrichment pattern is well-designed and the consolidation of visibility helpers improves maintainability. The auth changes for tag definitions API are appropriate for internal executor access.
  • Review apps/sim/tools/params.ts for the logic issues in resolveSubBlockForParam and enrichment validation

Important Files Changed

Filename Overview
apps/sim/tools/schema-enrichers.ts New file implementing runtime schema enrichment for KB tags - fetches tag definitions and builds dynamic schemas for LLM consumption
apps/sim/tools/params-resolver.ts New file consolidating visibility helper functions and adding buildPreviewContextValues for canonical value resolution
apps/sim/tools/params.ts Major refactor: added tag parsing utilities, enrichment schema integration, improved parameter filtering, and condition evaluation consolidation
apps/sim/tools/knowledge/create_document.ts Replaced static tag parameters (tag1-7) with dynamic documentTags parameter using schema enrichment for KB-specific tags
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx Added new component wrappers, consolidated condition evaluation, improved canonical value resolution for preview context
apps/sim/app/api/knowledge/[id]/tag-definitions/route.ts Migrated from session-only auth to hybrid auth supporting internal JWT for executor access to tag definitions

Sequence Diagram

sequenceDiagram
    participant UI as Tool Input UI
    participant Store as Block Store
    participant Params as params.ts
    participant Enricher as schema-enrichers.ts
    participant API as Tag Definitions API
    participant Handler as Agent Handler
    participant Provider as Provider Utils
    participant Tool as Tool Execution

    Note over UI,Store: User configures KB ID
    UI->>Store: Set knowledgeBaseId
    
    Note over UI,Params: Build preview context
    UI->>Params: buildPreviewContextValues()
    Params-->>UI: Resolved canonical values
    
    Note over UI,API: Fetch tag definitions for UI
    UI->>API: GET /api/knowledge/{id}/tag-definitions
    API-->>UI: Tag definitions array
    UI->>UI: Render document-tag-entry/tag-filters
    
    Note over Handler,Tool: Agent executes tool with params
    Handler->>Provider: prepareToolExecution(tool, llmArgs)
    Provider->>Params: mergeToolParameters(userParams, llmArgs)
    Params-->>Provider: Merged tool params
    
    Note over Provider,Tool: Create LLM tool schema
    Provider->>Params: createLLMToolSchema(toolConfig, userParams)
    Params->>Params: Check schemaEnrichment config
    
    alt documentTags/tagFilters has enrichment
        Params->>Enricher: enrichKBTagsSchema(knowledgeBaseId)
        Enricher->>API: GET /api/knowledge/{id}/tag-definitions
        API-->>Enricher: Tag definitions
        Enricher-->>Params: Dynamic schema with KB tags
        Params-->>Provider: LLM schema with enriched params
    end
    
    Provider->>Tool: Execute with merged params + enriched schema
    
    Note over Tool,Params: Parse and normalize tags
    Tool->>Params: parseDocumentTags(value)
    Params-->>Tool: Normalized tag entries
    Tool->>Params: formatDocumentTagsForAPI(tags)
    Params-->>Tool: documentTagsData JSON
    
    Tool-->>Handler: Tool execution result
Loading

@icecrasher321
Copy link
Collaborator Author

@greptile

@icecrasher321
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

25 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321 icecrasher321 merged commit 0fcd526 into staging Jan 18, 2026
11 checks passed
@icecrasher321 icecrasher321 deleted the improvement/tool-input branch January 18, 2026 03:13
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.

2 participants