Skip to content

feat(api): add Agents API - #3847

Merged
apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-75
Sep 10, 2026
Merged

apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-75

Conversation

@apcha-oai

@apcha-oai apcha-oai commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Add the beta.agents API.

  • Manage agents, sessions, items, and turns; inspect subagents and their history.
  • Work with environments, templates, files, artifacts, vaults, and credentials.
  • Includes automatic pagination, streaming events, binary artifact downloads, and the OpenAI-Beta: agents=v1 header.
  • beta.agents.sessions.stream(...): Stream one turn on an idle session; supports sync and async clients.
  • Function-tool handlers: Parse arguments, invoke registered functions, and submit tool results during the stream.
  • AgentSessionMessage.output_text: Join a message’s output-text blocks into one string.

Castiron-Internal-PR: openai/openai-python-internal#75
Castiron-Source-SHA: 97896898c58d6c11eddfe60dc2671ef0501c4bf8
Castiron-Public-Base-SHA: 603b81f
@apcha-oai
apcha-oai marked this pull request as ready for review September 10, 2026 19:23
@apcha-oai
apcha-oai requested a review from a team as a code owner September 10, 2026 19:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 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-09-10T19:28:43.747412Z d5370ba Draft marked ready
🔒 Security Review ✅ Completed 2026-09-10T19:27:31.379099Z d5370ba Draft marked ready
ℹ️ 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 Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

OkTest Summary

✅ 236/236 SDK tests passed in 11.655s for Python SDK PR #3847.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 181ms
tests/chat-completions-create.test.ts ✅ Passed 273ms
tests/chat-completions-stream.test.ts ✅ Passed 272ms
tests/files-content-binary.test.ts ✅ Passed 233ms
tests/files-create-multipart.test.ts ✅ Passed 236ms
tests/files-list-pagination.test.ts ✅ Passed 149ms
tests/initialize-config.test.ts ✅ Passed 180ms
tests/instance-isolation.test.ts ✅ Passed 173ms
tests/models-list.test.ts ✅ Passed 235ms
tests/responses-background-lifecycle.test.ts ✅ Passed 206ms
tests/responses-body-method-errors.test.ts ✅ Passed 275ms
tests/responses-cancel-timeout.test.ts ✅ Passed 183ms
tests/responses-cancel.test.ts ✅ Passed 250ms
tests/responses-compact-retries.test.ts ✅ Passed 369ms
tests/responses-compact.test.ts ✅ Passed 211ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 122ms
tests/responses-create-advanced.test.ts ✅ Passed 244ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.215s
tests/responses-create-errors.test.ts ✅ Passed 165ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 473ms
tests/responses-create-retries.test.ts ✅ Passed 344ms
tests/responses-create-stream-failures.test.ts ✅ Passed 202ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 228ms
tests/responses-create-stream-wire.test.ts ✅ Passed 3.916s
tests/responses-create-stream.test.ts ✅ Passed 421ms
tests/responses-create-terminal-states.test.ts ✅ Passed 266ms
tests/responses-create-timeout.test.ts ✅ Passed 190ms
tests/responses-create.test.ts ✅ Passed 290ms
tests/responses-delete.test.ts ✅ Passed 204ms
tests/responses-input-items-errors.test.ts ✅ Passed 444ms
tests/responses-input-items-list.test.ts ✅ Passed 329ms
tests/responses-input-items-options.test.ts ✅ Passed 359ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 237ms
tests/responses-input-tokens-count.test.ts ✅ Passed 272ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.932s
tests/responses-not-found-errors.test.ts ✅ Passed 257ms
tests/responses-parse.test.ts ✅ Passed 548ms
tests/responses-retrieve-retries.test.ts ✅ Passed 219ms
tests/responses-retrieve.test.ts ✅ Passed 255ms
tests/responses-stored-method-errors.test.ts ✅ Passed 529ms
tests/retry-behavior.test.ts ✅ Passed 3.047s
tests/sdk-error-shape.test.ts ✅ Passed 253ms

View OkTest run #34520115338

SDK merge (76a0f3379c4d) · head (d5370ba5ea38) · base (603b81f9e228) · OkTest (08ec4299e769)

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Castiron custom code

Mixed files: 41 → 43

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

Compared 603b81f9e228 → d5370ba5ea38. Generated baselines verified.

File Result Current custom patch
api.md Generated baseline changed +119 / −0
scripts/castiron/test_custom_code_report.py Existing customization changed +343 / −31
src/openai/resources/beta/agents/sessions/sessions.py Newly customized +54 / −1
src/openai/resources/beta/beta.py Generated baseline changed +21 / −0
src/openai/types/beta/agent_session_message.py Newly customized +5 / −0
38 existing customizations unchanged
  • scripts/castiron/README.md
  • scripts/castiron/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/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/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/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/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
  • src/openai/types/responses/responses_client_event_param.py
  • src/openai/types/responses/tool.py
  • src/openai/types/responses/tool_param.py
  • src/openai/types/webhooks/init.py
  • src/openai/types/webhooks/live_call_incoming_webhook_event.py
  • src/openai/types/webhooks/unwrap_webhook_event.py
  • tests/api_resources/test_videos.py

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 34520344275 --repo openai/openai-python \
  --name castiron-custom-code-34520344275-1 --dir /tmp/castiron-custom-code-34520344275-1
git apply --stat /tmp/castiron-custom-code-34520344275-1/custom-code.patch
cat /tmp/castiron-custom-code-34520344275-1/custom-code.patch

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

git fetch --no-tags origin 603b81f9e228d95032059169cb3a0e7dc12ba93f d5370ba5ea38fff1d5786bc5b3bc526b4ccffed4
python3 scripts/castiron/custom_code_report.py report \
  --base 603b81f9e228d95032059169cb3a0e7dc12ba93f \
  --head d5370ba5ea38fff1d5786bc5b3bc526b4ccffed4 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-d5370ba5ea38
cat /tmp/castiron-custom-code-d5370ba5ea38/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

"""Whether to stream session events as server-sent events. Defaults to `false`."""


SessionCreateParams = Union[SessionCreateParamsNonStreaming, SessionCreateParamsStreaming]

timeout: Override the client-level default timeout for this request, in seconds
"""
...

timeout: Override the client-level default timeout for this request, in seconds
"""
...

timeout: Override the client-level default timeout for this request, in seconds
"""
...

timeout: Override the client-level default timeout for this request, in seconds
"""
...

timeout: Override the client-level default timeout for this request, in seconds
"""
...

timeout: Override the client-level default timeout for this request, in seconds
"""
...

timeout: Override the client-level default timeout for this request, in seconds
"""
...

timeout: Override the client-level default timeout for this request, in seconds
"""
...

timeout: Override the client-level default timeout for this request, in seconds
"""
...
@apcha-oai
apcha-oai merged commit 1c4284a into main Sep 10, 2026
34 checks passed
@apcha-oai
apcha-oai deleted the castiron/promotions/pr-75 branch September 10, 2026 19:26
@openai-sdks openai-sdks Bot mentioned this pull request Sep 10, 2026
@apcha-oai apcha-oai changed the title feat(agents): add beta API and one-turn streaming helpers feat(api): add Agents API Sep 10, 2026

@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: d5370ba5ea

ℹ️ 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 +83 to +84
if len(self.recent_events) == _RECENT_EVENT_LIMIT:
self.event_ids.remove(self.recent_events.popleft())

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 Retain event IDs for the whole turn

When a long turn emits more than 1,024 distinct events and the server later redelivers an earlier event, this eviction removes the original ID, so accept() yields that event a second time. For an agent.session.turn.output_text.delta consumer that concatenates deltas, this silently duplicates output; deduplication should not expire based on an arbitrary event count during a single turn.

AGENTS.md reference: AGENTS.md:L112-L120

Useful? React with 👍 / 👎.

Comment thread src/openai/pagination.py
if has_more is not None and has_more is False:
return False

return super().has_next_page()

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 Follow opaque cursors after empty pages

When the environment-files API returns a valid empty page with has_more=true and a nonempty next token, delegating to BasePage.has_next_page() returns False solely because data is empty, so automatic iteration silently stops without requesting the indicated next page. Since this pagination scheme has an independent opaque cursor rather than deriving it from the last item, both the synchronous and asynchronous token-page implementations should decide continuation from has_more and next even when the current page contains no files.

Useful? React with 👍 / 👎.

@kattgrom-hub kattgrom-hub 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.

R

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.

2 participants