Skip to content

Plugin SDK: opt-in global execution profiles and native capability requirements #7918

Description

@beaverbeard

The workflow

A user wants one opt-in control to temporarily use a smaller model profile across all eligible existing and new BB threads, then return to each thread's own profile. A profile stays within the thread's provider. Explicit messages and already-queued messages should receive the effective profile at their next safe native turn boundary, without rewriting saved thread options, changing permissions, moving conversations, or interrupting an active turn.

Downshift is one consumer of this mechanism. Its UI already refuses activation when the native capability is absent. The request is for a generic BB/SDK capability; the model choices, toggle design and optional quota trigger belong in the plugin.

What happens today

Source investigation and an isolated executable reproduction use current main at fab82665a3299fae8910f55d7519a3b034a03b9a, Plugin SDK 0.6.168, Node 24.15.0, Linux x64. This is a feature proposal, not a full live stock-BB or real-provider reproduction. No server, database, enrolled host or inference was started for these checks.

The exact extracted current-main schema/functions were executed with a fixture hook registry. Both inline-explicit and queued-frozen fixture contexts proceeded with main-model even though the handler changed its copied tuple to smaller-model and returned it alongside proceed. An amend decision was rejected. Passing BB input 0.50.1 and ranges >=0.50.1 / >=0.6.132 to the current-main compatibility function returned no problems; a deliberately incompatible BB range was correctly rejected. The current SDK in that check was 0.6.168; this does not claim to have run the released 0.50.1 binary.

Reproduce the isolated actual-source checks without a BB install or model call

Save the script below as reproduce.mjs in a new temporary directory, then run:

git init -q bb
git -C bb fetch -q --depth=1 https://github.com/get-bb/bb.git fab82665a3299fae8910f55d7519a3b034a03b9a
git -C bb checkout -q --detach FETCH_HEAD
npm install --no-save --ignore-scripts typescript@5.9.3 zod@4.6.7 semver@7.8.6
node reproduce.mjs ./bb

The script extracts declarations without changing their bodies and transpiles their TypeScript. It supplies only the hook registry/error fixtures and dependencies; the null environment branch must not access a database or host. The queue case is a fixture passed through the real hook-pass functions, not a full native queue-drain integration test.

import assert from 'node:assert/strict';
import {readFileSync,writeFileSync} from 'node:fs';
import {createHash} from 'node:crypto';
import {createRequire} from 'node:module';
import {resolve} from 'node:path';
import vm from 'node:vm';
import {execFileSync} from 'node:child_process';

const root=resolve(process.argv[2]);
const require=createRequire(resolve(process.env.BB_REPRO_DEPS??process.cwd(),'package.json'));
const ts=require('typescript');
const z=require('zod').z;
const semver=require('semver');
const sha=value=>createHash('sha256').update(value).digest('hex');
const sources=[];
function declaration(path,name){
 const text=readFileSync(resolve(root,path),'utf8');
 const source=ts.createSourceFile(path,text,ts.ScriptTarget.Latest,true,ts.ScriptKind.TS);
 let found;
 for(const node of source.statements){
  if(ts.isFunctionDeclaration(node)&&node.name?.text===name)found=node;
  if(ts.isVariableStatement(node)&&node.declarationList.declarations.some(d=>d.name.getText(source)===name))found=node;
 }
 assert(found,`${path}: missing ${name}`);
 const code=found.getText(source);
 sources.push({path,name,sourceSha256:sha(text),declarationSha256:sha(code),line:source.getLineAndCharacterOfPosition(found.getStart(source)).line+1});
 return code;
}
const hooks='apps/server/src/services/threads/dispatch-hooks.ts';
const code=[
 declaration('apps/server/src/services/plugins/sdk-compat.ts','isPluginSdkRangeSatisfied'),
 declaration('apps/server/src/services/plugins/sdk-compat.ts','pluginSdkRangeProblem'),
 declaration('apps/server/src/services/plugins/update-resolver.ts','evaluateCompatibility'),
 declaration('apps/server/src/services/threads/dispatch-attempt.ts','resolveExecutionIntoPayload'),
 ...['messageDispatchHookDecisionSchema','evaluationLock','withEvaluationLock','messageDispatchHookFailure','dispatchRejection','decideWithinBox','dispatchEnvironmentAndHost','dispatchInputText','summarizeDispatchProvenance','buildHookContext','runMessageDispatchHookPass'].map(name=>declaration(hooks,name)),
 'globalThis.actual={evaluateCompatibility,resolveExecutionIntoPayload,messageDispatchHookDecisionSchema,runMessageDispatchHookPass};'
].join('\n');
const sdkVersion=readFileSync(resolve(root,'packages/domain/src/plugin-sdk-version.ts'),'utf8').match(/PLUGIN_SDK_VERSION = "([^"]+)"/)[1];
const waitMax=Number(readFileSync(resolve(root,'packages/domain/src/queued-message.ts'),'utf8').match(/QUEUED_MESSAGE_WAIT_REASON_MAX_LENGTH = (\d+)/)[1]);
let handler;
const provider={listHooks:()=>[{pluginId:'repro',handler:context=>handler(context)}],decisionTimeoutMs:1000,invokeHook:async(_hook,_name,run)=>({ok:true,value:await run()})};
const unused=()=>{throw Error('Fixture must not access database/host');};
class FixtureApiError extends Error{constructor(status,code,message){super(message);this.status=status;this.code=code;}}
const context=vm.createContext({exports:{},z,semver,PLUGIN_SDK_VERSION:sdkVersion,QUEUED_MESSAGE_WAIT_REASON_MAX_LENGTH:waitMax,pluginHookProvider:()=>provider,ApiError:FixtureApiError,getEnvironment:unused,toEnvironmentResponse:unused,getNonDestroyedHostWithStatus:unused,setTimeout,clearTimeout});
vm.runInContext(ts.transpileModule(code,{compilerOptions:{target:ts.ScriptTarget.ES2022,module:ts.ModuleKind.CommonJS}}).outputText,context);
const actual=context.actual;
const json=value=>JSON.parse(JSON.stringify(value));
const compatibility=actual.evaluateCompatibility({bbRange:'>=0.50.1',sdkRange:'>=0.6.132',appVersion:'0.50.1'});
assert.deepEqual(json(compatibility),{effective:[],packaged:[],devMode:false});
assert(actual.evaluateCompatibility({bbRange:'>=999.0.0',sdkRange:'>=0.6.132',appVersion:'0.50.1'}).effective.length>0);
assert.equal(actual.messageDispatchHookDecisionSchema.safeParse({action:'amend',execution:{model:'smaller-model'}}).success,false);
const results=[];
for(const kind of ['inline-explicit','queued-frozen']){
 const execution={providerId:'example-provider',model:'main-model',reasoningLevel:'medium',serviceTier:'default',permissionMode:'full'};
 const source={providerId:'explicit',model:'explicit',reasoningLevel:null,serviceTier:null,permissionMode:'explicit'};
 const input=[{type:'text',text:'fixture only, never sent'}];
 const payload={input,...execution};
 const resolvedBeforeHooks=actual.resolveExecutionIntoPayload(payload,execution);
 let hookTuple;
 handler=c=>{
  c.requestedExecution.model='smaller-model';
  hookTuple=c.requestedExecution.model;
  return {action:'proceed',execution:{model:'smaller-model'}};
 };
 let continued=false;
 const row={threadId:'fixture',initiator:'user',origin:null,originPluginId:null,senderThreadId:null,waitingOn:null};
 const outcome=await actual.runMessageDispatchHookPass({db:null,hub:null},{thread:{id:'fixture'},threadResponse:{id:'fixture'},project:{id:'fixture'},environmentId:null,intendedHostId:null,environmentIntent:null,input,requestedExecution:execution,executionSources:source,attempt:'start-turn',initiator:'user',senderThreadId:null,origin:null,originPluginId:null,startedOnBehalfOf:null,parentThreadId:null,queuedMessages:kind==='inline-explicit'?[]:[row],pluginSubmission:null,continueAfterHooks:async()=>{continued=true;}});
 assert.equal(outcome.kind,'proceed');assert(continued);
 assert.equal(execution.model,'main-model');assert.equal(resolvedBeforeHooks.model,'main-model');
 assert.equal(resolvedBeforeHooks.permissionMode,'full');
 results.push({kind,hookTuple,modelAfterPass:execution.model,resolvedPayloadModel:resolvedBeforeHooks.model});
}
const result={base:execFileSync('git',['-C',root,'rev-parse','HEAD'],{encoding:'utf8'}).trim(),node:process.version,sdkVersion,scope:'Exact extracted current-main schema/functions with fixture hook registry; no server, database, host, install or provider/model call.',compatibility:json(compatibility),amendDecisionAccepted:false,results,dependencies:Object.fromEntries(['typescript','zod','semver'].map(n=>[n,require(`${n}/package.json`).version])),sources,modelsCalled:0};
if(process.env.BB_REPRO_OUTPUT)writeFileSync(process.env.BB_REPRO_OUTPUT,JSON.stringify(result,null,2)+'\n');
console.log(JSON.stringify({base:result.base,sdkVersion,compatibility:result.compatibility,amendDecisionAccepted:false,results,modelsCalled:0},null,2));

Actual output:

