-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[codex] add native agent file uploads #1927
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ import type { | |||||||||||||||||||
| Variables, | ||||||||||||||||||||
| } from "../../types/public/agent.js"; | ||||||||||||||||||||
| import { processCoordinates } from "../utils/coordinateNormalization.js"; | ||||||||||||||||||||
| import { getFileUploadGuardError } from "../utils/fileUploadGuard.js"; | ||||||||||||||||||||
| import { ensureXPath } from "../utils/xpath.js"; | ||||||||||||||||||||
| import { waitAndCaptureScreenshot } from "../utils/screenshotHandler.js"; | ||||||||||||||||||||
| import { substituteVariables } from "../utils/variables.js"; | ||||||||||||||||||||
|
|
@@ -62,6 +63,16 @@ MANDATORY USE CASES (always use fillFormVision for these): | |||||||||||||||||||
| }), | ||||||||||||||||||||
| execute: async ({ fields }): Promise<FillFormVisionToolResult> => { | ||||||||||||||||||||
| try { | ||||||||||||||||||||
| const fileUploadGuardError = getFileUploadGuardError( | ||||||||||||||||||||
| ...fields.flatMap((field) => [field.action, field.value]), | ||||||||||||||||||||
| ); | ||||||||||||||||||||
|
Comment on lines
+66
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The upload guard only inspects the raw field values; any Prompt for AI agents
Suggested change
|
||||||||||||||||||||
| if (fileUploadGuardError) { | ||||||||||||||||||||
| return { | ||||||||||||||||||||
| success: false, | ||||||||||||||||||||
| error: fileUploadGuardError, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const page = await v3.context.awaitActivePage(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Process coordinates and substitute variables for each field | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ import type { | |||||||||||
| Variables, | ||||||||||||
| } from "../../types/public/agent.js"; | ||||||||||||
| import { processCoordinates } from "../utils/coordinateNormalization.js"; | ||||||||||||
| import { getFileUploadGuardError } from "../utils/fileUploadGuard.js"; | ||||||||||||
| import { ensureXPath } from "../utils/xpath.js"; | ||||||||||||
| import { waitAndCaptureScreenshot } from "../utils/screenshotHandler.js"; | ||||||||||||
| import { substituteVariables } from "../utils/variables.js"; | ||||||||||||
|
|
@@ -38,6 +39,14 @@ export const typeTool = (v3: V3, provider?: string, variables?: Variables) => { | |||||||||||
| text, | ||||||||||||
| }): Promise<TypeToolResult> => { | ||||||||||||
| try { | ||||||||||||
| const fileUploadGuardError = getFileUploadGuardError(describe, text); | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Run the file-upload guard on the substituted text; Prompt for AI agents
Suggested change
|
||||||||||||
| if (fileUploadGuardError) { | ||||||||||||
| return { | ||||||||||||
| success: false, | ||||||||||||
| error: fileUploadGuardError, | ||||||||||||
| }; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const page = await v3.context.awaitActivePage(); | ||||||||||||
| const processed = processCoordinates( | ||||||||||||
| coordinates[0], | ||||||||||||
|
|
||||||||||||
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.
These "never use this for file upload" annotations to tool calls seems overly prescriptive and not the right pattern to add