You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: [Bug]: a declarative Model component cannot be loaded through agent_schema_dispatch #9866
agent_schema_dispatch contains two case "model" branches. The first returns a ModelResource, which makes the second branch, returning a Model, unreachable dead code. A spec tagging a model with the fields the Model class actually carries raises a TypeError, so there is no input shape that loads a Model through the dispatch.
Expected Behavior
A model specification with id, provider, apiType, connection, or options loads as a Model through the exported dispatch, while resource shaped payloads (kind, name, id) keep loading as ModelResource.
Both classes are part of the exported AgentSchemaSpec union and both claim the model kind, so dispatch needs to pick between them by shape: a schema carrying any model specification field belongs to Model, everything else stays with the model resource. I have a fix ready once the team agrees with the direction.
Acknowledgements
I searched existing issues and did not find a duplicate.
I personally verified this behavior and the reproduction details are authentic.
I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
changed the title [-]Declarative: a Model component cannot be loaded through agent_schema_dispatch[/-][+]Python: [Bug]: a declarative Model component cannot be loaded through agent_schema_dispatch[/+]on Oct 31, 2026
Thanks for the clear reproduction. The team will consider standalone model-specification loading through the declarative dispatcher as core MAF behavior. We need to settle how model specifications and model resources are distinguished while preserving existing resource loading. This is not a commitment to implementation or timing; please keep implementation on hold while that contract is planned.
/plan Plan the core-accepted request for standalone Model-specification loading through agent_schema_dispatch on current main. Preserve maintained kind:model-to-ModelResource behavior and normal nested model loading; Model itself has no kind field, and direct untagged Model.from_dict already works. The duplicate model case and reported TypeError are independently confirmed, but removing dead code alone does not establish a safe public dispatch contract. Determine the simplest explicit, compatible distinction between model specifications and resource references, including ID-only, empty, mixed name/provider fields, and malformed payloads; do not silently reinterpret existing resources or discard fields. Reconcile AgentSchemaSpec and constructor/tag handling, and specify focused dispatcher, resource, typed-model, nested-agent, and case-normalization controls. Establish the smallest correct production scope before readiness. Original contributor PR #9867 is already closed pending agreement; do not reopen it or start competing implementation. This request is for planning, not implementation approval. Retain triage, do not add ready-for-implementation, and defer assignment until the public contract is settled.
agent_schema_dispatch has two case "model" branches in _models.py. The first returns ModelResource, so the second (Model) can never run. A tagged payload with provider, apiType, connection or options therefore fails with a TypeError. The maintainer decision is that standalone model-specification loading through the dispatcher is core behavior. This is a plan only. Nothing has been changed, run or tested.
Findings from the current code (read, not executed)
Model.__init__ accepts only id, provider, apiType, connection, options. It has no kind and no **kwargs.
SerializationMixin.from_dict forwards every key except type to the constructor. So a payload tagged kind: model would also fail on Model with an unexpected kind argument. Deleting the dead case is not enough. The dispatcher must stop passing kind to Model.
ModelResource takes kind, name, id. Resource.from_dict and AgentManifest.resources always build ModelResource for kind: model. PromptAgent.model already builds Model directly. AgentSchemaSpec already lists both classes, so the union needs no change.
id is valid for both shapes, so it cannot decide between them. Only name (resource) and provider/apiType/connection/options (specification) can.
The existing test test_agent_schema_dispatch_model_resource covers kind: Model + name + id → ModelResource. There is no test for loading a Model through the dispatcher.
Recommendation
Code change, small and limited to the dispatcher. It is warranted because there is currently no input shape that loads a Model through the public dispatcher. The workaround, calling Model.from_dict(...) directly without kind, works but bypasses the dispatcher. I do not recommend adding a new discriminator field or changing Resource, ModelResource, AgentManifest or AgentSchemaSpec.
Proposed contract (for maintainer agreement)
For kind equal to model (case-insensitive, as today):
Payload (besides kind)
Result
Only resource fields: name, id, name+id, or nothing (empty)
ModelResource (unchanged)
Any specification field set: provider, apiType, connection, options
Model (built from a copy without kind)
id plus specification fields (no name)
Model
name together with any specification field
ValueError naming the conflicting keys. Nothing is dropped.
Unknown extra keys
Same as today for the chosen class (constructor TypeError)
Notes on the choices:
"Set" means key present with a non-None value, so provider: null does not flip an existing resource.
An ID-only spec such as {kind: model, id: gpt-4o} stays a ModelResource. This keeps existing resources working. Standalone ID-only specs must use Model.from_dict or nesting. Document this boundary.
Do not mutate the caller's dict when removing kind.
The explicit error for mixed name and specification fields is preferred over guessing. Today those payloads already fail with TypeError, so no working input changes meaning.
Key names stay case-sensitive, as with all other fields. Only the kind value is normalized.
Proposed plan
In agent_schema_dispatch, remove the unreachable second case "model". Route the single model case through a small helper that applies the table above. Keep it in the dispatcher so Resource.from_dict and manifests are untouched.
Dispatcher tests: kind: model/Model/MODEL with provider+apiType+id → Model with correct fields and nested Connection/ModelOptions. Also test options-only, connection-only, and id+provider.
Compatibility tests: name+id, name only, id only and empty payload → ModelResource. name+provider → ValueError. provider: null + name → ModelResource. Input dict is unchanged after the call.
Check that the earlier Resource.from_dict/AgentManifest.resources tests still pass (kind: model there stays ModelResource). Also check that untagged Model.from_dict and PromptAgent(model={...}) (which ignores kind) behave as before.
Malformed input: non-mapping connection/options still raises from the existing constructors, and the plan should assert that error type rather than add new validation.
Add a short docstring note on the dispatcher about how model specifications and resources are told apart, including the ID-only boundary. No sample changes are needed.
Done when the reported repro returns a Model, all existing declarative tests pass, and the new tests above pass. Run python/packages/declarative tests plus the repo's lint/type checks.
Open point for maintainers
Is "ID-only stays ModelResource" the intended boundary? If you would rather have a way to request a Model for ID-only payloads, that would need a new explicit marker. That is a larger public API change, so I'd defer it unless wanted.
Per the request, triage stays, ready-for-implementation is not suggested, and assignment waits until this contract is agreed. PR #9867 is not touched.
Generated by Issue Planning for #9866 · copilot · auto · ~23 AIC · ⌖ ~1 AIC · ⊞ 4.8K · ◷
Activity
eavanvalkenburg commentedon Oct 30, 2026
please use the defined issue templates and wait for the team to review before opening a PR Manohar Paturi (@ManoharPaturi)
[-]Declarative: a Model component cannot be loaded through agent_schema_dispatch[/-][+]Python: [Bug]: a declarative Model component cannot be loaded through agent_schema_dispatch[/+]eavanvalkenburg commentedon Nov 9, 2026
Thanks for the clear reproduction. The team will consider standalone model-specification loading through the declarative dispatcher as core MAF behavior. We need to settle how model specifications and model resources are distinguished while preserving existing resource loading. This is not a commitment to implementation or timing; please keep implementation on hold while that contract is planned.
eavanvalkenburg commentedon Nov 9, 2026
/plan Plan the core-accepted request for standalone Model-specification loading through agent_schema_dispatch on current main. Preserve maintained kind:model-to-ModelResource behavior and normal nested model loading; Model itself has no kind field, and direct untagged Model.from_dict already works. The duplicate model case and reported TypeError are independently confirmed, but removing dead code alone does not establish a safe public dispatch contract. Determine the simplest explicit, compatible distinction between model specifications and resource references, including ID-only, empty, mixed name/provider fields, and malformed payloads; do not silently reinterpret existing resources or discard fields. Reconcile AgentSchemaSpec and constructor/tag handling, and specify focused dispatcher, resource, typed-model, nested-agent, and case-normalization controls. Establish the smallest correct production scope before readiness. Original contributor PR #9867 is already closed pending agreement; do not reopen it or start competing implementation. This request is for planning, not implementation approval. Retain triage, do not add ready-for-implementation, and defer assignment until the public contract is settled.
github-actions commentedon Nov 9, 2026
Summary
agent_schema_dispatchhas twocase "model"branches in_models.py. The first returnsModelResource, so the second (Model) can never run. A tagged payload withprovider,apiType,connectionoroptionstherefore fails with aTypeError. The maintainer decision is that standalone model-specification loading through the dispatcher is core behavior. This is a plan only. Nothing has been changed, run or tested.Findings from the current code (read, not executed)
Model.__init__accepts onlyid, provider, apiType, connection, options. It has nokindand no**kwargs.SerializationMixin.from_dictforwards every key excepttypeto the constructor. So a payload taggedkind: modelwould also fail onModelwith an unexpectedkindargument. Deleting the deadcaseis not enough. The dispatcher must stop passingkindtoModel.ModelResourcetakeskind, name, id.Resource.from_dictandAgentManifest.resourcesalways buildModelResourceforkind: model.PromptAgent.modelalready buildsModeldirectly.AgentSchemaSpecalready lists both classes, so the union needs no change.idis valid for both shapes, so it cannot decide between them. Onlyname(resource) andprovider/apiType/connection/options(specification) can.test_agent_schema_dispatch_model_resourcecoverskind: Model+name+id→ModelResource. There is no test for loading aModelthrough the dispatcher.Recommendation
Code change, small and limited to the dispatcher. It is warranted because there is currently no input shape that loads a
Modelthrough the public dispatcher. The workaround, callingModel.from_dict(...)directly withoutkind, works but bypasses the dispatcher. I do not recommend adding a new discriminator field or changingResource,ModelResource,AgentManifestorAgentSchemaSpec.Proposed contract (for maintainer agreement)
For
kindequal tomodel(case-insensitive, as today):kind)name,id,name+id, or nothing (empty)ModelResource(unchanged)provider,apiType,connection,optionsModel(built from a copy withoutkind)idplus specification fields (noname)Modelnametogether with any specification fieldValueErrornaming the conflicting keys. Nothing is dropped.TypeError)Notes on the choices:
Nonevalue, soprovider: nulldoes not flip an existing resource.{kind: model, id: gpt-4o}stays aModelResource. This keeps existing resources working. Standalone ID-only specs must useModel.from_dictor nesting. Document this boundary.kind.nameand specification fields is preferred over guessing. Today those payloads already fail withTypeError, so no working input changes meaning.kindvalue is normalized.Proposed plan
agent_schema_dispatch, remove the unreachable secondcase "model". Route the singlemodelcase through a small helper that applies the table above. Keep it in the dispatcher soResource.from_dictand manifests are untouched.kind: model/Model/MODELwithprovider+apiType+id→Modelwith correct fields and nestedConnection/ModelOptions. Also testoptions-only,connection-only, andid+provider.name+id,nameonly,idonly and empty payload →ModelResource.name+provider→ValueError.provider: null+name→ModelResource. Input dict is unchanged after the call.Resource.from_dict/AgentManifest.resourcestests still pass (kind: modelthere staysModelResource). Also check that untaggedModel.from_dictandPromptAgent(model={...})(which ignores kind) behave as before.connection/optionsstill raises from the existing constructors, and the plan should assert that error type rather than add new validation.Model, all existing declarative tests pass, and the new tests above pass. Runpython/packages/declarativetests plus the repo's lint/type checks.Open point for maintainers
Is "ID-only stays
ModelResource" the intended boundary? If you would rather have a way to request aModelfor ID-only payloads, that would need a new explicit marker. That is a larger public API change, so I'd defer it unless wanted.Per the request,
triagestays,ready-for-implementationis not suggested, and assignment waits until this contract is agreed. PR #9867 is not touched.ManoharPaturi commentedon Nov 10, 2026
Eduard van Valkenburg (@eavanvalkenburg) should i start working on this ?