Skip to content

fix(custom tool): prevent Authorization prefix accumulation#36350

Open
Epochex wants to merge 1 commit into
langgenius:mainfrom
Epochex:fix/custom-tool-auth-prefix-mutation
Open

fix(custom tool): prevent Authorization prefix accumulation#36350
Epochex wants to merge 1 commit into
langgenius:mainfrom
Epochex:fix/custom-tool-auth-prefix-mutation

Conversation

@Epochex
Copy link
Copy Markdown

@Epochex Epochex commented May 18, 2026

Fixes #35974.

Custom tool API-key auth was mutating runtime.credentials["api_key_value"] when adding the Bearer/Basic prefix. Because ToolRuntime can be reused across invocations (multi-step agent runs, retries, parallel calls), the prefix could accumulate over time (e.g. Bearer Bearer ).

This change:

  • Computes the prefixed header value without mutating runtime.credentials.
  • Avoids double-prefixing when the stored value is already prefixed.

Tests:

  • uv run --project api pytest -q api/tests/unit_tests/core/tools/test_custom_tool.py -k assembling_request

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 18, 2026
@Epochex
Copy link
Copy Markdown
Author

Epochex commented May 18, 2026

Actions checks haven’t started for this fork PR yet (workflow runs show “Action required”).

I ran the relevant unit test + ruff locally and they pass:

  • uv run --project api pytest -q api/tests/unit_tests/core/tools/test_custom_tool.py -k assembling_request
  • uv run --project api ruff check api/core/tools/custom_tool/tool.py api/tests/unit_tests/core/tools/test_custom_tool.py

Could a maintainer please approve/run the workflows so CI can execute?

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

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Authorization header prefix ("Bearer "/"Basic ") accumulates on repeated Custom Tool calls due to credentials mutation

1 participant