Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/angry-cooks-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@openai/agents-core": patch
"@openai/agents-extensions": patch
"@openai/agents-openai": patch
---

Fix #233 - eliminate confusion with "input_text" type items with role: "assistant"
1 change: 0 additions & 1 deletion packages/agents-core/src/types/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ export type ComputerAction = z.infer<typeof computerActions>;
export const AssistantContent = z.discriminatedUnion('type', [
OutputText,
Refusal,
InputText,
AudioContent,
ImageContent,
]);
Expand Down
29 changes: 8 additions & 21 deletions packages/agents-extensions/src/aiSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,16 @@ export function itemsToLanguageV1Messages(
messages.push({
role,
content: content
.filter((c) => c.type === 'input_text' || c.type === 'output_text')
.filter((c) => c.type === 'output_text')
.map((c) => {
const { providerData: contentProviderData } = c;
if (c.type === 'output_text') {
return {
type: 'text',
text: c.text,
providerMetadata: {
...(contentProviderData ?? {}),
},
};
}
if (c.type === 'input_text') {
return {
type: 'text',
text: c.text,
providerMetadata: {
...(contentProviderData ?? {}),
},
};
}
const exhaustiveCheck = c satisfies never;
throw new UserError(`Unknown content type: ${exhaustiveCheck}`);
return {
type: 'text',
text: c.text,
providerMetadata: {
...(contentProviderData ?? {}),
},
};
}),
providerMetadata: {
...(providerData ?? {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function extractAllAssistantContent(
}
const out: ChatCompletionAssistantMessageParam['content'] = [];
for (const c of content) {
if (c.type === 'output_text' || c.type === 'input_text') {
if (c.type === 'output_text') {
out.push({
type: 'text',
text: c.text,
Expand Down