Stream OpenAI OAuth structured helpers - #100
Open
k2v7n24cbf-cyber wants to merge 1 commit into
Open
Conversation
k2v7n24cbf-cyber
marked this pull request as ready for review
July 20, 2026 08:35
k2v7n24cbf-cyber
added a commit
to k2v7n24cbf-cyber/openacme
that referenced
this pull request
Jul 22, 2026
Merge staged copy of sandydasari#100 into local-stage.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR changes structured helper calls to use streaming when the parent model is
openaiwithoauthauth.The existing structured-helper path uses
generateObject()for all providers. For ChatGPT OAuth, that sends a non-streaming Responses request. In local deployment debug logs, those calls reached the ChatGPT OAuth backend but were rejected with:The fix keeps the existing
generateObject()path for other providers/auth modes, and only routes OpenAI OAuth structured helpers throughstreamObject(). The helper still exposes the same one-shot result contract to callers by draining the SDK stream internally before returning the final object and usage metadata.Root cause
OpenAcme structured helper jobs, such as session title generation and memory selection, currently share one implementation in
runStructured(). That implementation uses AI SDKgenerateObject(), which is non-streaming.The ChatGPT OAuth/Codex backend expects these Responses calls to be streamed. Non-streaming structured helper calls therefore fail even though normal interactive turns can continue to work, because the main chat path already streams.
Why this is costly
This is not just a cosmetic helper failure. In a real deployment, the failure was observed repeatedly across deployed agents during normal sessions. Each failed helper call is still a model round trip that carries prompt input and returns no useful work.
That cost compounds because these helpers run around common workflows:
Prompt caching can reduce reprocessing work, but it does not make failed turns free: each call still sends input, consumes latency, and adds operational noise. A repeating
400on helper paths is therefore token-expensive relative to the value produced, because the marginal information returned by each failed call is zero.Change
streamObject()for structured helper calls only when the resolved helper model isopenai+oauth.result.fullStreamsoresult.objectandresult.usageresolve reliably while preserving the existing synchronous helper API.generateObject()behavior.doStreaminstead ofdoGenerate.Validation
Focused validation:
Commit/push hooks also ran successfully: