Repository navigation
Per-thread environment on t3_thread_launch for external orchestrators
#17328
Replies: 1 comment
|
Another use case for this: a coordinator thread on a laptop drives worker agents on cloud VMs (Boat sandboxes). Each VM can already be a T3 environment through the desktop's SSH route, which installs the matching server by itself. But MCP tools act only on "this environment", so the coordinator cannot start a worker thread on a VM, read it, or be woken when it ends. Today it drives the VMs through their CLI from background shells, and those workers are invisible in T3. An environment target on |
Uh oh!
There was an error while loading. Please reload this page.
Problem or use case
An external orchestrator can now drive T3 through the V2
/mcpclient. It launches many threads in one project witht3_thread_launchandworkspaceStrategy: existing_worktree, each in its own worktree for its own task.Each of those agents needs a few task-scoped values in its process environment:
core.hooksPathoverride, set throughGIT_CONFIG_COUNT/GIT_CONFIG_KEY_n/GIT_CONFIG_VALUE_nTools, hooks and scripts the agent runs read these, not only the model.
t3_thread_launchtakes no environment, and provider processes inherit the T3 server's. So two threads in the same project cannot get different values.The concrete consumer is Firstmate (kunchenguid/firstmate#6904). On 0.0.46 nightly we ran its whole worker lifecycle through
/mcp: launch into an existing worktree, steer, wait, interrupt, archive, and restart. This was the one gap left.The workarounds it forces today:
envblock in.claude/settings.local.json. This only works for Claude, and it writes into the user's checkout.binaryPathper provider instance that looks values up by cwd. This is fragile, and one Codex app-server serves every Codex thread, so a wrapper cannot vary by thread.Neighboring ideas, not duplicates:
Here, the caller supplies the values per launch, and they differ between threads in one project.
Proposed solution (narrowest shape)
env: Record<string, string>ont3_thread_launch.envthe adapter already passes to the SDK.config(for exampleshell_environment_policy.set) looks like the natural carrier, though I'd defer to you on that.PATH,HOME,NODE_OPTIONS,LD_*/DYLD_*, provider home and auth variables such asCLAUDE_CONFIG_DIR,CODEX_HOMEand*_API_KEY. Cap the number of keys and the value length.t3_thread_readshows key names at most.orchestration:operatecredentials with a non-read-only ceiling may set it.Open question: because it is not persisted, a T3 restart drops it. Accepting the same
envont3_thread_configurewould let the caller re-apply it before the next send. I'd welcome a better idea.Alternatives considered
Offer
If you approve the direction and scope, I'm happy to open a PR. If you'd rather implement it differently, that works too.
This write-up was drafted with my AI agent on my behalf.
All reactions