Compare commits

...

56 Commits

Author SHA1 Message Date
Twisha Bansal
b29bb21c75 Merge branch 'main' into processing-best-practice 2026-02-11 13:41:11 +05:30
Twisha Bansal
2d6a2a76d6 Update docs/en/samples/pre_post_processing/_index.md
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-02-09 11:55:18 +05:30
Twisha Bansal
33a98db375 docs: add pre/post processing best practices 2026-02-09 11:50:06 +05:30
Twisha Bansal
22657c9dad fix link checker issue 2026-02-09 11:42:44 +05:30
Twisha Bansal
d829ee7bdf Merge branch 'main' into processing-docs 2026-02-09 11:30:29 +05:30
Twisha Bansal
f598543ea4 remove extra print 2026-02-09 11:10:19 +05:30
Twisha Bansal
4885f6ebfb Merge branch 'main' into processing-docs 2026-02-09 11:07:37 +05:30
Twisha Bansal
77af793066 clarify description for pre and post processing. 2026-02-09 10:29:35 +05:30
Twisha Bansal
fe01519f61 Update docs/en/samples/pre_post_processing/_index.md
Co-authored-by: Averi Kitsch <akitsch@google.com>
2026-02-09 10:28:27 +05:30
Twisha Bansal
4d0a2ce038 Update docs/en/samples/pre_post_processing/python.md
Co-authored-by: Averi Kitsch <akitsch@google.com>
2026-02-09 10:25:10 +05:30
Twisha Bansal
126dbe0d90 Update docs/en/samples/pre_post_processing/python.md
Co-authored-by: Averi Kitsch <akitsch@google.com>
2026-02-09 10:24:42 +05:30
Twisha Bansal
1f79754866 use hyphens everywhere 2026-02-06 17:15:52 +05:30
Twisha Bansal
2ec6dac8bd address comments 2026-02-06 17:10:15 +05:30
Twisha Bansal
fad11de9ff use hugo notice 2026-02-06 16:52:39 +05:30
Twisha Bansal
35d5bd67e8 add license header 2026-02-06 16:40:52 +05:30
Twisha Bansal
eb8a46c175 Update docs/en/samples/pre_post_processing/_index.md
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
2026-02-06 16:39:03 +05:30
Twisha Bansal
c4f924e6f8 Update docs/en/samples/pre_post_processing/_index.md
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
2026-02-06 16:38:33 +05:30
Twisha Bansal
0fcf690d42 Update docs/en/samples/pre_post_processing/_index.md
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
2026-02-06 16:38:23 +05:30
Twisha Bansal
2564058fd9 Update docs/en/samples/pre_post_processing/_index.md
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
2026-02-06 16:37:58 +05:30
Twisha Bansal
2a8d6af4d1 Update docs/en/samples/pre_post_processing/_index.md
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
2026-02-06 16:37:38 +05:30
Twisha Bansal
4dad163803 updated weight 2026-02-06 16:36:25 +05:30
Twisha Bansal
b5c55020c9 Apply suggestion from @Yuan325
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
2026-02-06 16:36:03 +05:30
Twisha Bansal
1dc3417557 Update golden.txt 2026-02-05 21:37:30 +05:30
Twisha Bansal
8ea10c2caf remove init file 2026-02-05 12:28:07 +05:30
Twisha Bansal
632dd10180 remove license header from docs 2026-02-05 12:14:23 +05:30
Twisha Bansal
9771aa47df Update python.md 2026-02-04 14:58:53 +05:30
Twisha Bansal
a212aedd19 more reliable tests 2026-02-03 18:30:33 +05:30
Twisha Bansal
9210e5555c unnecessary file change removal 2026-02-03 18:15:05 +05:30
Twisha Bansal
b43af71793 fix merge issues 2026-02-03 18:13:49 +05:30
Twisha Bansal
da1f463dd1 more reliable agent queries 2026-02-03 18:08:59 +05:30
Twisha Bansal
3265f7e3a6 better tests 2026-02-03 18:08:59 +05:30
Twisha Bansal
336743f747 add more test case + remove flaky test 2026-02-03 18:08:59 +05:30
Twisha Bansal
911069ae8d Fix tests 2026-02-03 18:08:58 +05:30
Twisha Bansal
cee59d52c3 update requirements file 2026-02-03 18:08:58 +05:30
Twisha Bansal
9517daba09 license fix 2026-02-03 18:08:57 +05:30
Twisha Bansal
3c61ee0597 add sample tests 2026-02-03 18:08:09 +05:30
Twisha Bansal
19271eb9ee docs: clarify that pre/post processing is an orchestration feature
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.
2026-02-03 18:08:09 +05:30
Twisha Bansal
3a150c77ca Highlight tool level processing 2026-02-03 18:08:09 +05:30
Twisha Bansal
ca6f31a192 fix import 2026-02-03 18:08:09 +05:30
Twisha Bansal
d7faf7700f logic fix 2026-02-03 18:08:09 +05:30
Twisha Bansal
37a60ea2a6 Update docs/en/samples/pre_post_processing/python/langchain/agent.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-02-03 18:08:09 +05:30
Twisha Bansal
8de16976ae license header 2026-02-03 18:08:08 +05:30
Twisha Bansal
49cb2f39f7 lint 2026-02-03 18:08:08 +05:30
Twisha Bansal
f169874e53 gemini code review 2026-02-03 18:08:08 +05:30
Twisha Bansal
db8c3a3c77 remove not needed files 2026-02-03 18:08:08 +05:30
Twisha Bansal
8b33b0c67f docs: add pre/post processing docs for langchain python 2026-02-03 18:08:08 +05:30
Twisha Bansal
35fa73516b rename file 2026-02-03 15:45:03 +05:30
Twisha Bansal
66df3bfd21 move file around fix 2026-02-03 15:40:49 +05:30
Twisha Bansal
73e0edc3cd move files around 2026-02-03 15:36:56 +05:30
Twisha Bansal
3f32a9aab6 fix paths 2026-02-03 15:29:18 +05:30
Twisha Bansal
28006fc9b2 move files around 2026-02-03 15:27:43 +05:30
Twisha Bansal
56c69131b4 Update run_tests.sh 2026-02-03 15:09:07 +05:30
Twisha Bansal
ad4a509340 Apply suggestion from @gemini-code-assist[bot]
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-02-03 14:16:47 +05:30
Twisha Bansal
d39acac96c Apply suggestion from @gemini-code-assist[bot]
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-02-03 14:16:36 +05:30
Twisha Bansal
6df2ad28a9 Apply suggestion from @gemini-code-assist[bot]
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-02-03 14:15:54 +05:30
Twisha Bansal
8416378613 refactor: consolidate quickstart tests into universal runner 2026-02-03 14:11:54 +05:30
2 changed files with 28 additions and 0 deletions

View File

@@ -50,5 +50,30 @@ It is helpful to understand how tool-level processing differs from other scopes:
- **Model Level**: Intercepts individual calls to the LLM (prompts and responses). Unlike tool-level, this applies globally to all text sent/received, making it better for global PII redaction or token tracking. - **Model Level**: Intercepts individual calls to the LLM (prompts and responses). Unlike tool-level, this applies globally to all text sent/received, making it better for global PII redaction or token tracking.
- **Agent Level**: Wraps the high-level execution loop (e.g., a "turn" in the conversation). Unlike tool-level, this envelopes the entire turn (user input to final response), making it suitable for session management or end-to-end auditing. - **Agent Level**: Wraps the high-level execution loop (e.g., a "turn" in the conversation). Unlike tool-level, this envelopes the entire turn (user input to final response), making it suitable for session management or end-to-end auditing.
## Best Practices
### Security & Guardrails
- **Principle of Least Privilege**: Ensure that tools run with the minimum necessary permissions. Middleware is an excellent place to enforce "read-only" modes or verify user identity before executing sensitive actions.
- **Input Sanitization**: Actively strip potential PII (like credit card numbers or raw emails) from tool arguments before logging them.
- **Prompt Injection Defense**: Use pre-processing hooks to scan user inputs for known jailbreak patterns or malicious directives before they reach the model or tools.
### Observability & Debugging
- **Structured Logging**: Instead of simple print statements, use structured JSON logging with correlation IDs. This allows you to trace a single user request through multiple agent turns and tool calls.
- **Logging for Testability**: LLM responses are non-deterministic and may summarize away key details.
- **Pattern**: Add explicit logging markers in your post-processing middleware (e.g., `logger.info("ACTION_SUCCESS: <id>")`).
- **Benefit**: Your integration tests can grep logs for these stable markers to verify tool success, rather than painfully parsing variable natural language responses.
### Performance & Cost Optimization
- **Token Economy**: Tools often return verbose JSON. Use post-processing to strip unnecessary fields or summarize large datasets *before* returning the result to the LLM's context window. This saves tokens and reduces latency.
- **Caching**: For read-heavy tools (like "search_knowledge_base"), implement caching middleware to return previous results for identical queries, saving both time and API costs.
### Error Handling
- **Graceful Degradation**: If a tool fails (e.g., API timeout), catch the exception in middleware and return a structured error message to the LLM (e.g., `Error: Database timeout, please try again`).
- **Self-Correction**: Well-formatted error messages often allow the LLM to understand *why* a call failed and retry it with corrected parameters automatically.
## Samples ## Samples

View File

@@ -0,0 +1,3 @@
AI:
Loyalty Points
POLICY CHECK: Intercepting 'update-hotel'