Starlark Code Mode and Built-In Read-Only Tools
Standard LLM tool loops waste turns and tokens fetching one resource at a time and stuffing full JSON payloads into conversation history. Faber’s Starlark Code Mode lets the model run one small, hermetic Starlark script (run_script) that calls multiple read-only tools in parallel, filters the results in memory, and returns only the distilled facts.
This guide covers Starlark Code Mode and Faber’s built-in read-only OCI registry inspection tools.
Starlark Multi-Tool Code Mode
Section titled “Starlark Multi-Tool Code Mode”Code Mode embeds a hermetic go.starlark.net interpreter inside the agent runner (internal/engine/codemode):
- Hermetic by construction:
load()is disabled, and scripts have zero filesystem, shell, or raw network access. Scripts can only call the authorized read-only tools bound into the runner. - Hard-denied mutations: Sandbox tools (
sandbox_*),submit_result,run_script, and mutating Kubernetes or write tools are unconditionally excluded from Starlark bindings. - Strict per-script budgets: Every invocation is bounded by bytecode step count (
maxSteps, default100000), wall-clock timeout (timeout, default15s), nested tool calls (maxToolCalls, default25), serializedresult()size (maxOutputBytes, default32768), andbatch()worker concurrency (maxBatchConcurrency, default4, clamped at8). - Compact prompt surface: When
hideWrappedToolsis enabled (the default), individual wrapped read-only tools are collapsed behindrun_scriptto save prompt tokens whilerun_script,submit_result, and any sandbox tools stay directly callable.
Built-In Starlark Namespaces and Helpers
Section titled “Built-In Starlark Namespaces and Helpers”Inside run_script, Faber exposes wrapped read-only tools under clean namespaces:
k8s:k8s.list,k8s.get,k8s.logs,k8s.eventsmcp.<server>:mcp.<server>.<tool>for each configured Streamable HTTP MCPConnectoroci:oci.list_tags,oci.resolve_digestfor configured OCI registryConnectorendpointstools:tools.<name>for any other bound read-only tools
Three built-in helpers keep scripts short and fast:
help()orhelp(k8s.list): Returns compact parameter signatures and descriptions for bound tools so the model can discover exact argument names without bloating the system prompt.batch([call(fn, key="val"), call(other_fn, key="val")]): Runs multiple read-only tool calls concurrently in a bounded Go worker pool and returns their results in the same order.result(value): Sets the compact JSON value returned to the LLM turn (every script must callresult(value)).
Example Starlark script executed by the model in a single turn:
pods = k8s.list(resource="pods", namespace="apps")unready = [p["name"] for p in pods["items"] if not p["ready"]]
logs, tags = batch([ call(k8s.logs, namespace="apps", name=unready[0]), call(oci.list_tags, repository="ghcr.io/my-org/checkout", semverOnly=True, maxTags=5),])
errors = [line for line in logs.splitlines() if "ERROR" in line]result({ "pod": unready[0], "errorCount": len(errors), "latestTag": tags["tags"][0] if tags["tags"] else "",})For parameter names that match a Starlark keyword (such as from or in), scripts can pass a single positional dict argument instead of keyword arguments, for example mcp.prom.query({"from": "5m"}).
Built-In Read-Only OCI Registry Inspection (Connector type: oci)
Section titled “Built-In Read-Only OCI Registry Inspection (Connector type: oci)”Declare one or more Connector resources with spec.type: oci to expose two operator-side, SSRF-guarded Distribution Spec v2 tools without pulling image layers or blobs:
oci_list_tags(oci.list_tagsin Code Mode): Lists repository tags with optionalprefix,semverOnlysorting, andmaxTags(default50, hard cap200).oci_resolve_digest(oci.resolve_digestin Code Mode): Resolves a tag or reference viaHEADandGETmanifest lookup and returns content digest, media type, and multi-arch platform metadata.
apiVersion: faberops.dev/v1beta1kind: Connectormetadata: name: ghcr-readonly namespace: faberspec: type: oci url: https://ghcr.io capabilities: - read secretRef: name: ghcr-pull-credentials key: .dockerconfigjsonGuardrails:
- Each
Connectorspec.urlhost is added to an exact registry allowlist (for exampleghcr.ioorregistry.k8s.io). Empty allowlists fail closed and wildcards (*,*.example.com) are rejected. - Optional
secretRefsupplies pull credentials from a same-namespace Secret (supporting.dockerconfigjson,username:password, or a bearer token). - Environment HTTP proxies are ignored and private, loopback, and link-local IP ranges are blocked at dial time.
See config/samples/connector-observability.yaml and the CRD API Reference for configuring Connector resources.
Offline Verification
Section titled “Offline Verification”Faber’s offline eval suite includes a multi-tool Starlark Code Mode fixture (codemode-multi-tool) verified through the real engine and governors:
make eval