agentic-blocks 0.1.8__tar.gz → 0.1.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentic-blocks
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Simple building blocks for agentic AI systems with MCP client and conversation management
5
5
  Author-email: Magnus Bjelkenhed <bjelkenhed@gmail.com>
6
6
  License: MIT
@@ -23,6 +23,7 @@ Requires-Dist: mcp
23
23
  Requires-Dist: requests
24
24
  Requires-Dist: python-dotenv
25
25
  Requires-Dist: openai
26
+ Requires-Dist: langchain-core
26
27
  Provides-Extra: test
27
28
  Requires-Dist: pytest; extra == "test"
28
29
  Provides-Extra: dev
@@ -14,7 +14,7 @@ agentic_blocks = []
14
14
 
15
15
  [project]
16
16
  name = "agentic-blocks"
17
- version = "0.1.8"
17
+ version = "0.1.9"
18
18
  description = "Simple building blocks for agentic AI systems with MCP client and conversation management"
19
19
  readme = "README.md"
20
20
  requires-python = ">=3.11"
@@ -39,6 +39,7 @@ dependencies = [
39
39
  "requests",
40
40
  "python-dotenv",
41
41
  "openai",
42
+ "langchain-core",
42
43
  ]
43
44
 
44
45
  [project.urls]
@@ -205,6 +205,51 @@ class Messages:
205
205
 
206
206
  return False
207
207
 
208
+ def get_pending_tool_calls(self) -> List[Dict[str, Any]]:
209
+ """
210
+ Get pending tool calls that need execution, formatted for MCPClient.call_tool().
211
+
212
+ Returns:
213
+ List of dictionaries with 'tool_name', 'arguments', and 'tool_call_id' keys
214
+ """
215
+ pending_calls = []
216
+
217
+ if not self.messages:
218
+ return pending_calls
219
+
220
+ last_message = self.messages[-1]
221
+
222
+ # Check if the last message is an assistant message with tool calls
223
+ if last_message.get("role") == "assistant" and "tool_calls" in last_message:
224
+ # Get tool call IDs that have responses
225
+ responded_tool_call_ids = set()
226
+ for msg in reversed(self.messages):
227
+ if msg.get("role") == "tool" and msg.get("tool_call_id"):
228
+ responded_tool_call_ids.add(msg.get("tool_call_id"))
229
+
230
+ # Find tool calls that don't have responses
231
+ for tool_call in last_message["tool_calls"]:
232
+ tool_call_id = tool_call.get("id")
233
+ if tool_call_id not in responded_tool_call_ids:
234
+ function_info = tool_call.get("function", {})
235
+ tool_name = function_info.get("name")
236
+ arguments_str = function_info.get("arguments", "{}")
237
+
238
+ # Parse arguments JSON string to dict
239
+ import json
240
+ try:
241
+ arguments = json.loads(arguments_str)
242
+ except json.JSONDecodeError:
243
+ arguments = {}
244
+
245
+ pending_calls.append({
246
+ "tool_name": tool_name,
247
+ "arguments": arguments,
248
+ "tool_call_id": tool_call_id
249
+ })
250
+
251
+ return pending_calls
252
+
208
253
  def __str__(self) -> str:
209
254
  """Return messages in a simple, readable format."""
210
255
  if not self.messages:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentic-blocks
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Simple building blocks for agentic AI systems with MCP client and conversation management
5
5
  Author-email: Magnus Bjelkenhed <bjelkenhed@gmail.com>
6
6
  License: MIT
@@ -23,6 +23,7 @@ Requires-Dist: mcp
23
23
  Requires-Dist: requests
24
24
  Requires-Dist: python-dotenv
25
25
  Requires-Dist: openai
26
+ Requires-Dist: langchain-core
26
27
  Provides-Extra: test
27
28
  Requires-Dist: pytest; extra == "test"
28
29
  Provides-Extra: dev
@@ -2,6 +2,7 @@ mcp
2
2
  requests
3
3
  python-dotenv
4
4
  openai
5
+ langchain-core
5
6
 
6
7
  [dev]
7
8
  pytest
File without changes
File without changes
File without changes