@@ -111,6 +111,68 @@ it.effect("forks a session stored under the instance's own CLAUDE_CONFIG_DIR", (
111111 } ) . pipe ( Effect . provide ( forkRunnerLayer ) ) ,
112112 ) . pipe ( Effect . provide ( NodeServices . layer ) ) ,
113113) ;
114+
115+ it . effect . each ( [ "absolute" , "relative" ] as const ) (
116+ "reads a fork model from a %s custom Claude configuration directory" ,
117+ ( kind ) =>
118+ Effect . scoped (
119+ Effect . gen ( function * ( ) {
120+ const fileSystem = yield * FileSystem . FileSystem ;
121+ const path = yield * Path . Path ;
122+ const configDir = yield * fileSystem . makeTempDirectoryScoped ( {
123+ prefix : "t3-claude-model-config-" ,
124+ } ) ;
125+ const projectDir = yield * writeClaudeSession ( configDir ) ;
126+ const agentId = "agent-test" ;
127+ const subagentsDir = path . join ( projectDir , FORK_SESSION_ID , "subagents" ) ;
128+ yield * fileSystem . makeDirectory ( subagentsDir , { recursive : true } ) ;
129+ yield * fileSystem . writeFileString (
130+ path . join ( subagentsDir , `agent-${ agentId } .jsonl` ) ,
131+ [
132+ {
133+ type : "user" ,
134+ uuid : "aaaaaaaa-0000-4000-8000-000000000011" ,
135+ parentUuid : null ,
136+ sessionId : FORK_SESSION_ID ,
137+ agentId,
138+ isSidechain : true ,
139+ cwd : "/repo" ,
140+ message : { role : "user" , content : "hello" } ,
141+ } ,
142+ {
143+ type : "assistant" ,
144+ uuid : "aaaaaaaa-0000-4000-8000-000000000012" ,
145+ parentUuid : "aaaaaaaa-0000-4000-8000-000000000011" ,
146+ sessionId : FORK_SESSION_ID ,
147+ agentId,
148+ isSidechain : true ,
149+ cwd : "/repo" ,
150+ message : {
151+ role : "assistant" ,
152+ model : "claude-haiku-4-5" ,
153+ content : [ { type : "text" , text : "hi" } ] ,
154+ } ,
155+ } ,
156+ ]
157+ . map ( ( entry ) => JSON . stringify ( entry ) )
158+ . join ( "\n" ) + "\n" ,
159+ ) ;
160+ const runner = yield * ClaudeAgentSdkQueryRunner ;
161+ const model = yield * runner . subagentModel ( {
162+ sessionId : FORK_SESSION_ID ,
163+ agentId,
164+ dir : "/repo" ,
165+ environment : {
166+ ...process . env ,
167+ CLAUDE_CONFIG_DIR : kind === "relative" ? path . relative ( "/repo" , configDir ) : configDir ,
168+ } ,
169+ threadId : ThreadId . make ( "thread-fork-model-config" ) ,
170+ providerSessionId : ProviderSessionId . make ( "session-fork-model-config" ) ,
171+ } ) ;
172+ assert . equal ( model , "claude-haiku-4-5" ) ;
173+ } ) . pipe ( Effect . provide ( forkRunnerLayer ) ) ,
174+ ) . pipe ( Effect . provide ( NodeServices . layer ) ) ,
175+ ) ;
114176const realQueryRunner = layerQueryRunner . pipe (
115177 Layer . provide ( PortScanner . layerTest ) ,
116178 Layer . provide (
0 commit comments