fix: add OTS instance endpoint fallback#127
Merged
Merged
Conversation
Signed-off-by: hzzz2020 <hz403446@alibaba-inc.com>
774b52c to
06b262d
Compare
Contributor
There was a problem hiding this comment.
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
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix bugs
Bug detail
Pull request tasks
Update docs
Reason for update
Pull request tasks
Add contributor
Contributed content
Content detail
Others
Reason for update