Add durable per-thread environment variables to thread spawn - #3314
Open
aivanov93 wants to merge 1 commit into
Open
Add durable per-thread environment variables to thread spawn#3314aivanov93 wants to merge 1 commit into
aivanov93 wants to merge 1 commit into
Conversation
aivanov93
force-pushed
the
bb/add-per-thread-env-vars-to-bb-thr_h8mvrp7zf7
branch
from
September 9, 2026 04:45
a8bda81 to
0911a87
Compare
aivanov93
marked this pull request as ready for review
September 9, 2026 16:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
The use of env vars at agent launch is a common flow used by most harnesses but bb currently does not allow passing custom env vars to
thread spawn. This PR addresses that. Lots of files touched but mostly a pass through from different surfaces.What was wrong
Thread creation had no way to carry caller-supplied process configuration from the CLI or SDK to the provider running on a host daemon. This is a common need, e.g. #2927.
What changed
envVarstothreads.spawn()(includingbb.sdk.threads.spawn()) and repeatablebb thread spawn --env KEY=VALUE. Empty values and additional=characters are preserved; duplicate names are rejected.BB_*, reject null bytes, and limit maps to 32 entries, 16 KiB per value, and 64 KiB serialized.0115_familiar_thunderbirdagainst current upstream migrations and bumpHOST_DAEMON_PROTOCOL_VERSIONfrom 195 to 196 for the new required internal field.Scope: values are supplied at spawn time and retained for that thread. This does not add mutation through
thread tell --env,--env-file, provider-wide defaults, or inheritance through the separate fork API. Values are stored as plaintext JSON in the server database, not in an encrypted secrets store; the documentation calls out data-directory and shell-history sensitivity.Rebased onto upstream
mainat682f0d2c5, including the bundled-guide move and later-turn Pi/ACP environment fixes. Unrelated formatting changes and unused test instrumentation were removed. Most added lines are the generated Drizzle snapshot.How you verified
Added coverage for validation limits, CLI parsing and HTTP serialization, SDK serialization, migration backfill and persistence, queued dispatch, remote command contracts, runtime precedence/resume/rewind, reserved variables, and masked/public payloads.
Broad validation before the latest rebase:
pnpm exec turbo run typecheck --concurrency=4 --continue— passed, 93 tasks.pnpm exec turbo run build --filter=@bb/cli --filter=@bb/server --filter=@bb/host-daemon --concurrency=3— passed.pnpm exec turbo run lint— passed with existing warnings.@bb/domain,@bb/sdk,@bb/thread-view,@bb/server-contract,@bb/host-daemon-contract,@bb/cli,@bb/agent-runtime,@bb/templates,@bb/db,@bb/host-daemon, and@bb/server— 5,152 tests passed; one server test file skipped by the suite.pnpm exec turbo run test --filter=@bb/db --filter=@bb/host-daemon --filter=@bb/server --concurrency=1 -- --maxWorkers=3. Earlier Git-heavy tests timed out with the local Git wrapper; the rerun used plain Git and Node 24.18.0.oxfmt --checkpassed on 41 changed source/documentation files; excluded generated migration files and five files whose unrelated upstream formatting was deliberately preserved.git diff origin/main --checkpassed.Latest rebase verification (
0911a87d4on682f0d2c5):No live provider/remote-machine manual test was performed; remote forwarding and provider lifecycle behavior are covered by automated tests.
Fixes #2927