Skip to content

Decouple AgentServer responses from generated model internals#47995

Draft
Shivakishore14 wants to merge 3 commits into
mainfrom
sshiva/agentserver-typeddict-local
Draft

Decouple AgentServer responses from generated model internals#47995
Shivakishore14 wants to merge 3 commits into
mainfrom
sshiva/agentserver-typeddict-local

Conversation

@Shivakishore14

@Shivakishore14 Shivakishore14 commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary

  • localize AgentServer response contracts as TypedDict/dict wire payloads
  • remove runtime dependency on generated model constructors, serialization helpers, and nested generated SDK model paths
  • regenerate the local response TypedDict models from the source-built Azure/typespec-azure Python emitter that supports models-mode=typeddict
  • update storage, streaming, validation, samples, and tests to use dict-native response payloads

Validation

  • make generate-models TYPESPEC_PYTHON_EMITTER_PATH=/tmp/typespec-azure-agentserver/packages/typespec-python
  • make generate-openapi && make generate-validators
  • PYTHONPATH=. /tmp/azsdk-agentserver-cleanup-venv/bin/python -m pytest tests/unit tests/contract tests/interop -q
    • 951 passed, 1 warning

Current source-emitter gaps

  • Enum generation is incomplete: the source emitter outputs Literal[...] aliases, but generated annotations still reference EnumName.MEMBER, and the expected _enums.py module is not emitted. The finalizer currently adds enum-like fallback exports and rewrites generated enum-member references to literal strings.
  • Generated package is nested too deeply: source output lands under _generated/agentserver/responses/models/; the finalizer extracts the emitted TypedDict files into the local _generated/ package boundary.
  • TypedDict mode still emits client/operation files: the source emitter emits _client.py, _configuration.py, operations/, and aio/; the finalizer copies only the model contract files needed by AgentServer.
  • Synced TypeSpec overlay has stale OpenAI references: client.tsp still references removed OpenAI symbols (OutputItemComputerToolCallOutputResource, OutputItemCustomToolCall, OutputItemCustomToolCallOutput, FunctionToolCallOutputResource), so the finalizer removes those stale @@usage lines before compilation.
  • No published npm package supports this yet: npm latest and next still reject models-mode=typeddict; generation currently requires a source-built emitter from Azure/typespec-azure/main via TYPESPEC_PYTHON_EMITTER_PATH.
  • Post-processing is still required: finalization currently patches stale TypeSpec usage refs, extracts nested model output, patches enum references, strips trailing whitespace, and keeps validators generated from OpenAPI.

Upstream asks

  • Fix TypedDict enum emission so generated code imports and supports runtime constants without a local fallback.
  • Support model-only / flat TypedDict output for this local contract package shape.
  • Publish an emitter version with models-mode=typeddict support.
  • Update the AgentServer TypeSpec overlay to remove stale OpenAI symbol references.

Notes

  • This PR is scoped to sdk/agentserver/azure-ai-agentserver-responses.

Move response contracts to local TypedDict wire payloads and remove runtime reliance on generated model constructors, serialization helpers, and nested generated SDK model paths.

Keep validation behind a stable local wrapper and update tests to exercise dict-native payloads instead of generated model runtime callability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Hosted Agents sdk/agentserver/* label Jul 10, 2026
Shivakishore14 and others added 2 commits July 10, 2026 12:44
Use the source-built TypeSpec Python emitter TypedDict output as the model source instead of the localized bridge artifact.

Normalize the emitted package into the local AgentServer generated boundary and remove fake model_base/_models compatibility shims.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant