Skip to content

feat(api): add Agents API - #992

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

feat(api): add Agents API#992
apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-60

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.
  • AgentSessionMessages.outputText(message): Join a message’s output-text blocks into one string.

Castiron-Internal-PR: openai/openai-java-internal#60
Castiron-Source-SHA: 66d29c23748ad43c9b6106ba9dce665a36d9fcfc
Castiron-Public-Base-SHA: 6cf15d8
@apcha-oai
apcha-oai marked this pull request as ready for review September 10, 2026 19:27
@apcha-oai
apcha-oai requested a review from a team as a code owner September 10, 2026 19:27
@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:35:19.754596Z 22b5ef2 Draft marked ready
🔒 Security Review Completed 2026-09-10T19:33:15.795264Z 22b5ef2 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.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

Mixed files: 62 → 70

8 newly customized · 0 customizations removed · 1 existing customizations changed · 4 generated baselines changed

Compared 6cf15d835f7c22b5ef2b1e28. Generated baselines verified.

File Result Current custom patch
openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsync.kt Generated baseline changed +11 / −0
openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsyncImpl.kt Generated baseline changed +18 / −0
openai-java-core/src/main/kotlin/com/openai/services/async/beta/agents/SessionServiceAsync.kt Newly customized +14 / −0
openai-java-core/src/main/kotlin/com/openai/services/async/beta/agents/SessionServiceAsyncImpl.kt Newly customized +14 / −0
openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaService.kt Generated baseline changed +11 / −0
openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaServiceImpl.kt Generated baseline changed +18 / −0
openai-java-core/src/main/kotlin/com/openai/services/blocking/beta/agents/SessionService.kt Newly customized +16 / −0
openai-java-core/src/main/kotlin/com/openai/services/blocking/beta/agents/SessionServiceImpl.kt Newly customized +8 / −0
openai-java-core/src/test/kotlin/com/openai/services/async/beta/agents/SessionServiceAsyncTest.kt Newly customized +20 / −3
openai-java-core/src/test/kotlin/com/openai/services/async/beta/agents/sessions/EventServiceAsyncTest.kt Newly customized +23 / −3
openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/agents/SessionServiceTest.kt Newly customized +19 / −3
openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/agents/sessions/EventServiceTest.kt Newly customized +19 / −2
scripts/castiron/test_custom_code_report.py Existing customization changed +420 / −54
57 existing customizations unchanged
  • openai-java-core/src/main/kotlin/com/openai/models/audio/AudioResponseFormat.kt
  • openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt
  • openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageFunctionToolCall.kt
  • openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolMessageParam.kt
  • openai-java-core/src/main/kotlin/com/openai/models/embeddings/Embedding.kt
  • openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionToolCall.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionWebSearch.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextConfig.kt
  • openai-java-core/src/main/kotlin/com/openai/models/videos/Video.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/WebhookServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/WebhookServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/WebhookService.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/WebhookServiceImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionService.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt
  • openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseFunctionWebSearchTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponsesServerEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/live/ClientEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/live/ServerEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/live/SessionClosedEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/live/SessionStartEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/live/SessionStartedEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/live/SessionUpdatedEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/live/forks/ForkServerEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFunctionWebSearchTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/CompletionServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/ImageServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt

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

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

git fetch --no-tags origin 6cf15d835f7cbd1758a83fa39a6f55ac086fbd6d 22b5ef2b1e2802330e65215dac408cd49ed27e87
python3 scripts/castiron/custom_code_report.py report \
  --base 6cf15d835f7cbd1758a83fa39a6f55ac086fbd6d \
  --head 22b5ef2b1e2802330e65215dac408cd49ed27e87 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-22b5ef2b1e28
cat /tmp/castiron-custom-code-22b5ef2b1e28/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

@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
@openai-sdks

openai-sdks Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

236/236 SDK tests passed in 18.193s for Java SDK PR #992.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 297ms
tests/chat-completions-create.test.ts ✅ Passed 696ms
tests/chat-completions-stream.test.ts ✅ Passed 918ms
tests/files-content-binary.test.ts ✅ Passed 349ms
tests/files-create-multipart.test.ts ✅ Passed 623ms
tests/files-list-pagination.test.ts ✅ Passed 282ms
tests/initialize-config.test.ts ✅ Passed 176ms
tests/instance-isolation.test.ts ✅ Passed 174ms
tests/models-list.test.ts ✅ Passed 286ms
tests/responses-background-lifecycle.test.ts ✅ Passed 738ms
tests/responses-body-method-errors.test.ts ✅ Passed 549ms
tests/responses-cancel-timeout.test.ts ✅ Passed 255ms
tests/responses-cancel.test.ts ✅ Passed 330ms
tests/responses-compact-retries.test.ts ✅ Passed 414ms
tests/responses-compact.test.ts ✅ Passed 241ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 286ms
tests/responses-create-advanced.test.ts ✅ Passed 1.561s
tests/responses-create-disconnect.test.ts ✅ Passed 1.117s
tests/responses-create-errors.test.ts ✅ Passed 340ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 355ms
tests/responses-create-retries.test.ts ✅ Passed 328ms
tests/responses-create-stream-failures.test.ts ✅ Passed 318ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 266ms
tests/responses-create-stream-wire.test.ts ✅ Passed 6.981s
tests/responses-create-stream.test.ts ✅ Passed 122ms
tests/responses-create-terminal-states.test.ts ✅ Passed 422ms
tests/responses-create-timeout.test.ts ✅ Passed 251ms
tests/responses-create.test.ts ✅ Passed 285ms
tests/responses-delete.test.ts ✅ Passed 414ms
tests/responses-input-items-errors.test.ts ✅ Passed 282ms
tests/responses-input-items-list.test.ts ✅ Passed 422ms
tests/responses-input-items-options.test.ts ✅ Passed 489ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 286ms
tests/responses-input-tokens-count.test.ts ✅ Passed 438ms
tests/responses-malformed-inputs.test.ts ✅ Passed 5.757s
tests/responses-not-found-errors.test.ts ✅ Passed 436ms
tests/responses-parse.test.ts ✅ Passed 834ms
tests/responses-retrieve-retries.test.ts ✅ Passed 345ms
tests/responses-retrieve.test.ts ✅ Passed 305ms
tests/responses-stored-method-errors.test.ts ✅ Passed 1.119s
tests/retry-behavior.test.ts ✅ Passed 3.498s
tests/sdk-error-shape.test.ts ✅ Passed 438ms

View OkTest run #34520496970

SDK merge (753cb350af75) · head (22b5ef2b1e28) · base (6cf15d835f7c) · OkTest (08ec4299e769)

@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: 22b5ef2b1e

ℹ️ 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 +1069 to +1070
override fun toString() =
"McpOAuth{accessToken=$accessToken, mcpServerUrl=$mcpServerUrl, type=$type, expiresAt=$expiresAt, refresh=$refresh, additionalProperties=$additionalProperties}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Redact secrets from credential string representations

When an application logs or interpolates a credential create parameter, this toString() renders the write-only OAuth access token verbatim; the nested refresh-token and client-secret variants and StaticBearer similarly expose their secrets. Since these objects are likely to appear in diagnostic logs, generate redacted string representations for every credential create/rotate secret and add regression coverage ensuring the raw values never appear.

AGENTS.md reference: AGENTS.md:L29-L33

Useful? React with 👍 / 👎.

Comment on lines +73 to +77
val result =
try {
future.get()
} finally {
active = null

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 Treat cancellation caused by close as normal termination

When another thread closes a synchronous stream while an asyncToolHandler stage is incomplete, close() cancels this active future and future.get() throws CancellationException; the outer catch then rethrows it to the consuming thread. This makes an intentional close fail the stream operation, unlike closing during a blocked event read and unlike the async helper, both of which complete normally after close. Check closed when the wait is cancelled and end iteration instead of propagating the cancellation.

Useful? React with 👍 / 👎.

Comment on lines +33 to +34
fun create(environmentId: String): EnvironmentFile =
create(environmentId, FileCreateParams.none())

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 Require a file source before issuing create requests

create(environmentId) constructs FileCreateParams.none(), and the implementation validates only the environment ID before sending a POST with no body. Because creating an environment file necessarily requires either inline bytes or a Files API file reference, this convenience overload always produces an invalid request instead of a usable operation. Mark the request body as required in the authoritative OpenAPI source so the generated sync and async APIs require a HostedEnvironmentFileParam.

AGENTS.md reference: AGENTS.md:L5-L8

Useful? React with 👍 / 👎.

@apcha-oai
apcha-oai merged commit 10027a0 into main Sep 10, 2026
19 checks passed
@openai-sdks openai-sdks Bot mentioned this pull request Sep 10, 2026
apcha-oai pushed a commit that referenced this pull request Sep 10, 2026
Automated Release PR
---


##
[4.63.0](v4.62.0...v4.63.0)
(2026-09-10)


### Features

* **api:** add Agents API
([#992](#992))
([10027a0](10027a0))

---
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.

1 participant