[agentserver] azure-ai-agentserver-responses package#46052
Open
[agentserver] azure-ai-agentserver-responses package#46052
Conversation
- added type spec model generation - add model validator generation - creating a server
* trying * generate contract models * add validator generator * fix model generation * add more unit tests * fix conflict * refined model generation
* trying * generate contract models * add validator generator * fix model generation * add more unit tests * fix conflict * refined model generation * renamed the pacakge
* create response * cancel and delete * fix options
…dk-for-python into agentserver/invoke
…on deserialization
- Fix C-MSG-01: Input items without 'type' now default to 'message' per OpenAI spec
- Generator pipeline: validation-overlay.yaml adds default_discriminator
- Schema walker passes defaultValue through to emitter
- Emitter generates value.get('type', 'message') fallback
- Helper get_input_expanded() injects type='message' for items missing it
- Fix temperature/top_p: Override Optional[int] → Optional[float] via _patch.py
- Uses official subclass customization pattern (not monkey-patching)
- CreateResponse and ResponseObject subclassed with correct rest_field types
- Fix union deserialization: Patch _deserialize_sequence to reject plain strings
- model_base.py bug: str treated as iterable sequence in Union[dict,str,list]
- Makefile applies sed patch after each generate-models run
- Fix Makefile: Use pinned npm deps from emitter-package.json via tsp-client sync
- Removed hardcoded LOCAL_TYPESPEC_PACKAGES variable
- npm install runs inside TempTypeSpecFiles/ using pinned package.json
- Added generate-openapi target; fixed spec path to virtual-public-preview
- Add OpenAI interop test suite: 84 tests (53 wire compliance + 31 SDK round-trip)
- All 560 tests pass, 0 xfailed
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- request_span (both _base.py and _tracing.py): added :type:, :keyword:, :paramtype:, :rtype:, and missing instrumentation_scope doc - _handle_sigterm: prefixed unused args with _ (_signum, _frame) - sse_keepalive_stream: added :type: and :rtype: - end_span, flush_spans, record_error, trace_stream: added :type: - _BaggageLogRecordProcessor.on_emit: added :param log_data: Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…leanup
- Add 12 new contract test files (39 tests) for .NET protocol parity:
agent_reference_auto_stamp, bg_stream_disconnect, cancel_consistency,
connection_termination, conversation_store, handler_driven_persistence,
output_manipulation_detection, response_id_auto_stamp, response_id_header,
sentinel_removal, session_id_resolution, snapshot_consistency
- Fix 6 implementation gaps identified by parity analysis:
- Conformant ID format in tests (resp_/item_/msg_ prefixes)
- agent_reference propagation (return {} for None)
- FR-008a output manipulation detection before state validation
- run_background waits for response.created, default in_progress
- FR-013 background+stream disconnect shielding via asyncio.shield()
- CancelledError: re-raise unknown instead of transitioning to failed
- Remove internal spec numbers (FR/S/B) from client-facing error messages
- Add ruff exclude for _generated directory in pyproject.toml
- Fix E501, F821, F841 ruff violations in hand-written source and tests
- Revert accidental ruff --fix changes to generated model files
613 passed, 0 failed, 8 skipped
Ensures _on_ending span processor method and stable baggage/log APIs are available. Avoids edge cases with older SDK versions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e history limit - get_input_expanded now returns list[Item] with proper discriminated subtypes via _deserialize, enabling isinstance checks instead of dict-style type inspection - Replace all hardcoded 10000 history item counts in orchestrator with configurable default_fetch_history_count from ResponsesServerOptions - Add TextResponse convenience class for text-only handlers, supporting both complete text (create_text) and streaming (create_text_stream) - Add StreamingTextDeltas sample demonstrating create_text_stream - Update GetStarted and ConversationHistory samples to use TextResponse - Update FunctionCalling sample/scenario and tests for isinstance checks - Fix ruff lint issues in sample files
…/core/_base.py Co-authored-by: Johan Stenberg (MSFT) <johan.stenberg@microsoft.com>
…ersation stamping, 22 new tests Aligned with Azure.AI.AgentServer.Responses .NET PR #57895: Rule number updates: - Removed dashes from B-XX references (B-11→B11, B-13→B13, etc.) - Remapped S-rules to formalized spec numbering (S-047→B38, S-048→B39, S-007→FR-006, S-008→FR-007, S-021→S-015, etc.) Cancel hardening: - Fixed cancel persistence bug in _finalize_stream - Added 10s cancel grace period in handle_cancel before forcing terminal Delete stream cleanup: - Added delete_stream_events() to protocol and InMemoryResponsesProvider - Handle_delete now cleans up stream events after deleting response Store behavior: - B14: store=false SSE replay now returns 404 (was 400) Conversation stamping (S-040): - Normalized polymorphic conversation (str|ConversationParam_2) to ConversationReference in ResponseEventStream init - Thread conversation_id through apply_common_defaults and all orchestrator call sites to forcibly stamp on lifecycle events - Fixed _resolve_conversation_id to handle dict form Queued status honour: - Background non-stream responses now honour handler-set queued status - Orchestrator transitions through in_progress when going from queued to a terminal state New tests (22 total, 635 pass): - 8 conversation round-trip tests (string/object, default/streaming/bg) - 3 queued status lifecycle tests - 2 GET endpoint tests (Accept header, store=false) - 2 cancel tests (signal trigger, B11 race condition) - 1 delete test (bg completed response) - 6 additional contract test improvements Code formatting: applied ruff format across all files
- _routing.py: use AgentConfig.from_env() for Foundry auto-activation and SSE keep-alive merge instead of private _ENV_* imports - _foundry_settings.py: add from_endpoint() classmethod; from_env() delegates to AgentConfig - _request_parsing.py: _resolve_session_id() takes env_session_id kwarg instead of reading os.environ directly - _endpoint_handler.py: passes host.config.session_id to resolver - _options.py: remove SSE_KEEPALIVE_INTERVAL from from_env(); AgentConfig handles it; inline DEFAULT_FETCH_HISTORY_ITEM_COUNT string - core _config.py: fix _DEFAULT_SSE_KEEPALIVE_INTERVAL from 15 to 0 (disabled by default per container spec) - Revert broken S-024 unknown CancelledError fix (re-add skip) 636 passed, 8 skipped
) Replace the heuristic three-var + FOUNDRY_ENVIRONMENT check with a simple opt-in: is_hosted returns True only when FOUNDRY_HOSTED=true, which the platform injects exclusively into hosted containers. This prevents false-positive Foundry storage auto-activation when a developer sets FOUNDRY_PROJECT_ENDPOINT or other FOUNDRY_* vars locally (e.g. to use agent_framework features) without intending to run in a hosted environment.
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.
Description
Split from PR #45925 for independent review of the
azure-ai-agentserver-responsespackage.This PR builds on the core+invocations changes in #45925 and adds the responses protocol implementation including:
azure.core.AsyncPipelineClient, in-memory provider for testingDependencies
agentserver/invoke-reponses(PR [agentserver] azure-ai-agentserver -core and -invocation packages #45925) which provides the core packageCarried-over review threads from #45925
The following unresolved review threads were moved from the original PR. They all target code in this package.
Code fixes needed (copilot-reviewer)
_http_errors.py_not_foundreturns 404 but usescode="invalid_request"— should usecode="not_found"anderror_type="not_found_error"_handlers.pyresponse_handlervalidates parameter count but does not validate handler isasync defor returnsAsyncIterable_foundry_serializer.pyserialize_create_requestcalls.as_dict()unconditionally — breaks if adictis passed instead of a model_base.pyResponseProviderProtocoldocstrings specifyKeyErrorbut Foundry provider raisesFoundryResourceNotFoundError(2 threads, duplicate)_runtime_state.py[*A, *history]— use deque or accumulate-then-concat_event_subject.pyasyncio.Queueper subscriber with no backpressure — can cause OOM (2 threads, duplicate)_foundry_settings.pybuild_url()uses manual string concatenation — switch tourllib.parse.urlencode_request_parsing.pyDesign/architecture (johanste)
_routing.pyResponseHandlershould inherit fromAgentHostto be the host entry pointsamples/GetStarted/app.pysamples/GetStarted/app.pyResponseHandlershould be the "host" — users should not needAgentHostdirectlySamples (RaviPidaparthi)
samples/README.md