Skip to content

feat(super-agent): make modelService/modelName fields optional#93

Merged
OhYee merged 1 commit intomainfrom
feat/super-agent-optional-model-fields
Apr 25, 2026
Merged

feat(super-agent): make modelService/modelName fields optional#93
OhYee merged 1 commit intomainfrom
feat/super-agent-optional-model-fields

Conversation

@Sodawyx
Copy link
Copy Markdown
Collaborator

@Sodawyx Sodawyx commented Apr 25, 2026

Backend now allows modelServiceName / modelName to be absent from create and invoke JSON. SDK omits unset scalar / empty-list fields from forwardedProps on create and invoke paths while preserving null-as-clear semantics on update.

  • Add _prune_forwarded_props helper in api/control.py.
  • Plumb prune_props flag through _build_protocol_settings_config and _build_protocol_configuration; to_create_input opts in, to_update_input stays default-False so update(model_name=None) still clears.
  • Prune forwarded_extras inside SuperAgentDataAPI._build_invoke_body before injecting SDK-managed metadata / conversationId; drop any leaked conversationId when caller passes conversation_id=None.
  • Sync agentrun/super_agent/api/__data_async_template.py and agentrun/super_agent/__agent_async_template.py so codegen cannot revert the change; clarify _forwarded_business_fields docstring to point at the downstream pruning step.
  • Tests: 6 unit tests for the helper, 4 new tests for create / invoke pruning behavior, 2 regression tests locking in update null preservation, 1 test for the defensive conversationId pop.

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Bug detail

The specific manifestation of the bug or the associated issue.

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

Backend now allows modelServiceName / modelName to be absent from
create and invoke JSON. SDK omits unset scalar / empty-list fields
from forwardedProps on create and invoke paths while preserving
null-as-clear semantics on update.

- Add _prune_forwarded_props helper in api/control.py.
- Plumb prune_props flag through _build_protocol_settings_config and
  _build_protocol_configuration; to_create_input opts in, to_update_input
  stays default-False so update(model_name=None) still clears.
- Prune forwarded_extras inside SuperAgentDataAPI._build_invoke_body
  before injecting SDK-managed metadata / conversationId; drop any
  leaked conversationId when caller passes conversation_id=None.
- Sync agentrun/super_agent/api/__data_async_template.py and
  agentrun/super_agent/__agent_async_template.py so codegen cannot
  revert the change; clarify _forwarded_business_fields docstring to
  point at the downstream pruning step.
- Tests: 6 unit tests for the helper, 4 new tests for create / invoke
  pruning behavior, 2 regression tests locking in update null
  preservation, 1 test for the defensive conversationId pop.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the SuperAgent SDK request payload shaping so modelServiceName / modelName (and other unset fields) can be omitted on create/invoke, matching backend support, while preserving null-as-clear semantics on update.

Changes:

  • Add _prune_forwarded_props and thread a prune_props flag through protocol configuration building so create prunes unset/empty fields while update retains None/[].
  • Prune forwarded_extras in SuperAgentDataAPI._build_invoke_body, ensuring SDK-managed fields (metadata, conversationId) are not overridden and leaked conversationId is defensively removed when conversation_id=None.
  • Add/extend unit tests covering pruning behavior for create/invoke and regression coverage for update null preservation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
agentrun/super_agent/api/control.py Introduces _prune_forwarded_props and enables pruning for create payload construction via prune_props=True.
agentrun/super_agent/api/data.py Prunes forwarded_extras before injecting SDK-managed metadata/conversationId; drops leaked conversationId when appropriate.
agentrun/super_agent/api/__data_async_template.py Mirrors data.py pruning logic so codegen won’t revert behavior.
agentrun/super_agent/agent.py Updates _forwarded_business_fields docstring to reflect downstream pruning behavior.
agentrun/super_agent/__agent_async_template.py Mirrors agent.py docstring update to keep codegen consistent.
tests/unittests/super_agent/test_control.py Adds focused unit tests for _prune_forwarded_props and create/update pruning/null-preservation behaviors.
tests/unittests/super_agent/test_data_api.py Adds invoke payload pruning tests, metadata preservation, and defensive conversationId drop regression test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@OhYee OhYee merged commit 95129cf into main Apr 25, 2026
6 checks passed
@OhYee OhYee deleted the feat/super-agent-optional-model-fields branch April 25, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants