-
Notifications
You must be signed in to change notification settings - Fork 498
Fix #374 add connector support #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@openai/agents-core": patch | ||
| "@openai/agents-openai": patch | ||
| --- | ||
|
|
||
| Fix #374 add connector support |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { Agent, run, hostedMcpTool } from '@openai/agents'; | ||
|
|
||
| async function main(verbose: boolean, stream: boolean): Promise<void> { | ||
| // 1. Visit https://developers.google.com/oauthplayground/ | ||
| // 2. Input https://www.googleapis.com/auth/calendar.events as the required scope | ||
| // 3. Grab the acccess token starting with "ya29." | ||
| const authorization = process.env.GOOGLE_CALENDAR_AUTHORIZATION!; | ||
|
|
||
| const agent = new Agent({ | ||
| name: 'My Calendar Assistant', | ||
| instructions: | ||
| 'You are a helpful assistant that can help a user with their calendar.', | ||
| tools: [ | ||
| hostedMcpTool({ | ||
| serverLabel: 'google_calendar', | ||
| connectorId: 'connector_googlecalendar', | ||
| authorization, | ||
| requireApproval: 'never', | ||
| }), | ||
| ], | ||
| }); | ||
|
|
||
| const today = new Date().toISOString().split('T')[0]; | ||
| const input = `What is my schedule for ${today}?`; | ||
| if (stream) { | ||
| const result = await run(agent, input, { stream: true }); | ||
| for await (const event of result) { | ||
| if ( | ||
| event.type === 'raw_model_stream_event' && | ||
| event.data.type === 'model' && | ||
| event.data.event.type !== 'response.mcp_call_arguments.delta' && | ||
| event.data.event.type !== 'response.output_text.delta' | ||
| ) { | ||
| console.log(`Got event of type ${JSON.stringify(event.data)}`); | ||
| } | ||
| } | ||
| for (const item of result.newItems) { | ||
| console.log(JSON.stringify(item, null, 2)); | ||
| } | ||
| console.log(`Done streaming; final result: ${result.finalOutput}`); | ||
| } else { | ||
| const res = await run(agent, input); | ||
| if (verbose) { | ||
| for (const item of res.output) { | ||
| console.log(JSON.stringify(item, null, 2)); | ||
| } | ||
| } | ||
| console.log(res.finalOutput); | ||
| } | ||
| } | ||
|
|
||
| const args = process.argv.slice(2); | ||
| const verbose = args.includes('--verbose'); | ||
| const stream = args.includes('--stream'); | ||
|
|
||
| main(verbose, stream).catch((err) => { | ||
| console.error(err); | ||
| process.exit(1); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "private": true, | ||
| "name": "connectors", | ||
| "dependencies": { | ||
| "@openai/agents": "workspace:*", | ||
| "zod": "^3.25.40" | ||
| }, | ||
| "scripts": { | ||
| "build-check": "tsc --noEmit", | ||
| "start": "tsx index.ts" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "extends": "../../tsconfig.examples.json" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Require either serverUrl or connectorId for hosted MCP tools
The new overload for
hostedMcpToolmakesserverUrloptional in both branches whileconnectorIdis only required in the connector branch. Because the runtime dispatch simply checks'serverUrl' in optionsand'connectorId' in options, it is now possible to callhostedMcpTool({ serverLabel: 'foo' })without either value; this compiles and returns provider data that lacks bothserver_urlandconnector_id. When the model later tries to invoke the tool, OpenAI will reject the call because no endpoint or connector is specified, whereas the previous signature enforced the required field at compile time. Consider keepingserverUrlmandatory for non‑connector usage and validating that one of the two identifiers is provided so misconfigurations are caught early.Useful? React with 👍 / 👎.