Skip to content

fix(embedding): stop forcing dimensions on OpenAI-compatible embedding calls - #2542

Open
mesutoezdil wants to merge 5 commits into
kagent-dev:mainfrom
mesutoezdil:fix/embedding-dimensions-openai-compatible
Open

fix(embedding): stop forcing dimensions on OpenAI-compatible embedding calls#2542
mesutoezdil wants to merge 5 commits into
kagent-dev:mainfrom
mesutoezdil:fix/embedding-dimensions-openai-compatible

Conversation

@mesutoezdil

Copy link
Copy Markdown
Contributor

The openai, azure_openai, and foundry embedding paths in both the Go and Python runtimes asked for exactly 768 dimensions unconditionally. Providers that only offer other sizes, such as Bedrock Titan behind an OpenAI-compatible gateway, reject the request outright, even though the existing truncate and normalize step already handles anything larger than 768. Drops the dimensions parameter on these paths, since the truncate and normalize step already covers it.

…g calls

The openai, azure_openai, and foundry embedding paths in both the Go
and Python runtimes asked for exactly 768 dimensions unconditionally.
Providers that only offer other sizes (e.g. Bedrock Titan behind an
OpenAI-compatible gateway) reject the request outright, even though
the existing truncate/normalize step already handles any size above
768.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
@EItanya
EItanya requested a balanced review from Copilot August 24, 2026 17:51

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Removes the hardcoded dimensions=768 parameter from OpenAI-compatible embedding requests so providers that don’t support exactly 768 dimensions can still be used, relying on existing truncate/normalize post-processing.

Changes:

  • Drop the dimensions parameter from the Python OpenAI embedding call path.
  • Drop the Dimensions field from the Go OpenAI embedding request payload.
  • Add/adjust unit tests to assert dimensions is not sent.

Reviewed changes

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

File Description
python/packages/kagent-adk/tests/unittests/test_embedding.py Adds a unit test asserting the OpenAI embedding call omits dimensions.
python/packages/kagent-adk/src/kagent/adk/models/_embedding.py Removes dimensions=self.TARGET_DIMENSION from the OpenAI embeddings request.
go/adk/pkg/embedding/embedding_test.go Updates the OpenAI provider test expectation to ensure dimensions is not sent.
go/adk/pkg/embedding/embedding.go Removes Dimensions from the OpenAI embeddings request params.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread go/adk/pkg/embedding/embedding_test.go Outdated
Comment thread python/packages/kagent-adk/tests/unittests/test_embedding.py Outdated
Decoding into an int field could not tell an absent dimensions key
from an explicit 0. Check the raw JSON body instead.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
…ons-openai-compatible

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
…ons-openai-compatible

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
…ons-openai-compatible

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants