actions-graph 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,192 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
175
+
176
+
177
+ # VS Code
178
+ .vscode/
179
+
180
+
181
+ # Local agent hook configuration
182
+ /.codex/
183
+ /.claude/settings.local.json
184
+ /AGENTS.md
185
+ /docs/agents/
186
+ /context-graph/CONTEXT-MAP.md
187
+ /context-graph/*/CONTEXT.md
188
+ /context-graph/docs/adr/
189
+ /context-graph/*/docs/adr/
190
+
191
+ # Project specific files
192
+ /enterprise-context/sic-agent/sic-scrapper/output/*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Memgraph
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,263 @@
1
+ Metadata-Version: 2.4
2
+ Name: actions-graph
3
+ Version: 0.1.0
4
+ Summary: Store and track LLM actions, tool calls, and sessions in Memgraph
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: agent-context-graph
13
+ Requires-Dist: memgraph-toolbox
14
+ Provides-Extra: claude-agent
15
+ Requires-Dist: claude-agent-sdk>=0.1.0; extra == 'claude-agent'
16
+ Provides-Extra: test
17
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'test'
18
+ Requires-Dist: pytest>=9.0.3; extra == 'test'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Actions Graph
22
+
23
+ Store and track LLM actions, tool calls, and sessions in Memgraph.
24
+
25
+ Actions Graph provides a graph-based storage system for tracking all LLM interactions, including:
26
+ - **Tool Calls**: Function/tool invocations by the LLM
27
+ - **Tool Results**: Outputs from tool executions
28
+ - **Messages**: User, assistant, and system messages
29
+ - **Structured Outputs**: Validated JSON outputs from the LLM
30
+ - **Subagent Events**: Subagent lifecycle tracking
31
+ - **Sessions**: Conversation session management
32
+
33
+ ## Features
34
+
35
+ - 📊 **Graph-based Storage**: Store actions as nodes with relationships in Memgraph
36
+ - 🔗 **Temporal Sequences**: Track action order with `FOLLOWED_BY` relationships
37
+ - 🌳 **Nested Actions**: Support for parent-child action relationships (e.g., subagents)
38
+ - 🏷️ **Session Management**: Create, track, and query sessions with tags
39
+ - 📈 **Analytics**: Built-in queries for tool usage stats and session summaries
40
+ - 🔌 **Agent Context Graph Integration**: Consume normalized runtime events through `ActionsGraphConnector`
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install actions-graph
46
+ ```
47
+
48
+ For Agent Context Graph integration:
49
+ ```bash
50
+ pip install actions-graph agent-context-graph
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ### Basic Usage
56
+
57
+ ```python
58
+ from actions_graph import ActionsGraph, Session, ToolCall
59
+
60
+ # Initialize the graph
61
+ graph = ActionsGraph()
62
+ graph.setup() # Create indexes and constraints
63
+
64
+ # Create a session
65
+ session = Session(
66
+ session_id="session-123",
67
+ model="claude-sonnet-4-20250514",
68
+ working_directory="/path/to/project",
69
+ )
70
+ graph.create_session(session)
71
+
72
+ # Record a tool call
73
+ tool_call = graph.record_tool_call(
74
+ session_id="session-123",
75
+ tool_name="Read",
76
+ tool_input={"file_path": "/path/to/file.py"},
77
+ tool_use_id="tool-use-001",
78
+ )
79
+
80
+ # Record the result
81
+ tool_result = graph.record_tool_result(
82
+ session_id="session-123",
83
+ tool_use_id="tool-use-001",
84
+ tool_name="Read",
85
+ content="def hello():\n print('Hello, World!')",
86
+ )
87
+
88
+ # Get session summary
89
+ summary = graph.get_session_summary("session-123")
90
+ print(f"Actions: {summary['action_count']}, Tools: {summary['tool_call_count']}")
91
+ ```
92
+
93
+ ### Agent Context Graph Integration
94
+
95
+ ```python
96
+ from actions_graph import ActionsGraph
97
+ from actions_graph.connector import ActionsGraphConnector
98
+ from agent_context_graph import AgentLink
99
+ from agent_context_graph.adapters.claude import ClaudeAdapter
100
+
101
+ graph = ActionsGraph()
102
+ graph.setup()
103
+
104
+ link = AgentLink()
105
+ link.add_connector(ActionsGraphConnector(graph))
106
+
107
+ adapter = ClaudeAdapter(link, session_id="my-session-123")
108
+ hooks = adapter.get_runtime_hooks()
109
+ ```
110
+
111
+ Actions Graph should consume runtime activity through Agent Context Graph when possible. Runtime adapters normalize SDK callbacks and command hooks into the shared Event Protocol; `ActionsGraphConnector` decides which events become session and action nodes.
112
+
113
+ ## Graph Schema
114
+
115
+ ### Nodes
116
+
117
+ - **Session**: LLM conversation sessions
118
+ - Properties: `session_id`, `started_at`, `ended_at`, `status`, `model`, `total_cost_usd`, etc.
119
+
120
+ - **Action**: Individual actions with type-specific labels
121
+ - Labels: `ToolCall`, `ToolResult`, `Message`, `StructuredOutput`, `SubagentEvent`, etc.
122
+ - Properties: `action_id`, `session_id`, `action_type`, `timestamp`, `status`, etc.
123
+
124
+ - **Tool**: Tool definitions
125
+ - Properties: `name`, `is_mcp`, `mcp_server`
126
+
127
+ - **Tag**: Session/action tags
128
+ - Properties: `name`
129
+
130
+ ### Relationships
131
+
132
+ ```
133
+ (:Session)-[:HAS_ACTION]->(:Action)
134
+ (:Action)-[:FOLLOWED_BY]->(:Action)
135
+ (:Action)-[:PARENT_OF]->(:Action)
136
+ (:Session)-[:FORKED_FROM]->(:Session)
137
+ (:Action)-[:USED_TOOL]->(:Tool)
138
+ (:Session)-[:HAS_TAG]->(:Tag)
139
+ ```
140
+
141
+ ## API Reference
142
+
143
+ ### ActionsGraph
144
+
145
+ Main class for interacting with the graph.
146
+
147
+ ```python
148
+ graph = ActionsGraph()
149
+
150
+ # Setup
151
+ graph.setup() # Create indexes
152
+ graph.drop() # Remove indexes
153
+ graph.clear() # Clear all data
154
+
155
+ # Sessions
156
+ graph.create_session(session)
157
+ graph.get_session(session_id)
158
+ graph.end_session(session_id, status=ActionStatus.COMPLETED)
159
+ graph.list_sessions(limit=100, status=None, tag=None)
160
+
161
+ # Actions
162
+ graph.record_action(action)
163
+ graph.record_tool_call(session_id, tool_name, tool_input, ...)
164
+ graph.record_tool_result(session_id, tool_use_id, tool_name, content, ...)
165
+ graph.record_message(session_id, role, content, ...)
166
+ graph.get_action(action_id)
167
+ graph.get_session_actions(session_id, action_type=None, limit=1000)
168
+
169
+ # Analytics
170
+ graph.get_tool_usage_stats(session_id=None)
171
+ graph.get_action_sequence(session_id, include_content=False)
172
+ graph.get_session_summary(session_id)
173
+ ```
174
+
175
+ ### Action Types
176
+
177
+ | Type | Model Class | Description |
178
+ |------|-------------|-------------|
179
+ | `tool_call` | `ToolCall` | Tool/function invocation |
180
+ | `tool_result` | `ToolResult` | Tool execution result |
181
+ | `user_message` | `Message` | User input |
182
+ | `assistant_message` | `Message` | LLM response |
183
+ | `system_message` | `Message` | System messages |
184
+ | `structured_output` | `StructuredOutput` | Validated JSON output |
185
+ | `subagent_start` | `SubagentEvent` | Subagent started |
186
+ | `subagent_stop` | `SubagentEvent` | Subagent completed |
187
+ | `error` | `ErrorEvent` | Error occurred |
188
+ | `permission_request` | `PermissionRequest` | Permission requested |
189
+ | `rate_limit` | `RateLimitEvent` | Rate limit event |
190
+
191
+ ### Agent Context Graph Connector
192
+
193
+ ```python
194
+ from actions_graph.connector import ActionsGraphConnector
195
+
196
+ connector = ActionsGraphConnector(graph)
197
+ link.add_connector(connector)
198
+ ```
199
+
200
+ The connector records:
201
+
202
+ - `SessionStartEvent` and `SessionEndEvent` as session lifecycle data
203
+ - `ToolStartEvent` as `ToolCall` action nodes
204
+ - `ToolEndEvent` as `ToolResult` action nodes
205
+ - `MessageEvent`, `AgentStartEvent`, `AgentEndEvent`, and `ErrorOccurredEvent` as action nodes
206
+
207
+ ### Claude Agent SDK Hooks
208
+
209
+ Direct Claude Agent SDK hooks remain available for standalone use, but Agent Context Graph is the preferred integration path when multiple graph components need the same runtime event stream.
210
+
211
+ For Claude Agent SDK integration:
212
+
213
+ ```python
214
+ from actions_graph.hooks import create_tracking_hooks, ActionTracker
215
+
216
+ # Simple usage
217
+ hooks = create_tracking_hooks(graph, session_id)
218
+
219
+ # Advanced usage with custom tracker
220
+ tracker = ActionTracker(
221
+ graph,
222
+ session_id,
223
+ track_tool_calls=True,
224
+ track_tool_results=True,
225
+ track_messages=True,
226
+ track_subagents=True,
227
+ track_permissions=True,
228
+ track_errors=True,
229
+ )
230
+ ```
231
+
232
+ ## Example Queries
233
+
234
+ ### Find sessions with errors
235
+
236
+ ```python
237
+ sessions = graph.list_sessions(status=ActionStatus.FAILED)
238
+ ```
239
+
240
+ ### Get all tool calls in a session
241
+
242
+ ```python
243
+ from actions_graph import ActionType
244
+
245
+ tool_calls = graph.get_session_actions(
246
+ session_id,
247
+ action_type=ActionType.TOOL_CALL,
248
+ )
249
+ ```
250
+
251
+ ### Custom Cypher queries
252
+
253
+ ```python
254
+ rows = graph._db.query("""
255
+ MATCH (s:Session {session_id: $session_id})-[:HAS_ACTION]->(a:ToolCall)
256
+ RETURN a.tool_name AS tool, count(*) AS count
257
+ ORDER BY count DESC
258
+ """, params={"session_id": "my-session"})
259
+ ```
260
+
261
+ ## License
262
+
263
+ MIT
@@ -0,0 +1,243 @@
1
+ # Actions Graph
2
+
3
+ Store and track LLM actions, tool calls, and sessions in Memgraph.
4
+
5
+ Actions Graph provides a graph-based storage system for tracking all LLM interactions, including:
6
+ - **Tool Calls**: Function/tool invocations by the LLM
7
+ - **Tool Results**: Outputs from tool executions
8
+ - **Messages**: User, assistant, and system messages
9
+ - **Structured Outputs**: Validated JSON outputs from the LLM
10
+ - **Subagent Events**: Subagent lifecycle tracking
11
+ - **Sessions**: Conversation session management
12
+
13
+ ## Features
14
+
15
+ - 📊 **Graph-based Storage**: Store actions as nodes with relationships in Memgraph
16
+ - 🔗 **Temporal Sequences**: Track action order with `FOLLOWED_BY` relationships
17
+ - 🌳 **Nested Actions**: Support for parent-child action relationships (e.g., subagents)
18
+ - 🏷️ **Session Management**: Create, track, and query sessions with tags
19
+ - 📈 **Analytics**: Built-in queries for tool usage stats and session summaries
20
+ - 🔌 **Agent Context Graph Integration**: Consume normalized runtime events through `ActionsGraphConnector`
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install actions-graph
26
+ ```
27
+
28
+ For Agent Context Graph integration:
29
+ ```bash
30
+ pip install actions-graph agent-context-graph
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ### Basic Usage
36
+
37
+ ```python
38
+ from actions_graph import ActionsGraph, Session, ToolCall
39
+
40
+ # Initialize the graph
41
+ graph = ActionsGraph()
42
+ graph.setup() # Create indexes and constraints
43
+
44
+ # Create a session
45
+ session = Session(
46
+ session_id="session-123",
47
+ model="claude-sonnet-4-20250514",
48
+ working_directory="/path/to/project",
49
+ )
50
+ graph.create_session(session)
51
+
52
+ # Record a tool call
53
+ tool_call = graph.record_tool_call(
54
+ session_id="session-123",
55
+ tool_name="Read",
56
+ tool_input={"file_path": "/path/to/file.py"},
57
+ tool_use_id="tool-use-001",
58
+ )
59
+
60
+ # Record the result
61
+ tool_result = graph.record_tool_result(
62
+ session_id="session-123",
63
+ tool_use_id="tool-use-001",
64
+ tool_name="Read",
65
+ content="def hello():\n print('Hello, World!')",
66
+ )
67
+
68
+ # Get session summary
69
+ summary = graph.get_session_summary("session-123")
70
+ print(f"Actions: {summary['action_count']}, Tools: {summary['tool_call_count']}")
71
+ ```
72
+
73
+ ### Agent Context Graph Integration
74
+
75
+ ```python
76
+ from actions_graph import ActionsGraph
77
+ from actions_graph.connector import ActionsGraphConnector
78
+ from agent_context_graph import AgentLink
79
+ from agent_context_graph.adapters.claude import ClaudeAdapter
80
+
81
+ graph = ActionsGraph()
82
+ graph.setup()
83
+
84
+ link = AgentLink()
85
+ link.add_connector(ActionsGraphConnector(graph))
86
+
87
+ adapter = ClaudeAdapter(link, session_id="my-session-123")
88
+ hooks = adapter.get_runtime_hooks()
89
+ ```
90
+
91
+ Actions Graph should consume runtime activity through Agent Context Graph when possible. Runtime adapters normalize SDK callbacks and command hooks into the shared Event Protocol; `ActionsGraphConnector` decides which events become session and action nodes.
92
+
93
+ ## Graph Schema
94
+
95
+ ### Nodes
96
+
97
+ - **Session**: LLM conversation sessions
98
+ - Properties: `session_id`, `started_at`, `ended_at`, `status`, `model`, `total_cost_usd`, etc.
99
+
100
+ - **Action**: Individual actions with type-specific labels
101
+ - Labels: `ToolCall`, `ToolResult`, `Message`, `StructuredOutput`, `SubagentEvent`, etc.
102
+ - Properties: `action_id`, `session_id`, `action_type`, `timestamp`, `status`, etc.
103
+
104
+ - **Tool**: Tool definitions
105
+ - Properties: `name`, `is_mcp`, `mcp_server`
106
+
107
+ - **Tag**: Session/action tags
108
+ - Properties: `name`
109
+
110
+ ### Relationships
111
+
112
+ ```
113
+ (:Session)-[:HAS_ACTION]->(:Action)
114
+ (:Action)-[:FOLLOWED_BY]->(:Action)
115
+ (:Action)-[:PARENT_OF]->(:Action)
116
+ (:Session)-[:FORKED_FROM]->(:Session)
117
+ (:Action)-[:USED_TOOL]->(:Tool)
118
+ (:Session)-[:HAS_TAG]->(:Tag)
119
+ ```
120
+
121
+ ## API Reference
122
+
123
+ ### ActionsGraph
124
+
125
+ Main class for interacting with the graph.
126
+
127
+ ```python
128
+ graph = ActionsGraph()
129
+
130
+ # Setup
131
+ graph.setup() # Create indexes
132
+ graph.drop() # Remove indexes
133
+ graph.clear() # Clear all data
134
+
135
+ # Sessions
136
+ graph.create_session(session)
137
+ graph.get_session(session_id)
138
+ graph.end_session(session_id, status=ActionStatus.COMPLETED)
139
+ graph.list_sessions(limit=100, status=None, tag=None)
140
+
141
+ # Actions
142
+ graph.record_action(action)
143
+ graph.record_tool_call(session_id, tool_name, tool_input, ...)
144
+ graph.record_tool_result(session_id, tool_use_id, tool_name, content, ...)
145
+ graph.record_message(session_id, role, content, ...)
146
+ graph.get_action(action_id)
147
+ graph.get_session_actions(session_id, action_type=None, limit=1000)
148
+
149
+ # Analytics
150
+ graph.get_tool_usage_stats(session_id=None)
151
+ graph.get_action_sequence(session_id, include_content=False)
152
+ graph.get_session_summary(session_id)
153
+ ```
154
+
155
+ ### Action Types
156
+
157
+ | Type | Model Class | Description |
158
+ |------|-------------|-------------|
159
+ | `tool_call` | `ToolCall` | Tool/function invocation |
160
+ | `tool_result` | `ToolResult` | Tool execution result |
161
+ | `user_message` | `Message` | User input |
162
+ | `assistant_message` | `Message` | LLM response |
163
+ | `system_message` | `Message` | System messages |
164
+ | `structured_output` | `StructuredOutput` | Validated JSON output |
165
+ | `subagent_start` | `SubagentEvent` | Subagent started |
166
+ | `subagent_stop` | `SubagentEvent` | Subagent completed |
167
+ | `error` | `ErrorEvent` | Error occurred |
168
+ | `permission_request` | `PermissionRequest` | Permission requested |
169
+ | `rate_limit` | `RateLimitEvent` | Rate limit event |
170
+
171
+ ### Agent Context Graph Connector
172
+
173
+ ```python
174
+ from actions_graph.connector import ActionsGraphConnector
175
+
176
+ connector = ActionsGraphConnector(graph)
177
+ link.add_connector(connector)
178
+ ```
179
+
180
+ The connector records:
181
+
182
+ - `SessionStartEvent` and `SessionEndEvent` as session lifecycle data
183
+ - `ToolStartEvent` as `ToolCall` action nodes
184
+ - `ToolEndEvent` as `ToolResult` action nodes
185
+ - `MessageEvent`, `AgentStartEvent`, `AgentEndEvent`, and `ErrorOccurredEvent` as action nodes
186
+
187
+ ### Claude Agent SDK Hooks
188
+
189
+ Direct Claude Agent SDK hooks remain available for standalone use, but Agent Context Graph is the preferred integration path when multiple graph components need the same runtime event stream.
190
+
191
+ For Claude Agent SDK integration:
192
+
193
+ ```python
194
+ from actions_graph.hooks import create_tracking_hooks, ActionTracker
195
+
196
+ # Simple usage
197
+ hooks = create_tracking_hooks(graph, session_id)
198
+
199
+ # Advanced usage with custom tracker
200
+ tracker = ActionTracker(
201
+ graph,
202
+ session_id,
203
+ track_tool_calls=True,
204
+ track_tool_results=True,
205
+ track_messages=True,
206
+ track_subagents=True,
207
+ track_permissions=True,
208
+ track_errors=True,
209
+ )
210
+ ```
211
+
212
+ ## Example Queries
213
+
214
+ ### Find sessions with errors
215
+
216
+ ```python
217
+ sessions = graph.list_sessions(status=ActionStatus.FAILED)
218
+ ```
219
+
220
+ ### Get all tool calls in a session
221
+
222
+ ```python
223
+ from actions_graph import ActionType
224
+
225
+ tool_calls = graph.get_session_actions(
226
+ session_id,
227
+ action_type=ActionType.TOOL_CALL,
228
+ )
229
+ ```
230
+
231
+ ### Custom Cypher queries
232
+
233
+ ```python
234
+ rows = graph._db.query("""
235
+ MATCH (s:Session {session_id: $session_id})-[:HAS_ACTION]->(a:ToolCall)
236
+ RETURN a.tool_name AS tool, count(*) AS count
237
+ ORDER BY count DESC
238
+ """, params={"session_id": "my-session"})
239
+ ```
240
+
241
+ ## License
242
+
243
+ MIT