Skip to content

fix: add OTS instance endpoint fallback#127

Merged
OhYee merged 1 commit into
mainfrom
codex/ots-instance-endpoint-fallback
Jun 23, 2026
Merged

fix: add OTS instance endpoint fallback#127
OhYee merged 1 commit into
mainfrom
codex/ots-instance-endpoint-fallback

Conversation

@hhuangzhen

Copy link
Copy Markdown
Collaborator

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?

Signed-off-by: hzzz2020 <hz403446@alibaba-inc.com>
@hhuangzhen hhuangzhen force-pushed the codex/ots-instance-endpoint-fallback branch from 774b52c to 06b262d Compare June 23, 2026 08:32
@hhuangzhen hhuangzhen requested a review from OhYee June 23, 2026 08:35
@OhYee OhYee requested a review from Copilot June 23, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates OTS knowledge base retrieval to primarily use the instance-specific OTS endpoint and introduces a fallback to the legacy “frontend” endpoint when instance-endpoint retrieval fails (only in public/non-VPC mode).

Changes:

  • Switch Config.get_ots_endpoint() (public mode) from the shared frontend domain to the instance-specific HTTPS endpoint.
  • Add instance-endpoint failure fallback logic in OTSDataAPI.retrieve() / retrieve_async() (and corresponding template).
  • Update and extend unit tests to validate the new endpoint selection and fallback behavior (sync + async).

Reviewed changes

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

Show a summary per file
File Description
agentrun/utils/config.py Changes default (public) OTS endpoint construction to instance-specific https://{instance}.{region}.ots.aliyuncs.com.
agentrun/knowledgebase/api/__data_async_template.py Adds OTS client override + fallback endpoint builder and fallback retry logic (template source for codegen).
agentrun/knowledgebase/api/data.py Auto-generated output reflecting the template changes, including fallback behavior in OTS retrieval.
tests/unittests/utils/test_config.py Updates expectations for the new default public OTS endpoint format.
tests/unittests/knowledgebase/test_ots_knowledgebase.py Adds/updates tests to cover fallback behavior and updated endpoint usage for OTS client construction.

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

Comment on lines +679 to +683
def _build_frontend_ots_endpoint(
self, config: Optional[Config] = None
) -> str:
cfg = Config.with_configs(self.config, config)
return f"http://ots-{cfg.get_region_id()}.aliyuncs.com"
Comment on lines 855 to +860
logger.debug(f"OTS retrieve request: {request}")
response = client.retrieve(request)
try:
response = client.retrieve(request)
except Exception as instance_error:
if not self._can_fallback_to_frontend_ots_endpoint(config):
raise
@OhYee OhYee merged commit dd900cf into main Jun 23, 2026
4 checks passed
@OhYee OhYee deleted the codex/ots-instance-endpoint-fallback branch June 23, 2026 12:33
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