@@ -192,95 +192,77 @@ describe("SessionStore", () => {
192192 } ) ,
193193 )
194194
195- it . effect ( "omits inline data URIs on read tool parts in messages list while retaining them on message and context" , ( ) =>
196- Effect . gen ( function * ( ) {
197- const sessionID = Session . ID . make ( "ses_read_media" )
198- yield * seedSessions ( [ { id : sessionID , updated : 0 } ] )
199- const database = yield * Database . Service
200- const store = yield * SessionStore . Service
201- const assistantMessageID = SessionMessage . ID . make ( "msg_step_start" )
202- const inlineUri = `data:image/png;base64,${ "A" . repeat ( 4096 ) } `
203- const created = DateTime . makeUnsafe ( 100 )
204- const encoded = Schema . encodeSync ( SessionMessage . Info ) (
205- SessionMessage . Assistant . make ( {
206- id : assistantMessageID ,
207- type : "assistant" ,
208- agent : Agent . ID . make ( "build" ) ,
209- model : { providerID : Provider . ID . make ( "anthropic" ) , id : Model . ID . make ( "claude-sonnet-4-5" ) } ,
210- time : { created, completed : DateTime . makeUnsafe ( 120 ) } ,
211- content : [
212- {
213- type : "tool" ,
214- id : "call_read_1" ,
215- name : "read" ,
216- time : { created, completed : DateTime . makeUnsafe ( 120 ) } ,
217- state : {
218- status : "completed" ,
219- input : { path : "screenshot.png" } ,
220- content : [
221- { type : "text" , text : "Image read successfully" } ,
222- { type : "file" , uri : inlineUri , mime : "image/png" , name : "screenshot.png" } ,
223- ] ,
195+ describe . each ( [ "read" , "execute" ] ) ( "%s media" , ( name ) => {
196+ it . effect ( "omits inline data URIs in messages list while retaining them on message and context" , ( ) =>
197+ Effect . gen ( function * ( ) {
198+ const sessionID = Session . ID . make ( "ses_read_media" )
199+ yield * seedSessions ( [ { id : sessionID , updated : 0 } ] )
200+ const database = yield * Database . Service
201+ const store = yield * SessionStore . Service
202+ const assistantMessageID = SessionMessage . ID . make ( "msg_step_start" )
203+ const inlineUri = `data:image/png;base64,${ "A" . repeat ( 4096 ) } `
204+ const created = DateTime . makeUnsafe ( 100 )
205+ const encoded = Schema . encodeSync ( SessionMessage . Info ) (
206+ SessionMessage . Assistant . make ( {
207+ id : assistantMessageID ,
208+ type : "assistant" ,
209+ agent : Agent . ID . make ( "build" ) ,
210+ model : { providerID : Provider . ID . make ( "anthropic" ) , id : Model . ID . make ( "claude-sonnet-4-5" ) } ,
211+ time : { created, completed : DateTime . makeUnsafe ( 120 ) } ,
212+ content : [
213+ {
214+ type : "tool" ,
215+ id : "call_read_1" ,
216+ name,
217+ time : { created, completed : DateTime . makeUnsafe ( 120 ) } ,
218+ state : {
219+ status : "completed" ,
220+ input : { path : "screenshot.png" } ,
221+ content : [
222+ { type : "text" , text : "Image read successfully" } ,
223+ { type : "file" , uri : inlineUri , mime : "image/png" , name : "screenshot.png" } ,
224+ ] ,
225+ } ,
224226 } ,
225- } ,
226- ] ,
227- } ) ,
228- )
229- const { id, type, ...data } = encoded
230- yield * database . db
231- . insert ( SessionMessageTable )
232- . values ( {
233- id : SessionMessage . ID . make ( id ) ,
234- session_id : sessionID ,
235- type,
236- seq : 2 ,
237- time_created : 100 ,
238- data,
239- } )
240- . run ( )
241-
242- const listed = yield * store . messages ( { sessionID } )
243- expect ( listed ) . toHaveLength ( 1 )
244- const assistant = listed [ 0 ] !
245- expect ( assistant . type ) . toBe ( "assistant" )
246- if ( assistant . type !== "assistant" ) return
247- expect ( assistant . content ) . toMatchObject ( [
248- {
249- type : "tool" ,
250- name : "read" ,
251- state : {
252- status : "completed" ,
253- content : [ { type : "text" , text : "Image read successfully" } ] ,
254- } ,
255- } ,
256- ] )
227+ ] ,
228+ } ) ,
229+ )
230+ const { id, type, ...data } = encoded
231+ yield * database . db
232+ . insert ( SessionMessageTable )
233+ . values ( {
234+ id : SessionMessage . ID . make ( id ) ,
235+ session_id : sessionID ,
236+ type,
237+ seq : 2 ,
238+ time_created : 100 ,
239+ data,
240+ } )
241+ . run ( )
257242
258- const single = yield * store . message ( assistant . id )
259- expect ( single ?. message ) . toMatchObject ( {
260- type : "assistant" ,
261- content : [
243+ const listed = yield * store . messages ( { sessionID } )
244+ expect ( listed ) . toHaveLength ( 1 )
245+ const assistant = listed [ 0 ] !
246+ expect ( assistant . type ) . toBe ( "assistant" )
247+ if ( assistant . type !== "assistant" ) return
248+ expect ( assistant . content ) . toMatchObject ( [
262249 {
263250 type : "tool" ,
264- name : "read" ,
251+ name,
265252 state : {
266253 status : "completed" ,
267- content : [
268- { type : "text" , text : "Image read successfully" } ,
269- { type : "file" , uri : inlineUri , mime : "image/png" , name : "screenshot.png" } ,
270- ] ,
254+ content : [ { type : "text" , text : "Image read successfully" } ] ,
271255 } ,
272256 } ,
273- ] ,
274- } )
257+ ] )
275258
276- const context = yield * store . context ( sessionID )
277- expect ( context ) . toMatchObject ( [
278- {
259+ const single = yield * store . message ( assistant . id )
260+ expect ( single ?. message ) . toMatchObject ( {
279261 type : "assistant" ,
280262 content : [
281263 {
282264 type : "tool" ,
283- name : "read" ,
265+ name,
284266 state : {
285267 status : "completed" ,
286268 content : [
@@ -290,8 +272,28 @@ describe("SessionStore", () => {
290272 } ,
291273 } ,
292274 ] ,
293- } ,
294- ] )
295- } ) ,
296- )
275+ } )
276+
277+ const context = yield * store . context ( sessionID )
278+ expect ( context ) . toMatchObject ( [
279+ {
280+ type : "assistant" ,
281+ content : [
282+ {
283+ type : "tool" ,
284+ name,
285+ state : {
286+ status : "completed" ,
287+ content : [
288+ { type : "text" , text : "Image read successfully" } ,
289+ { type : "file" , uri : inlineUri , mime : "image/png" , name : "screenshot.png" } ,
290+ ] ,
291+ } ,
292+ } ,
293+ ] ,
294+ } ,
295+ ] )
296+ } ) ,
297+ )
298+ } )
297299} )
0 commit comments