Title: feat: improve schema usability type instantiation · Issue #47 · agentclientprotocol/python-sdk · GitHub
Open Graph Title: feat: improve schema usability type instantiation · Issue #47 · agentclientprotocol/python-sdk
X Title: feat: improve schema usability type instantiation · Issue #47 · agentclientprotocol/python-sdk
Description: Problem statement I'm just diving into using this SDK to add a compatibility layer to an agent service for ACP clients, and encountered a few initial difficulties with regards to the schema that felt could be improved. First is that when...
Open Graph Description: Problem statement I'm just diving into using this SDK to add a compatibility layer to an agent service for ACP clients, and encountered a few initial difficulties with regards to the schema that fe...
X Description: Problem statement I'm just diving into using this SDK to add a compatibility layer to an agent service for ACP clients, and encountered a few initial difficulties with regards to the schema tha...
Opengraph URL: https://github.com/agentclientprotocol/python-sdk/issues/47
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat: improve schema usability type instantiation","articleBody":"### Problem statement\n\nI'm just diving into using this SDK to add a compatibility layer to an agent service for ACP clients, and encountered a few initial difficulties with regards to the schema that felt could be improved.\n\nFirst is that when instantiating classes that have a required field and only one possible value, that field shouldn't need to be provided, it should default. For example, when I construct `AgentMessageChunk`, the `session_update` field only has one possible value, `\"agent_message_chunk\"`. It's a required field, and it cannot be anything else. So why do I have to provide it? I understand that it's used as the discriminator when deserializing, but when `AgentMessageChunk` is constructed explicitly, it shouldn't be needed. This is a common pattern, not exclusive to `AgentMessageChunk`.\n\nHowever if these fields are given a default such as:\n```\nclass AgentMessageChunk(ContentChunk):\n session_update: Annotated[Literal[\"agent_message_chunk\"], Field(alias=\"sessionUpdate\")] = \"agent_message_chunk\"\n```\nThis then leads to another issue, in that when the SDK serializes the message, it's omitted because of `exclude_defaults=True` in https://github.com/agentclientprotocol/python-sdk/blob/a09e090cf3db70491abacb126d016187552796e1/src/acp/utils.py#L33\n\nNow after going through the examples, I noticed that you provide helpers such as `update_agent_message` for addressing this. But IMHO these should not be necessary. When I look at a function or class, and I see that it accepts some type, I shouldn't have to go hunting through the source code to see if there's a helper that is supposed to be used for construction of that type. And while I would argue that the type shouldn't need a helper at all, and that types should be simple to instantiate directly, if there is going to be a helper, I think it would be better for discoverability to put the helper as a static/class method on the class itself. Then if you want to expose all the helpers in some top level package for ease of import, you would declare local variables which reference the static method.\n\n### Proposed solution\n\n* Change all types that have a required parameter with only a single possible value to default to that value.\n* Change `params.model_dump` to use `exclude_defaults=False`.\n * A little more work, but if you still want to use `exclude_defaults`, then implement a custom serializer that does exclude defaults, but only when the field is optional.\n* Remove the helpers.\n\n\n### Alternatives considered\n\nMake the helpers easier to discover by putting them as static methods on the class they construct.\n\n### Additional context\n\n_No response_\n\n### Can you help build it?\n\n- [ ] I can contribute code or docs for this request.","author":{"url":"https://github.com/phemmer","@type":"Person","name":"phemmer"},"datePublished":"2025-12-14T19:37:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/47/python-sdk/issues/47"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fcb96b78-1e32-ea9e-4833-4c4e4662ffe1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8872:268A9:90DD7F:BA1E82:697FE5A1 |
| html-safe-nonce | 9e8dfde7c3ffc4d5a87fc69c8ab29154a054b589b51255df27eee0da623436f7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODcyOjI2OEE5OjkwREQ3RjpCQTFFODI6Njk3RkU1QTEiLCJ2aXNpdG9yX2lkIjoiODMwNjk4Nzg0NzczMTExMTMyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8890e332c512b964cf724e35712eeacb616a23f9aa0acd5dbeb76c07f4fe0f1f |
| hovercard-subject-tag | issue:3727894639 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/agentclientprotocol/python-sdk/47/issue_layout |
| twitter:image | https://opengraph.githubassets.com/38ae7cfe6d9958de82b1074f05781c3b06f6019ff1a3f3014b14fb9abe5e74f6/agentclientprotocol/python-sdk/issues/47 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/38ae7cfe6d9958de82b1074f05781c3b06f6019ff1a3f3014b14fb9abe5e74f6/agentclientprotocol/python-sdk/issues/47 |
| og:image:alt | Problem statement I'm just diving into using this SDK to add a compatibility layer to an agent service for ACP clients, and encountered a few initial difficulties with regards to the schema that fe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | phemmer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/agentclientprotocol/python-sdk git https://github.com/agentclientprotocol/python-sdk.git |
| octolytics-dimension-user_id | 235308037 |
| octolytics-dimension-user_login | agentclientprotocol |
| octolytics-dimension-repository_id | 1051445009 |
| octolytics-dimension-repository_nwo | agentclientprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1051445009 |
| octolytics-dimension-repository_network_root_nwo | agentclientprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width