Skip to content

Commit a4b8ee9

Browse files
haiyuan-eng-googlecopybara-github
authored andcommitted
feat(plugins): classify error-bearing tool results and extract shared callback helpers
- Introduce `ToolResultClassification` and `ToolResultClassifier` in `google.adk.plugins._callback_helpers`, re-exported from `google.adk.plugins` and `bigquery_agent_analytics_plugin`, so an application can classify tool results that report a failure without raising an exception. - Record, per plugin instance, a weak reference to the `ToolContext` whose failure `on_tool_error_callback` recorded, so `after_tool_callback` does not record the same failure again when a recovery plugin's answer reaches it as the call's result. Two plugins in one runner never consume each other's marker. - Record `ReflectAndRetryToolPlugin` answers and MCP `CallToolResult` results with `isError` set as `TOOL_ERROR` rows in `BigQueryAgentAnalyticsPlugin`. The new `BigQueryLoggerConfig.tool_result_classifier` lets an application classify its own tools' results: an `OK` verdict keeps `TOOL_COMPLETED` where the MCP rule would record a failure, but cannot hide a retry answer. - Record the exception type name as the `TOOL_ERROR` message when a raised error has no message, matching what a `ReflectAndRetryToolPlugin` answer records for it. - Add `TOOLBOX` and `SKILL` tool origin detection, and inspect tool results without running their code, so a hostile or malformed result cannot raise into a callback or leak its content into a log. - Move the model finish and block reason codes and the durable workflow node error check into `_callback_helpers` for the other observability plugins to share. Fixes #7112 Co-authored-by: Haiyuan Cao <haiyuan@google.com> PiperOrigin-RevId: 1001317185
1 parent 18a41a5 commit a4b8ee9

4 files changed

Lines changed: 3686 additions & 23 deletions

File tree

‎src/google/adk/plugins/__init__.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
if TYPE_CHECKING:
2424
from ..tools.model_consult._force_escalation_plugin import ForceEscalationPlugin
2525
from ..tools.model_consult._observability_plugin import ModelConsultObservabilityPlugin
26+
from ._callback_helpers import ToolResultClassification
27+
from ._callback_helpers import ToolResultClassifier
2628
from ._reflect_retry_model_plugin import ReflectAndRetryModelPlugin
2729
from ._tool_call_integrity_plugin import ToolCallIntegrityError
2830
from ._tool_call_integrity_plugin import ToolCallIntegrityPlugin
@@ -41,6 +43,8 @@
4143
"ReflectAndRetryToolPlugin",
4244
"ToolCallIntegrityError",
4345
"ToolCallIntegrityPlugin",
46+
"ToolResultClassification",
47+
"ToolResultClassifier",
4448
]
4549

4650
_LAZY_MEMBERS: dict[str, str] = {
@@ -54,6 +58,8 @@
5458
"ReflectAndRetryToolPlugin": "reflect_retry_tool_plugin",
5559
"ToolCallIntegrityError": "_tool_call_integrity_plugin",
5660
"ToolCallIntegrityPlugin": "_tool_call_integrity_plugin",
61+
"ToolResultClassification": "_callback_helpers",
62+
"ToolResultClassifier": "_callback_helpers",
5763
}
5864

5965

0 commit comments

Comments
 (0)