Skip to content

fix: auto-append /v1 to embedding API base URL#6909

Open
Yaohua-Leo wants to merge 6 commits intoAstrBotDevs:masterfrom
Yaohua-Leo:fix/6855-embedding-api-base-v1
Open

fix: auto-append /v1 to embedding API base URL#6909
Yaohua-Leo wants to merge 6 commits intoAstrBotDevs:masterfrom
Yaohua-Leo:fix/6855-embedding-api-base-v1

Conversation

@Yaohua-Leo
Copy link
Contributor

@Yaohua-Leo Yaohua-Leo commented Mar 24, 2026

Summary

  • Automatically append /v1 to embedding_api_base if not already present
  • Fixes issue where embedding providers like SiliconFlow fail without /v1 suffix

Changes

  • Modified openai_embedding_source.py to check if API base ends with /v1
  • If not present, automatically appends /v1 to the base URL

Fixes #6855

Summary by Sourcery

Ensure embedding API base URLs are normalized and propagate tool call timeouts through subagent handoffs.

Bug Fixes:

  • Normalize embedding API base URLs by automatically appending the /v1 suffix when missing to prevent failures with providers that require it.

Enhancements:

  • Pass the configured tool_call_timeout from the run context through to the subagent tool loop during handoffs.

Tests:

  • Add a unit test verifying that tool_call_timeout is forwarded to the tool loop agent during handoff execution.

LehaoLin added 5 commits March 21, 2026 00:58
- Add tool_call_timeout parameter to _execute_handoff method
- Pass run_context.tool_call_timeout to ctx.tool_loop_agent
- Add unit test to verify tool_call_timeout is correctly passed
- Fixes AstrBotDevs#6711: SubAgent MCP tool call timeout now respects configured timeout

The SubAgent handoff execution was using the default 60-second timeout
instead of the configured tool_call_timeout from provider settings.
This change ensures that SubAgent MCP tool calls respect the user's
configured timeout settings.
- Restore test_collect_handoff_image_urls_filters_extensionless_missing_event_file
- Fix test_collect_handoff_image_urls_keeps_extensionless_existing_event_file assertion
- Keep new test_execute_handoff_passes_tool_call_timeout_to_tool_loop_agent
- Pass run_context.tool_call_timeout directly to ctx.tool_loop_agent
- Remove unnecessary local variable assignment
- Addresses review feedback from Sourcery AI
- Automatically append /v1 to embedding_api_base if not already present
- Fixes issue where embedding providers like SiliconFlow fail without /v1 suffix

Fixes AstrBotDevs#6855
@auto-assign auto-assign bot requested review from Raven95676 and Soulter March 24, 2026 17:15
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 24, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of API interactions by ensuring that embedding API base URLs are correctly formatted with the '/v1' suffix, preventing potential connection issues with certain providers. Additionally, it improves agent execution by properly propagating tool call timeout settings, allowing for more controlled and reliable tool usage. These changes collectively contribute to a more stable and predictable system behavior.

Highlights

  • Embedding API Base URL Fix: Automatically appends '/v1' to the embedding_api_base if it's not already present, resolving issues with providers like SiliconFlow.
  • Tool Call Timeout Propagation: The tool_call_timeout parameter is now correctly passed to the tool_loop_agent during agent handoff execution.
  • New Test Case: A new unit test was added to verify that the tool_call_timeout is properly handled and passed to the agent.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. label Mar 24, 2026
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The /v1 auto-append logic assumes the version segment is at the end of the URL; if a user configures an embedding_api_base that already includes deeper paths (e.g. /v1/embeddings or another versioned path), this will silently produce incorrect URLs—consider parsing the URL path and only adding /v1 when there is no path or only /.
  • When passing tool_call_timeout=run_context.tool_call_timeout into tool_loop_agent, this now hard-depends on that attribute being present on all run_context instances; if that’s not guaranteed, consider using a default via getattr(run_context, 'tool_call_timeout', <default>) to avoid potential AttributeErrors.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `/v1` auto-append logic assumes the version segment is at the end of the URL; if a user configures an `embedding_api_base` that already includes deeper paths (e.g. `/v1/embeddings` or another versioned path), this will silently produce incorrect URLs—consider parsing the URL path and only adding `/v1` when there is no path or only `/`.
- When passing `tool_call_timeout=run_context.tool_call_timeout` into `tool_loop_agent`, this now hard-depends on that attribute being present on all `run_context` instances; if that’s not guaranteed, consider using a default via `getattr(run_context, 'tool_call_timeout', <default>)` to avoid potential `AttributeError`s.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to pass a tool_call_timeout to the agent's tool execution loop, ensuring that tool calls can respect a specified timeout. This is implemented by adding the tool_call_timeout argument to the tool_loop_agent call within the _execute_handoff function, and a new unit test has been added to verify this functionality. Additionally, the PR standardizes the OpenAI embedding API base URL by ensuring it always ends with /v1. There is no feedback to provide on the review comments as none were submitted.

- Parse URL to check if path exists before appending /v1
- Avoids incorrect URLs when user configures paths like /v1/embeddings
- Addresses Sourcery review feedback

Fixes AstrBotDevs#6855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]调用OpenAI embedding类型的embedding provider时不会自动补全/v1

1 participant