docs: add pre/post processing docs for ADK Python#2534
Conversation
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Explicitly document that these capabilities are typically provided by orchestration frameworks (like LangChain, LangGraph) rather than the Toolbox SDK itself, but that Toolbox tools are designed to leverage them.
There was a problem hiding this comment.
Code Review
This pull request introduces Python examples for pre- and post-processing using ADK, which is a valuable addition. The documentation has been updated and tests have been improved to be data-driven. However, there are a few issues in the new example code and documentation that need attention. Specifically, there are logical errors in the example test cases for both ADK and LangChain, where the conditions to trigger the pre-processing logic are not met. Additionally, a significant portion of the 'Best Practices' documentation has been removed, and it would be beneficial to clarify the reasoning behind this change.
I am having trouble creating individual review comments. Click here to see my feedback.
docs/en/samples/pre_post_processing/python/adk/agent.py (131)
This test case is intended to demonstrate a policy violation for a stay longer than 14 days, which is checked in the enforce_business_rules pre-processing callback. However, this callback only triggers for the update-hotel tool. The user input 'Book a hotel...' will likely call the book-hotel tool instead. To correctly test the pre-processing logic, the user input should be phrased as an update.
"Update my booking for hotel 5 with checkin date 2025-01-18 and checkout date 2025-02-10",
docs/en/samples/pre_post_processing/python/langchain/agent.py (97)
This test case is meant to test the pre-processing logic that prevents hotel stays longer than 14 days. However, the checkout date has been changed to '2025-01-20', making the stay only 2 days long. This no longer triggers the policy violation. To correctly demonstrate the pre-processing rule, the checkout date should result in a stay longer than 14 days, for example, by reverting to '2025-02-20'.
user_input = "Update my hotel with id 3 with checkin date 2025-01-18 and checkout date 2025-02-20."
docs/en/samples/pre_post_processing/_index.md (53-79)
This change removes the entire 'Best Practices' section, which contained valuable information on security, observability, performance, and error handling. Was this removal intentional? If this content is being moved to another page, it would be helpful to include a link. Otherwise, please consider restoring this section as it provides important guidance for developers.
docs/en/samples/pre_post_processing/python/adk/agent.py (16)
There's a grammatical error in the system prompt. it's name should be its name.
cancellations. When the user searches for a hotel, mention its name, id,
docs/en/samples/pre_post_processing/python/adk/agent.py (26-28)
There's a typo in the function name. It should be enforce_business_rules. Please also update its usage on line 112.
async def enforce_business_rules(
tool: ToolboxTool, args: Dict[str, Any], tool_context: ToolContext
) -> Optional[Dict[str, Any]]:
|
🧨 Preview deployments removed. |
## Description Created again on accidental deletion of #2433 ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> 0158206
…#2534) ## Description Created again on accidental deletion of googleapis#2433 ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> 0158206
…#2534) ## Description Created again on accidental deletion of googleapis#2433 ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> 0158206
…#2534) ## Description Created again on accidental deletion of googleapis#2433 ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> 0158206
…#2534) ## Description Created again on accidental deletion of googleapis#2433 ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> 0158206
## Description Created again on accidental deletion of googleapis#2433 ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Description
Created again on accidental deletion of #2433
PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
!if this involve a breaking change🛠️ Fixes #<issue_number_goes_here>