Feat: Use AuthPreprocessor in LlmAgent#444
Merged
kalenkevich merged 7 commits intoJun 22, 2026
Merged
Conversation
kalenkevich
reviewed
Jun 18, 2026
Comment on lines
+28
to
+31
| authConfig?: AuthConfig; | ||
| auth_config?: AuthConfig; | ||
| functionCallId?: string; | ||
| function_call_id?: string; |
Collaborator
There was a problem hiding this comment.
Do you know why it is like that?
Can we camelCase all the values somehow not to introduce such types?
Collaborator
Author
There was a problem hiding this comment.
I agree that we should avoid duplicate types. I have refactored this by adding a recursive camelCaseKeys utility to normalize all incoming event arguments in AuthPreprocessor. This allowed us to simplify the RequestCredentialArgs interface to only contain camelCase fields, while maintaining compatibility with snake_case arguments sent by Python or other clients. I also added unit tests to verify this normalization.
added 6 commits
June 22, 2026 12:18
…am filtering in RestApiTool
d617b4f to
2d61aa6
Compare
kalenkevich
approved these changes
Jun 22, 2026
Merged
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Closes: #
Related: #
Problem:
Previously,
LlmAgentdid not have a mechanism to handle tool authentication flows. If a tool required authentication (e.g., API key, OAuth), there was no standard way to pause execution, request credentials from the user, store them, and resume tool execution.Solution:
This PR implements
AuthPreprocessorinLlmAgentand integrates it withRestApiToolto support authenticated tool execution.Key changes:
AuthPreprocessor: A new request processor registered by default inLlmAgent. It intercepts the flow when a tool returns a pending auth status, yields a credential request event, and pauses execution. When the user provides the credentials, it stores them and retries the failed tool before resuming the LLM interaction.isFinalResponseUpdate: ModifiedisFinalResponseincore/src/events/event.tsto returntruewhen auth configs are requested. This ensures the runner stops and waits for user input.RestApiTool: Implemented a tool that represents an OpenAPI operation. It usesToolAuthHandlerto check for credentials and returns a pending status if credentials are required but missing.AUTH_PREPROCESSOR,AuthPreprocessor, andRestApiToolincore/src/common.ts.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
We added/updated the following test suites:
core/test/auth/auth_preprocessor_test.ts: TestsAuthPreprocessorlogic.core/test/agents/llm_agent_auth_integration_test.ts: Integration test simulating the full auth request/resume flow with a mock LLM and a local HTTP server.core/test/events/event_test.ts: TestsisFinalResponsewith requested auth configs.core/test/tools/openapi_tool/rest_api_tool_test.ts: TestsRestApiToolcredential handling and request preparation.All tests passed locally (90 tests in total).
Manual End-to-End (E2E) Tests:
We added an E2E test:
tests/e2e/tools/rest_api_tool_auth_e2e_test.tswhich runs a local server and uses a real Gemini model to verify the auth flow.Note: This test is skipped locally if
GEMINI_API_KEY(or equivalent) is not set in the environment.Checklist