Skip to content

Commit 1bb4d86

Browse files
Fix #233 - eliminate confusion with "input_text" type items with role: "assistant" (#312)
Co-authored-by: Kazuhiro Sera <[email protected]>
1 parent a51105b commit 1bb4d86

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

.changeset/angry-cooks-wait.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@openai/agents-core": patch
3+
"@openai/agents-extensions": patch
4+
"@openai/agents-openai": patch
5+
---
6+
7+
Fix #233 - eliminate confusion with "input_text" type items with role: "assistant"

packages/agents-core/src/types/protocol.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ export type ComputerAction = z.infer<typeof computerActions>;
241241
export const AssistantContent = z.discriminatedUnion('type', [
242242
OutputText,
243243
Refusal,
244-
InputText,
245244
AudioContent,
246245
ImageContent,
247246
]);

packages/agents-extensions/src/aiSdk.ts

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,29 +116,16 @@ export function itemsToLanguageV1Messages(
116116
messages.push({
117117
role,
118118
content: content
119-
.filter((c) => c.type === 'input_text' || c.type === 'output_text')
119+
.filter((c) => c.type === 'output_text')
120120
.map((c) => {
121121
const { providerData: contentProviderData } = c;
122-
if (c.type === 'output_text') {
123-
return {
124-
type: 'text',
125-
text: c.text,
126-
providerMetadata: {
127-
...(contentProviderData ?? {}),
128-
},
129-
};
130-
}
131-
if (c.type === 'input_text') {
132-
return {
133-
type: 'text',
134-
text: c.text,
135-
providerMetadata: {
136-
...(contentProviderData ?? {}),
137-
},
138-
};
139-
}
140-
const exhaustiveCheck = c satisfies never;
141-
throw new UserError(`Unknown content type: ${exhaustiveCheck}`);
122+
return {
123+
type: 'text',
124+
text: c.text,
125+
providerMetadata: {
126+
...(contentProviderData ?? {}),
127+
},
128+
};
142129
}),
143130
providerMetadata: {
144131
...(providerData ?? {}),

packages/agents-openai/src/openaiChatCompletionsConverter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function extractAllAssistantContent(
3737
}
3838
const out: ChatCompletionAssistantMessageParam['content'] = [];
3939
for (const c of content) {
40-
if (c.type === 'output_text' || c.type === 'input_text') {
40+
if (c.type === 'output_text') {
4141
out.push({
4242
type: 'text',
4343
text: c.text,

0 commit comments

Comments
 (0)