Skip to content

MCP: Fix suggestions in INVALID_CEL errors and CEL references generated from the environment #1122

Open

Description

@kyasbal

Part of #1049 / Follows up #1042

Summary

Finish the remaining parts of #1042: fix suggestions in INVALID_CEL errors and compile-time validation of path keys.

Background

CEL errors

  • The CEL errors spec of MCP: Workbench read layer and common conventions #1042 returns Position, Did you mean, and Available keys in path, or the available function names for a misspelled function. An agent without the plugin must be able to fix the expression from the error alone.
  • The acceptance criteria of MCP: Workbench read layer and common conventions #1042 say: "Passing invalid CEL returns Markdown starting with Error: INVALID_CEL, containing the error position and fix suggestions, with isError: true."
  • mdtemplate.InvalidCELError in pkg/server/mcp/mdtemplate/template.go writes only Field, Expression, and Message. The position appears only inside the cel-go message text.

path keys

  • path is declared as map<string,string> in pkg/server/workbench/cel/env.go, so the MCP: Workbench read layer and common conventions #1042 example path.namspace == 'default' passes ValidateTimelineQuery.
  • Indexing a level that a timeline does not have used to abort the whole filter with "no such key". The fix for that bug makes a missing level evaluate to an empty string. As a result, a misspelled key now matches nothing instead of failing. Compile-time validation is the only way to report it.

CEL references (Resolved in #1165, #1167, #1177)

  • The code-generated CEL reference pipeline (pkg/server/workbench/cel/reference.go and make generate-agent-plugin-references) was replaced with static reference files (plugins/khi/skills/khi-investigation/references/cel-timeline.md and cel-log.md, using lowercase kind names) paired with the dynamic Filter vocabulary section in khi://inspections/{id}.

Proposed work

  1. Validate path keys at compile time against the registered timeline type labels, in ValidateTimelineQuery. The Web UI uses the same validation through CELValidationServer.
  2. Return structured CEL errors: Position with line and column from the cel-go issues, Did you mean by edit distance, the available path keys for an undefined key, and the available functions for an undeclared function.

Acceptance criteria

  • path.namspace == 'default' returns INVALID_CEL with Position, Did you mean: path.namespace, and the available keys.
  • A misspelled function name returns INVALID_CEL with the available function names.

Related code

  • pkg/server/workbench/cel/env.go: CEL environments and declarations.
  • pkg/server/mcp/mdtemplate/template.go: InvalidCELError.
  • pkg/server/api/v1/cel_validation.go: Validation for the Web UI.

Activity

  1. added
    type:feature
    area:backend-core
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backend-coretype:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions