ios: bound assistant image sets and keep output tools quiet
This commit is contained in:
@@ -178,6 +178,26 @@ private func requestBytes(_ request: URLRequest) -> Data {
|
||||
for descriptor in descriptors {
|
||||
row.metadata = .object(["kind": .string("message"), "status": .string("complete"), "agentAttachments": .array([descriptor])])
|
||||
#expect(row.agentAttachments.isEmpty)
|
||||
row.metadata = .object(["kind": .string("message"), "status": .string("complete"), "agentAttachments": .array([image.metadataValue, descriptor])])
|
||||
#expect(row.agentAttachments.isEmpty) // No valid prefix from an invalid output set.
|
||||
}
|
||||
let maximum = (0..<8).map { index in
|
||||
var item = image; item.id = "image-\(index)"; item.sizeBytes = 4 * 1024 * 1024
|
||||
return item
|
||||
}
|
||||
row.metadata = .object(["kind": .string("message"), "status": .string("complete"), "agentAttachments": .array(maximum.map(\.metadataValue))])
|
||||
#expect(row.agentAttachments == maximum) // Exactly eight IDs and 32 MiB.
|
||||
let tooMany = (0..<9).map { index in
|
||||
var item = image; item.id = "image-\(index)"
|
||||
return item
|
||||
}
|
||||
var tooLarge = maximum; tooLarge[0].sizeBytes += 1
|
||||
for invalid in [tooMany, [image, image], tooLarge] {
|
||||
row.role = .assistant
|
||||
row.metadata = .object(["kind": .string("message"), "status": .string("complete"), "agentAttachments": .array(invalid.map(\.metadataValue))])
|
||||
#expect(row.agentAttachments.isEmpty)
|
||||
row.role = .user
|
||||
#expect(row.agentAttachments == invalid) // These new output limits do not change legacy input parsing.
|
||||
}
|
||||
row.role = .user
|
||||
row.metadata = .object(["agentAttachments": .array([sampleAttachment().metadataValue])])
|
||||
|
||||
Reference in New Issue
Block a user