Skip to content

fix: update sandbox and template models to use Pydantic Field for TTL…#58

Merged
OhYee merged 3 commits intomainfrom
fix-sandbox-ttl-seconds
Mar 3, 2026
Merged

fix: update sandbox and template models to use Pydantic Field for TTL…#58
OhYee merged 3 commits intomainfrom
fix-sandbox-ttl-seconds

Conversation

@Sodawyx
Copy link
Collaborator

@Sodawyx Sodawyx commented Mar 2, 2026

… aliases
issue: #53

This commit modifies the sandbox_ttlin_seconds and sandbox_idle_ttlin_seconds fields in the Sandbox and Template models to utilize Pydantic's Field for aliasing to sandboxTTLInSeconds and sandboxIdleTTLInSeconds, respectively. Additionally, tests have been added to ensure correct parsing and serialization of these fields with their aliases.

Co-developed-by: Aone Copilot noreply@alibaba-inc.com

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?

… aliases

This commit modifies the `sandbox_ttlin_seconds` and `sandbox_idle_ttlin_seconds` fields in the `Sandbox` and `Template` models to utilize Pydantic's `Field` for aliasing to `sandboxTTLInSeconds` and `sandboxIdleTTLInSeconds`, respectively. Additionally, tests have been added to ensure correct parsing and serialization of these fields with their aliases.

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
Copy link
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

This PR fixes Issue #53 by explicitly aliasing TTL-related fields that contain an acronym (TTL) so they correctly parse from/serialize to the Alibaba Cloud API’s expected camelCase keys (e.g., sandboxTTLInSeconds).

Changes:

  • Add explicit Pydantic Field(..., alias=...) for TTL fields in Template, Sandbox, and TemplateInput.
  • Add unit tests covering alias parsing/serialization and from_inner_object() behavior for the TTL fields.
  • Minor test/style formatting cleanups in OpenAPI and integration test fixtures.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
agentrun/sandbox/template.py Explicit alias for Template.sandbox_ttlin_secondssandboxTTLInSeconds.
agentrun/sandbox/sandbox.py Explicit alias for Sandbox.sandbox_idle_ttlin_secondssandboxIdleTTLInSeconds.
agentrun/sandbox/model.py Explicit alias for TemplateInput.sandbox_ttlin_secondssandboxTTLInSeconds.
agentrun/sandbox/__template_async_template.py Keeps the codegen source template in sync with the TTL alias fix.
agentrun/sandbox/__sandbox_async_template.py Keeps the codegen source template in sync with the idle TTL alias fix.
tests/unittests/utils/test_model.py Adds tests validating TTL alias parse/serialize behavior and from_inner_object() parsing.
tests/unittests/toolset/api/test_openapi.py Formatting-only change to $ref strings in test schemas.
tests/unittests/integration/test_langchain_agui_integration.py Formatting-only change to request JSON message content strings.
agentrun/integration/utils/tool.py Formatting-only change for how description is constructed in schema building.

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

OhYee added 2 commits March 3, 2026 11:52
…ng in CI

Migrate test implementations to use astream(stream_mode="updates") instead of astream_events to resolve async generator cancellation issues in CI environments. Also switch from httpx.ASGITransport to real HTTP servers with uvicorn for proper SSE stream handling in tests, addressing flaky streaming behavior in Linux CI environments.

将测试实现从 astream_events 迁移到 astream(stream_mode="updates") 以解决 CI 环境中的异步生成器取消问题。同时从 httpx.ASGITransport 切换到使用 uvicorn 的真实 HTTP 服务器,以正确处理测试中的 SSE 流式传输,解决 Linux CI 环境中的不稳定流式行为。

Change-Id: I4e9f694a80e952a94e240f479bb40fef59c0d649
Signed-off-by: OhYee <oyohyee@oyohyee.com>
test: improve SSE streaming test reliability in CI environment
@OhYee OhYee merged commit 7f2a74f into main Mar 3, 2026
2 checks passed
@OhYee OhYee deleted the fix-sandbox-ttl-seconds branch March 3, 2026 04:29
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