Skip to content

feat(agents): stage files and download turn artifacts - #4009

Merged
apcha-oai merged 20 commits into
mainfrom
apcha/agents-files-artifacts
Oct 1, 2026
Merged

apcha-oai merged 20 commits into
mainfrom
apcha/agents-files-artifacts

Conversation

@apcha-oai

@apcha-oai apcha-oai commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stage selected local files and read an artifact from the exact completed turn, either in memory or streamed to a local path. The helpers keep upload IDs available for explicit cleanup and stream downloads to a caller-chosen path.

Before:

uploaded = client.files.create(file=Path("source.pdf"), purpose="user_data")
inputs = [{"type": "file_id", "file_id": uploaded.id, "path": "/workspace/source.pdf"}]
# Pass inputs when creating the hosted environment, then run the session.
artifact = next(a for a in client.beta.agents.sessions.artifacts.list(result.session_id)
                if a.turn_id == result.turn_id and a.path == "/workspace/outputs/report.md")
with client.beta.agents.sessions.artifacts.with_streaming_response.content(
    artifact.id, session_id=result.session_id,
) as content:
    content.stream_to_file("report.md")

After:

prepared = client.beta.agents.environments.files.prepare({
    "/workspace/source.pdf": Path("source.pdf"),
})
# Pass prepared.files when creating the hosted environment, then run the session.
artifacts = client.beta.agents.sessions.artifacts.for_result(result)
report_bytes = artifacts.content("/workspace/outputs/report.md").content
# Or stream to an application-owned path:
artifact = artifacts.download("/workspace/outputs/report.md", to=Path("report.md"))

prepare_directory(..., include=[...]) selects a directory snapshot; files.upload(...) uploads and stages one file in an existing environment. Sync and async helpers live under the beta Agents namespace. They preflight selected files before uploading, preserve partial upload ownership on errors, and detect missing or ambiguous artifacts across all pages.

Local path selection is intended for static application-owned files and stable directories; it is not a filesystem sandbox for untrusted paths or hostile local writers.

This PR now targets main directly. Reattachment/result recovery is deferred: a silent attachment cannot reliably distinguish pending work from an already-completed turn, so these helpers do not depend on SDK-side recovery heuristics.

Stack

@apcha-oai
apcha-oai requested a review from a team as a code owner October 1, 2026 02:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T21:47:48.064750Z e02dd44 New commits
🔒 Security Review ✅ Completed 2026-10-01T21:46:39.590326Z e02dd44 New commits

Security findings

Advisory findings (1)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openai-sdks

openai-sdks Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

OkTest Summary

✅ 236/236 SDK tests passed in 10.298s for Python SDK PR #4009.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 242ms
tests/chat-completions-create.test.ts ✅ Passed 189ms
tests/chat-completions-stream.test.ts ✅ Passed 295ms
tests/files-content-binary.test.ts ✅ Passed 155ms
tests/files-create-multipart.test.ts ✅ Passed 238ms
tests/files-list-pagination.test.ts ✅ Passed 182ms
tests/initialize-config.test.ts ✅ Passed 153ms
tests/instance-isolation.test.ts ✅ Passed 171ms
tests/models-list.test.ts ✅ Passed 212ms
tests/responses-background-lifecycle.test.ts ✅ Passed 205ms
tests/responses-body-method-errors.test.ts ✅ Passed 320ms
tests/responses-cancel-timeout.test.ts ✅ Passed 186ms
tests/responses-cancel.test.ts ✅ Passed 202ms
tests/responses-compact-retries.test.ts ✅ Passed 316ms
tests/responses-compact.test.ts ✅ Passed 263ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 176ms
tests/responses-create-advanced.test.ts ✅ Passed 239ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.242s
tests/responses-create-errors.test.ts ✅ Passed 198ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 463ms
tests/responses-create-retries.test.ts ✅ Passed 197ms
tests/responses-create-stream-failures.test.ts ✅ Passed 147ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 218ms
tests/responses-create-stream-wire.test.ts ✅ Passed 3.146s
tests/responses-create-stream.test.ts ✅ Passed 94ms
tests/responses-create-terminal-states.test.ts ✅ Passed 218ms
tests/responses-create-timeout.test.ts ✅ Passed 182ms
tests/responses-create.test.ts ✅ Passed 256ms
tests/responses-delete.test.ts ✅ Passed 142ms
tests/responses-input-items-errors.test.ts ✅ Passed 419ms
tests/responses-input-items-list.test.ts ✅ Passed 292ms
tests/responses-input-items-options.test.ts ✅ Passed 347ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 222ms
tests/responses-input-tokens-count.test.ts ✅ Passed 176ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.163s
tests/responses-not-found-errors.test.ts ✅ Passed 225ms
tests/responses-parse.test.ts ✅ Passed 201ms
tests/responses-retrieve-retries.test.ts ✅ Passed 173ms
tests/responses-retrieve.test.ts ✅ Passed 180ms
tests/responses-stored-method-errors.test.ts ✅ Passed 558ms
tests/retry-behavior.test.ts ✅ Passed 3.233s
tests/sdk-error-shape.test.ts ✅ Passed 318ms

View OkTest run #36930622519

SDK merge (8605f9015ae5) · head (e02dd44da922) · base (a91d779cb5e7) · OkTest (92ff272954a1)

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Castiron custom code

Mixed files: 49 → 51

2 newly customized · 0 customizations removed · 0 existing customizations changed · 0 generated baselines changed

Compared a91d779cb5e7 → e02dd44da922. Generated baselines verified.

File Result Current custom patch
src/openai/resources/beta/agents/environments/files.py Newly customized +125 / −2
src/openai/resources/beta/agents/sessions/artifacts.py Newly customized +10 / −0
49 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/openai/init.py
  • src/openai/_client.py
  • src/openai/resources/audio/transcriptions.py
  • src/openai/resources/audio/translations.py
  • src/openai/resources/beta/agents/sessions/sessions.py
  • src/openai/resources/beta/beta.py
  • src/openai/resources/beta/responses/responses.py
  • src/openai/resources/beta/threads/runs/runs.py
  • src/openai/resources/beta/threads/threads.py
  • src/openai/resources/chat/completions/completions.py
  • src/openai/resources/embeddings.py
  • src/openai/resources/files.py
  • src/openai/resources/live/forks.py
  • src/openai/resources/live/live.py
  • src/openai/resources/live/sideband.py
  • src/openai/resources/realtime/api.md
  • src/openai/resources/realtime/realtime.py
  • src/openai/resources/responses/responses.py
  • src/openai/resources/uploads/uploads.py
  • src/openai/resources/vector_stores/file_batches.py
  • src/openai/resources/vector_stores/files.py
  • src/openai/resources/videos.py
  • src/openai/resources/webhooks/init.py
  • src/openai/resources/webhooks/webhooks.py
  • src/openai/types/beta/agent_session_message.py
  • src/openai/types/beta/session_turn_error.py
  • src/openai/types/chat/init.py
  • src/openai/types/chat/chat_completion_message_tool_call.py
  • src/openai/types/fine_tuning/fine_tuning_job_integration.py
  • src/openai/types/realtime/conversation_item_input_audio_transcription_delta_event.py
  • src/openai/types/realtime/realtime_error_event.py
  • src/openai/types/responses/init.py
  • src/openai/types/responses/response.py
  • src/openai/types/responses/response_function_web_search.py
  • src/openai/types/responses/response_function_web_search_param.py
  • src/openai/types/responses/responses_client_event.py

9 more in the full report.

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 36931092923 --repo openai/openai-python \
  --name castiron-custom-code-36931092923-1 --dir /tmp/castiron-custom-code-36931092923-1
git apply --stat /tmp/castiron-custom-code-36931092923-1/custom-code.patch
cat /tmp/castiron-custom-code-36931092923-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin a91d779cb5e725b47909333c6a3d9fe795e93439 e02dd44da92256fb2c9180bf3c56004d23d42ce1
python3 scripts/castiron/custom_code_report.py report \
  --base a91d779cb5e725b47909333c6a3d9fe795e93439 \
  --head e02dd44da92256fb2c9180bf3c56004d23d42ce1 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-e02dd44da922
cat /tmp/castiron-custom-code-e02dd44da922/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9479b8d6fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/lib/beta/agents/_files.py Outdated
Comment thread src/openai/lib/beta/agents/_files.py Outdated
Comment thread src/openai/lib/beta/agents/_files.py Outdated
Comment thread src/openai/resources/beta/agents/environments/files.py Outdated
Comment thread src/openai/lib/beta/agents/_files.py Fixed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b989135267

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/lib/beta/agents/_files.py Outdated
Comment thread src/openai/lib/beta/agents/_files.py
Comment thread src/openai/lib/beta/agents/_attachment.py Outdated
Comment thread src/openai/lib/beta/agents/_files.py Outdated
Comment thread src/openai/lib/streaming/agents/_streams.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: b989135267

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread src/openai/lib/beta/agents/_files.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0323f2a61

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/lib/beta/agents/_files.py Outdated
Comment thread src/openai/lib/beta/agents/_attachment.py Outdated
Comment thread tests/lib/streaming/agents/test_files.py Fixed
Comment thread tests/lib/streaming/agents/test_files.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e3512acbf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/lib/streaming/agents/_streams.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 187b30fe74

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/lib/beta/agents/_artifacts.py
@apcha-oai

Copy link
Copy Markdown
Contributor Author

@codex review pls

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 187b30fe74

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 187b30fe74

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@apcha-oai
apcha-oai changed the base branch from main to apcha/agents-reattach-handlers October 1, 2026 03:04
@apcha-oai
apcha-oai force-pushed the apcha/agents-reattach-handlers branch from 65812a9 to 1c2b129 Compare October 1, 2026 14:46
@apcha-oai
apcha-oai force-pushed the apcha/agents-files-artifacts branch 2 times, most recently from 527e121 to 4a0ce8f Compare October 1, 2026 15:25
@apcha-oai
apcha-oai force-pushed the apcha/agents-reattach-handlers branch 2 times, most recently from 0b85107 to f5e68d3 Compare October 1, 2026 15:37
@apcha-oai
apcha-oai force-pushed the apcha/agents-files-artifacts branch from 4a0ce8f to 1e5f718 Compare October 1, 2026 15:37
github-merge-queue Bot pushed a commit that referenced this pull request Oct 1, 2026
## Summary

Bind a Pydantic output model to the Agents request and its completed
result, so applications can use a typed answer without maintaining
separate schema and parsing code.

Before:
```python
with client.beta.agents.sessions.create(
    agent={"model": MODEL, "text": {"format": {
        "type": "json_schema", "schema": schema,
    }}},
    environment={"type": "none"}, input=QUESTION, stream=True,
) as stream:
    result = stream.get_final_result()
report = Report.model_validate_json(result.output_text)
```

After:
```python
with client.beta.agents.sessions.create(
    agent={"model": MODEL}, environment={"type": "none"},
    input=QUESTION, stream=True, output_type=Report,
) as stream:
    result = stream.get_final_result()
report = result.output_parsed
```

The same `output_type` works on follow-up streams as a local parser for
an already-configured session. `output_parsed` returns the first parsed
final text part; all final text parts are validated. Raw output remains
available; parsing failures expose the completed result through
`AgentOutputParseError.result`. Sync and async helpers share the
existing Pydantic schema normalization and result collection.

Schema conversion follows the existing Responses helper; API errors
report unsupported schema features. Typed tools and outputs can reuse
the same model without output normalization changing its tool argument
schema.

### Stack

- #4004 (merged
prerequisite)
- #4007 👈 this PR
- #4008
- #4009
@apcha-oai
apcha-oai force-pushed the apcha/agents-files-artifacts branch from 1e5f718 to 74be3ea Compare October 1, 2026 16:26
@apcha-oai
apcha-oai force-pushed the apcha/agents-reattach-handlers branch from f5e68d3 to f16973a Compare October 1, 2026 16:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74be3ea165

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/lib/beta/agents/_files.py
@apcha-oai

Copy link
Copy Markdown
Contributor Author

@codex review pls

@apcha-oai

Copy link
Copy Markdown
Contributor Author

@codex review pls

@apcha-oai

Copy link
Copy Markdown
Contributor Author

@codex review pls

@apcha-oai

Copy link
Copy Markdown
Contributor Author

@codex review pls

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: b8653b43fc

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8653b43fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/lib/beta/agents/_files.py Outdated

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4e2b103abc35f9606667bb5af2b3d96978c487ed, including all eight changed files and the destination-preflight, native-glob, and per-file async buffering follow-ups. No remaining actionable findings.

The ancestor-set collision check validates destinations before opening/uploading files while preserving input order. Native Path.glob selection avoids walking unrelated subtrees and retains selected-path/symlink checks. The async path now snapshots one file per upload, verifies its preflight identity, closes worker-owned handles even on cancellation, and retains successful upload IDs on a later failure. Result artifact lookup remains scoped to the exact session, turn, and published path, with explicit caller ownership of cleanup and output destinations.