{
  "base": "fab82665a3299fae8910f55d7519a3b034a03b9a",
  "sdkVersion": "0.6.168",
  "compatibility": {
    "effective": [],
    "packaged": [],
    "devMode": false
  },
  "amendDecisionAccepted": false,
  "results": [
    {
      "kind": "inline-explicit",
      "hookTuple": "smaller-model",
      "modelAfterPass": "main-model",
      "resolvedPayloadModel": "main-model"
    },
    {
      "kind": "queued-frozen",
      "hookTuple": "smaller-model",
      "modelAfterPass": "main-model",
      "resolvedPayloadModel": "main-model"
    }
  ],
  "modelsCalled": 0
}

What you would expect

Would maintainers support the following two connected extension boundaries? Names and the smallest acceptable implementation should be agreed here before a PR; they need not match the prototype.

  1. An opt-in native effective-execution policy. An owner-scoped experimental_ SDK surface stages a catalog-validated profile and enables/disables it through a revision/CAS and request-ID contract. Core applies it at the final native server/host dispatch boundary shared by explicit, queued and new-thread execution. Policy and user-facing defaults remain server-owned; host/runtime code validates the assigned host's catalog and effective tuple. The owner is a plugin identity, not a model-authored field.
  2. Source-preserving, recoverable behavior. Keep raw model/reasoning/tier, null inheritance, permissions, settings provenance and conversation identity intact. Store immutable original/effective provenance per affected request. An active turn, including steers into it, keeps its current profile; the next safe turn may use the new profile. OFF restores individual semantics. Define atomic replacement/reload, shutdown and disable/uninstall separately; reject overlapping owners unless a deterministic composition rule is explicitly supported. Persistence failure or a registry/journal mismatch must fail closed before transport, while a genuine empty first installation remains valid. An unknown transport outcome must never cause a blind duplicate send.
  3. Capability-aware installation and execution. Put versioned native requirements in the plugin's own manifest, resolved at its exact source. Do not add another copy of manifest requirements to marketplace entries. A native capability query/handshake should report actual server/host semantics, not infer support solely from a numeric BB version or accept a plugin's self-assertion. Missing, unknown or incompatible requirements need an actionable reason instead of a green feature-compatibility claim. An unprobed catalog item/host should be distinguishable from verified compatibility. Keep current behavior for plugins without capability requirements. Revalidate at activation and the actual execution host so enrollment/reconnect cannot bypass the check.

The initial implementation could expose an experimental_executionPolicies service with capability/read/stage/set/restore operations, plus matching SDK/CLI inspection and control, and a manifest native-requirements field. These are proposed names, not existing stock APIs. Changes to the server/daemon wire would use the protocol version appropriate to the landing base; current main is protocol 272. New SDK members would follow docs/api_to_audit.md and the Plugin Guide.

Suggested acceptance tests, not yet run on this base: real migrated SQLite and host-RPC transport doubles for explicit/queued/new dispatch, null and permissions/source preservation, active steer boundaries, CAS/request deduplication, failed writes/unknown sends, owner reload/uninstall, restart with missing/empty/partial registry and remaining journals, native host catalog rejection, and capability absent/present/semantic mismatch. Include a control plugin with no new requirements.

Context and alternatives

A public source prototype exists, with its integration contract. It targets the older df9619d8e8aac4aff00c0c3ff9b8ef4e2823e4f2 base. It has not been ported or validated against current main and is evidence of an explored implementation, not a proposed drop-in patch or a stock-compatible release. We would prefer an upstream mechanism over distributing a separate BB binary.

Polling, changing all thread options, intercepting only our own sends, or replacing/wrapping every provider do not meet the reversible global workflow. A project default only affects inheritance and cannot replace explicit queued tuples.

Duplicate search covered open and closed issues/PRs, including execution policy, global model, plugin capabilities, model override, execution overlay, and focused title queries. Related items read:

I found no existing issue requesting this same reversible global profile plus native-capability contract in the reviewed results. If one should own it, this evidence can be moved there. Please confirm the intended API boundary and whether compatibility should be a linked implementation before a feature PR is opened.

Checks

  • Searched open and closed issues and reviewed the related requests above.
  • Marked observed source-level checks separately from the proposed implementation and unrun integration tests.
  • No model/API inference, production mutation or private deployment data in this report.

AGENT GENERATED

Activity

  1. added
    plugins
    providers
    on Nov 20, 2026
  2. bb-slop-cop commented on Nov 20, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied the missing classifications:

    • Type: Feature
    • Priority: Medium — meaningful optional functionality, with no demonstrated outage or data loss.
    • Effort: High — requires new SDK contracts and coordinated server/host execution behavior.
    • Labels: plugins, providers

    No existing classifications needed preservation; all applied values were verified, including the final Feature type. Reproduction report and fix skipped: this requests new capability and architecture decisions, not a demonstrated bug, so no pull request was safe under the simple-fix rule.

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

    pluginsproviders

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions