Add a background-responses agent example - #569
Add a background-responses agent example#569PratikDhanave (PratikDhanave) wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Go example demonstrating OpenAI Responses “background” execution (continuation-token polling) for the Azure OpenAI provider, and wires it into the repo’s example verification harness.
Changes:
- Introduces
openai_responses_backgroundexample showing non-streaming background execution + polling viaResponse.ContinuationToken/agent.WithContinuationToken. - Registers the new example in
cmd/verifyexampleswith the sameAZURE_OPENAI_ENDPOINTgate used by the sibling Azure Responses example.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| examples/02-agents/providers/azure/openai_responses_background/main.go | New sample: start a background Responses run, then poll until continuation token is cleared. |
| cmd/verifyexamples/examples.go | Adds the new sample to the agentsExamples verification list with expected-output guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0cd72f1 to
21efdba
Compare
This comment has been minimized.
This comment has been minimized.
21efdba to
4f750db
Compare
This comment has been minimized.
This comment has been minimized.
Ports the Python getting-started background-responses sample to Go. It starts a long-running OpenAI Responses run with agent.AllowBackgroundResponses(true), which returns a continuation token instead of the final answer, then polls with agent.WithContinuationToken (sending no messages) until the run completes. Placed next to the existing openai_responses provider example since background responses are an OpenAI Responses capability, and registered in verifyexamples with the same AZURE_OPENAI_ENDPOINT gate so it skips cleanly without credentials.
Bound the sample with a timeout and replace the blocking sleep with a select on ctx.Done(), so a run that never completes (stuck queued, bad continuation token) cannot hang the example or verifyexamples.
4f750db to
96259eb
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PratikDhanave (@PratikDhanave) can you please address this in your PR |
This comment has been minimized.
This comment has been minimized.
Parity Review — PR #569: Add a background-responses agent exampleScope: examples only — no exported Go APIs changed. Upstream reference: Summary: The PR correctly ports the non-streaming polling pattern from the upstream Python sample and the Go implementation is semantically aligned with the Python
|
Ports the Python getting-started background responses sample (
python/samples/02-agents/background_responses.py) to Go. The Go SDK supports the feature (agent.AllowBackgroundResponses+Response.ContinuationToken+agent.WithContinuationToken) but had no example for it.What it shows
The non-streaming polling pattern:
agent.AllowBackgroundResponses(true)— the OpenAI Responses API returns quickly with a continuation token instead of the final answer.agent.WithContinuationToken(resp.ContinuationToken)until the run completes (no more token).A correctness detail worth calling out: continuation runs must not carry messages (the provider rejects
messages are not allowed when continuing a background response using a continuation token), so the poll usesRun(ctx, nil, …)rather thanRunText. If the model/endpoint does not support background execution, the run simply completes inline with no token, so the example degrades gracefully.Placement
Put next to the existing
providers/azure/openai_responsesexample, since background responses are an OpenAI Responses capability — this avoids guessing anagents/stepNNnumber. Happy to relocate/renumber to match your preferred layout.Registered in
cmd/verifyexampleswith the sameAZURE_OPENAI_ENDPOINTgate as the sibling example, so it skips cleanly when credentials are absent.go build ./...,go vet,gofmt, andgo test ./cmd/verifyexamples/all pass.