Skip to content

Commit 8fc01fc

Browse files
authored
Add a quick opt-in option to switch to gpt-5 and fix issues around gpt-5 (#363)
1 parent 2e6933a commit 8fc01fc

21 files changed

+248
-68
lines changed

.changeset/two-squids-smell.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@openai/agents-openai': patch
3+
'@openai/agents-core': patch
4+
---
5+
6+
Add a quick opt-in option to switch to gpt-5

examples/basic/hello-world-gpt-5.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ async function main() {
2121
outputType: output,
2222
});
2323

24-
const prompt = 'Tell me about recursion in programming.';
24+
const prompt =
25+
'Tell me about recursion in programming. Quickly responding with a single answer is fine.';
2526
const result = await run(agent, prompt);
2627
console.log(result.finalOutput);
2728

examples/basic/hello-world.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ async function main() {
66
instructions: 'You only respond in haikus.',
77
});
88

9-
const result = await run(agent, 'Tell me about recursion in programming.');
9+
const result = await run(
10+
agent,
11+
'Tell me about recursion in programming. Quickly responding with a single answer is fine.',
12+
);
1013
console.log(result.finalOutput);
1114
// Example output:
1215
// Function calls itself,

examples/basic/reasoning.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ const THINKING_PREFIX = styleText(['bgGray', 'black'], 'Thought');
77
async function main() {
88
const agent = new Agent({
99
name: 'Agent',
10-
model: 'o3',
10+
model: 'gpt-5',
1111
modelSettings: {
1212
providerData: {
1313
reasoning: {
1414
effort: 'high',
1515
summary: 'auto',
1616
},
17+
text: {
18+
verbosity: 'high',
19+
},
1720
},
1821
},
1922
});

examples/financial-research-agent/agents.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type FinancialSearchPlan = z.infer<typeof FinancialSearchPlan>;
4646
export const plannerAgent = new Agent({
4747
name: 'FinancialPlannerAgent',
4848
instructions: plannerPrompt,
49-
model: 'o3-mini',
49+
model: 'gpt-5-mini',
5050
outputType: FinancialSearchPlan,
5151
});
5252

@@ -69,6 +69,7 @@ Focus on key numbers, events, or quotes that will be useful to a financial analy
6969
export const searchAgent = new Agent({
7070
name: 'FinancialSearchAgent',
7171
instructions: searchAgentPrompt,
72+
model: 'gpt-4.1',
7273
tools: [webSearchTool()],
7374
modelSettings: { toolChoice: 'required' },
7475
});
@@ -92,7 +93,7 @@ export type VerificationResult = z.infer<typeof VerificationResult>;
9293
export const verifierAgent = new Agent({
9394
name: 'VerificationAgent',
9495
instructions: verifierPrompt,
95-
model: 'gpt-4o',
96+
model: 'gpt-4.1',
9697
outputType: VerificationResult,
9798
});
9899

examples/handoffs/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
HandoffInputData,
66
handoff,
77
withTrace,
8+
isGpt5Default,
89
} from '@openai/agents';
910
import { removeAllTools } from '@openai/agents-core/extensions';
1011
import { z } from 'zod';
@@ -23,6 +24,12 @@ const randomNumberTool = tool({
2324

2425
// Message filter for handoff (removes tool messages and first two history items)
2526
function spanishHandoffMessageFilter(handoffMessageData: HandoffInputData) {
27+
if (isGpt5Default()) {
28+
console.log(
29+
'GPT-5 models do not work if you remove the toll call results, so this filter does nothing.',
30+
);
31+
return handoffMessageData;
32+
}
2633
// Remove all tool-related messages
2734
return removeAllTools(handoffMessageData);
2835
}

examples/mcp/hosted-mcp-human-in-the-loop.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ async function main(verbose: boolean, stream: boolean): Promise<void> {
2121
};
2222
const agent = new Agent({
2323
name: 'MCP Assistant',
24-
instructions: 'You must always use the MCP tools to answer questions.',
24+
instructions:
25+
'You must always use the MCP tools to answer questions. The mcp server knows which repo to investigate, so you do not need to ask the user about it.',
2526
tools: [
2627
hostedMcpTool({
2728
serverLabel: 'gitmcp',

examples/mcp/hosted-mcp-on-approval.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ async function main(verbose: boolean, stream: boolean): Promise<void> {
2525
};
2626
const agent = new Agent({
2727
name: 'MCP Assistant',
28-
instructions: 'You must always use the MCP tools to answer questions.',
28+
instructions:
29+
'You must always use the MCP tools to answer questions. The mcp server knows which repo to investigate, so you do not need to ask the user about it.',
2930
tools: [
3031
hostedMcpTool({
3132
serverLabel: 'gitmcp',

examples/mcp/hosted-mcp-simple.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ async function main(verbose: boolean, stream: boolean): Promise<void> {
44
withTrace('Hosted MCP Example', async () => {
55
const agent = new Agent({
66
name: 'MCP Assistant',
7-
instructions: 'You must always use the MCP tools to answer questions.',
7+
instructions:
8+
'You must always use the MCP tools to answer questions. The mcp server knows which repo to investigate, so you do not need to ask the user about it.',
89
tools: [
910
hostedMcpTool({
1011
serverLabel: 'gitmcp',

examples/mcp/streamable-http-custom-fetch-example.ts

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)