@@ -1519,6 +1519,7 @@ describe("bash tool - background execution", () => {
15191519 expect ( result . success ) . toBe ( true ) ;
15201520 if ( result . success && "backgroundProcessId" in result ) {
15211521 expect ( result . backgroundProcessId ) . toBeDefined ( ) ;
1522+
15221523 // Process ID is now the display name directly
15231524 expect ( result . backgroundProcessId ) . toBe ( "test" ) ;
15241525 } else {
@@ -1527,4 +1528,46 @@ describe("bash tool - background execution", () => {
15271528
15281529 tempDir [ Symbol . dispose ] ( ) ;
15291530 } ) ;
1531+
1532+ it ( "should inject muxEnv environment variables in background mode" , async ( ) => {
1533+ const manager = new BackgroundProcessManager ( "/tmp/mux-test-bg" ) ;
1534+
1535+ const tempDir = new TestTempDir ( "test-bash-bg-mux-env" ) ;
1536+ const config = createTestToolConfig ( tempDir . path ) ;
1537+ config . backgroundProcessManager = manager ;
1538+ config . muxEnv = {
1539+ MUX_MODEL_STRING : "openai:gpt-5.2" ,
1540+ MUX_THINKING_LEVEL : "medium" ,
1541+ } ;
1542+
1543+ const tool = createBashTool ( config ) ;
1544+ const args : BashToolArgs = {
1545+ script : 'echo "MODEL:$MUX_MODEL_STRING THINKING:$MUX_THINKING_LEVEL"' ,
1546+ timeout_secs : 5 ,
1547+ run_in_background : true ,
1548+ display_name : "test-mux-env-bg" ,
1549+ } ;
1550+
1551+ const result = ( await tool . execute ! ( args , mockToolCallOptions ) ) as BashToolResult ;
1552+
1553+ expect ( result . success ) . toBe ( true ) ;
1554+ if ( result . success && "backgroundProcessId" in result ) {
1555+ const outputResult = await manager . getOutput (
1556+ result . backgroundProcessId ,
1557+ undefined ,
1558+ undefined ,
1559+ 2
1560+ ) ;
1561+ expect ( outputResult . success ) . toBe ( true ) ;
1562+ if ( outputResult . success ) {
1563+ expect ( outputResult . output ) . toContain ( "MODEL:openai:gpt-5.2" ) ;
1564+ expect ( outputResult . output ) . toContain ( "THINKING:medium" ) ;
1565+ }
1566+ } else {
1567+ throw new Error ( "Expected background process ID in result" ) ;
1568+ }
1569+
1570+ await manager . terminateAll ( ) ;
1571+ tempDir [ Symbol . dispose ] ( ) ;
1572+ } ) ;
15301573} ) ;
0 commit comments