Skip to content

bt functions push: support raw JSON manifest for facet and inline-quickjs preprocessor types #149

@imen-kedir

Description

@imen-kedir

I want my coding agents to iterate on preprocessors and facet prompts for the Topics pipeline and push them to Braintrust through bt. Right now bt functions push can't ship either:

  • Facets require function_data: {type: "facet", prompt, no_match_pattern, preprocessor: {id}}. The runner only collects what the SDK registers, and the SDK has no facet builder.
  • Preprocessors that Topics will actually run must be data.type: "inline" + runtime: "quickjs". SDK push bundles via esbuild instead, and the server rejects invocation with 400: Brainstore preprocessor aggregate only supports built-in 'thread' and inline quickjs preprocessors.

The backend handles both shapes — bt topics config enable already POSTs to /insert-functions (src/topics/api.rs:1015-1060). Today the workaround is curling that endpoint directly, which bypasses bt's auth/profile resolution.

What would solve this

A manifest path on bt functions push:

bt functions push --manifest path/to/function.json -p <project>

JSON matches what /insert-functions accepts. Facet:

{
  "name": "my-lens-issues",
  "slug": "my-lens-issues-v1",
  "function_type": "facet",
  "function_data": {
    "type": "facet",
    "prompt": "...",
    "no_match_pattern": "^NONE",
    "preprocessor": { "id": "<preprocessor-function-id>", "type": "function" }
  }
}

Inline-quickjs preprocessor:

{
  "name": "my-lens-preprocessor",
  "slug": "my-lens-preprocessor-v1",
  "function_type": "preprocessor",
  "function_data": {
    "type": "code",
    "data": {
      "type": "inline",
      "code": "function handler({ span_attributes, input }) { /* ... */ }",
      "runtime_context": { "runtime": "quickjs", "version": "ES2023" }
    }
  }
}

Skip the runner for this path; reuse existing auth/project/if_exists plumbing.

Happy to send a PR — already have a draft.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions