MCPcopy Index your code
hub / github.com/google/adk-python / DebugLoggingPlugin

Class DebugLoggingPlugin

src/google/adk/plugins/debug_logging_plugin.py:67–572  ·  view source on GitHub ↗

A plugin that captures complete debug information to a file. This plugin records detailed interaction data including: - LLM requests (model, system instruction, contents, tools) - LLM responses (content, usage metadata, errors) - Function calls with arguments - Function responses with res

Source from the content-addressed store, hash-verified

65
66
67class DebugLoggingPlugin(BasePlugin):
68 """A plugin that captures complete debug information to a file.
69
70 This plugin records detailed interaction data including:
71 - LLM requests (model, system instruction, contents, tools)
72 - LLM responses (content, usage metadata, errors)
73 - Function calls with arguments
74 - Function responses with results
75 - Events yielded from the runner
76 - Session state at the end of each invocation
77
78 The output is written as YAML format for human readability. Each invocation
79 is appended to the file as a separate YAML document (separated by ---).
80 This format is easy to read and can be shared for debugging purposes.
81
82 Example:
83 >>> debug_plugin = DebugLoggingPlugin(output_path="/tmp/adk_debug.yaml")
84 >>> runner = Runner(
85 ... agent=my_agent,
86 ... plugins=[debug_plugin],
87 ... )
88
89 Attributes:
90 output_path: Path to the output file. Defaults to "adk_debug.yaml".
91 include_session_state: Whether to include session state in the output.
92 include_system_instruction: Whether to include system instructions.
93 """
94
95 def __init__(
96 self,
97 *,
98 name: str = "debug_logging_plugin",
99 output_path: str = "adk_debug.yaml",
100 include_session_state: bool = True,
101 include_system_instruction: bool = True,
102 ):
103 """Initialize the debug logging plugin.
104
105 Args:
106 name: The name of the plugin instance.
107 output_path: Path to the output file. Defaults to "adk_debug.yaml".
108 include_session_state: Whether to include session state snapshot.
109 include_system_instruction: Whether to include full system instructions.
110 """
111 super().__init__(name)
112 self._output_path = Path(output_path)
113 self._include_session_state = include_session_state
114 self._include_system_instruction = include_system_instruction
115 self._invocation_states: dict[str, _InvocationDebugState] = {}
116
117 def _get_timestamp(self) -> str:
118 """Get current timestamp in ISO format."""
119 return datetime.now().isoformat()
120
121 def _serialize_content(
122 self, content: types.Content | None
123 ) -> dict[str, Any] | None:
124 """Serialize Content to a dictionary."""

Calls

no outgoing calls