Skip to content

fix(embed): truncate inputs over 8192-token limit#4

Closed
RomneyDa wants to merge 1 commit into
openclaw:mainfrom
RomneyDa:fix/embed-truncate-oversized-input
Closed

fix(embed): truncate inputs over 8192-token limit#4
RomneyDa wants to merge 1 commit into
openclaw:mainfrom
RomneyDa:fix/embed-truncate-oversized-input

Conversation

@RomneyDa
Copy link
Copy Markdown
Member

Summary

  • Cap embedding input at 24,576 runes (~3 chars/token floor × 8192) so threads with oversized bodies stop blowing the entire batch.
  • Repro added: unit test on embeddingTextForBasis and e2e test with a fake OpenAI server that returns the real 400 error.

Closes #2. Per-model dynamic detection tracked in #3.

Test plan

  • go test ./... (full suite green)
  • Both new tests fail pre-fix with the production error message, pass post-fix

Threads with bodies past OpenAI's embedding cap (e.g. openclaw/openclaw#27137,
10k tokens) failed the entire batch. Cap embedding input to 24576 runes so
3 chars/token-floor content stays under 8192 tokens.

Closes openclaw#2. Per-model dynamic detection tracked in openclaw#3.
@RomneyDa
Copy link
Copy Markdown
Member Author

@vincentkoc fixed!

@RomneyDa RomneyDa closed this Apr 30, 2026
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.

embed fails on threads with bodies over 8192 tokens

1 participant