Validation was source-only: implementation, supporting code, regression tests, and prior discussion. I did not run local tests, builds, live API calls, or an independent security scan. The refreshed current-head hosted CI is still queued; this approval does not claim a green full matrix.

@apcha-oai

Copy link
Copy Markdown
Contributor Author

@codex review pls

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 51dfacadd5

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 51dfacadd5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@apcha-oai
apcha-oai enabled auto-merge October 1, 2026 20:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7b99b163e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +176 to +180
def prepare(resource: Files, files: Mapping[str, str | PathLike[str]], options: _RequestOptions) -> PreparedAgentFiles:
with ExitStack() as stack:
selected = _prepare_selection(files, options, resource._client.default_headers, stack)
prepared = PreparedAgentFiles()
try:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve upload ownership while closing source handles

When synchronous prepare() has uploaded one or more path-backed files and ExitStack.__exit__ is interrupted (for example by KeyboardInterrupt) or a handle close raises, both exception handlers have already been exited, so the exception carries no prepared state even though persistent uploads now require cleanup. Fresh evidence beyond the earlier interruption fix is that the outer with ExitStack() remains outside the protected try; include context-exit failures in the ownership-preservation path.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e02dd44da9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +267 to +268
with _upload_content(file) as content:
uploaded = resource._client.files.create(file=content, purpose="user_data", **options)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the upload ID when closing the source fails

For a path-backed synchronous upload(), the Files API request can succeed and assign uploaded, but an exception or KeyboardInterrupt while _upload_content closes its handle exits this with before reaching the ownership-preserving handlers below. The persistent upload is then left behind while the propagated exception exposes no uploaded_file_id; include context-exit failures in the same ownership-preservation path.

Useful? React with 👍 / 👎.

@apcha-oai
apcha-oai added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 4fc2438 Oct 1, 2026
26 checks passed
@apcha-oai
apcha-oai deleted the apcha/agents-files-artifacts branch October 1, 2026 22:00
@openai-sdks openai-sdks Bot mentioned this pull request Oct 1, 2026
gh-actions-shared Bot pushed a commit to xf-qubit/openai-python that referenced this pull request Oct 1, 2026
Automated Release PR
---


##
[3.23.0](openai/openai-python@v3.22.1...v3.23.0)
(2026-10-01)


### Features

* **agents:** [1/n] return typed answers from session streams
([openai#4007](openai#4007))
([10f8816](openai@10f8816))
* **agents:** stage files and download turn artifacts
([openai#4009](openai#4009))
([4fc2438](openai@4fc2438))
* **api:** Add session traces and Realtime translations
([openai#4001](openai#4001))
([138e3d1](openai@138e3d1))
* **beta:** expose typed application actions as agent tools
([openai#4006](openai#4006))
([f219c55](openai@f219c55))
* collect final output from beta Agents streams
([157ac4c](openai@157ac4c))


### Bug Fixes

* **api:** allow original image detail in Chat Completions
([openai#4005](openai#4005))
([8a136c2](openai@8a136c2))
* **api:** correct the eval run cancellation endpoint
([openai#4003](openai#4003))
([28c5c9a](openai@28c5c9a))
* **api:** retain WebSocket endpoint paths and query parameters
([openai#3999](openai#3999))
([7f203fd](openai@7f203fd))
* keep Castiron budget results valid when main advances
([openai#4012](openai#4012))
([73f189b](openai@73f189b))
* **responses:** avoid replaying uncertain typed sends on reconnect
([openai#4011](openai#4011))
([1dbbf61](openai@1dbbf61))
* **responses:** respect send queue limits during reconnect
([openai#4000](openai#4000))
([50f95ac](openai@50f95ac))
* use monotonic clock for file processing timeout
([openai#3748](openai#3748))
([58aca1d](openai@58aca1d))


### Chores

* **api:** retain WebRTC Live session transport types
([openai#4002](openai#4002))
([5c9ace9](openai@5c9ace9))
* **deps-dev:** bump pyright from 1.1.413 to 1.1.414
([openai#3902](openai#3902))
([a91d779](openai@a91d779))
* **deps:** bump astral-sh/setup-uv from 10.0.1 to 10.1.0
([openai#3976](openai#3976))
([f15f43c](openai@f15f43c))
* **deps:** bump CodeQL actions to 4.38.1
([openai#3974](openai#3974))
([fb70d66](openai@fb70d66))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants