Skip to content

Session compaction converts prompt to invalid format #1176

@markb-trustifi

Description

@markb-trustifi

Please read this first

  • Have you read the docs? yes
  • Have you searched for related issues? yes

Describe the bug

After OpenAIResponsesCompactionSession runs compaction it converts prompt images to Responses API format which is not supported by Agents SDK.
That means, it changes
{type: 'input_image', image: 'data:image/jpeg;base64,xxx'}
to:
{type: 'input_image', detail:'auto', file_id:null, image_url: 'data:image/jpeg;base64,xxx'}

Debug information

  • Agents SDK version: (e.g. v0.8.3)
  • Runtime environment (e.g. Node.js 24.11.1)

Repro steps

const session = new OpenAIResponsesCompactionSession({
	client: openai,
	model: 'gpt-5.4',
	underlyingSession: new MemorySession(),
	shouldTriggerCompaction: ({ compactionCandidateItems }) => {
		return compactionCandidateItems.length >= 2;
	}
});
const content = [
	{type: 'input_text', text: 'analyse these images'},
	{type: 'input_image', image: `data:image/jpeg;base64,${Buffer.from(datafile).toString('base64')}`},
];
const history = [
	{role: 'user', content},
	{role: 'assistant', content: [{type: 'output_text', text: 'how can I help?'}]},
];
const prompt = [{role: 'user', content: [{type: 'input_text', text: 'analyse these images'}]}];

await session.addItems(history);
await session.runCompaction();

const agent = new Agent({name: 'agent', model: 'gpt-5.4', modelSettings: {store: false}});
const res = await run(agent, prompt, {session});

Error

Error: 400 Missing mutually exclusive parameters: 'input[0].content[1]'. Ensure you are providing exactly one of: 'file_id' or 'image_url'.

Expected behavior

Agents SDK should either support "image_url" or OpenAIResponsesCompactionSession should convert back from "image_url" to "image".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions