ragbits-agents 1.4.0.dev202601310254__py3-none-any.whl → 1.4.0.dev202602030301__py3-none-any.whl
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.
- ragbits/agents/_main.py +4 -5
- ragbits/agents/hooks/manager.py +8 -7
- ragbits/agents/hooks/types.py +7 -6
- {ragbits_agents-1.4.0.dev202601310254.dist-info → ragbits_agents-1.4.0.dev202602030301.dist-info}/METADATA +2 -2
- {ragbits_agents-1.4.0.dev202601310254.dist-info → ragbits_agents-1.4.0.dev202602030301.dist-info}/RECORD +6 -6
- {ragbits_agents-1.4.0.dev202601310254.dist-info → ragbits_agents-1.4.0.dev202602030301.dist-info}/WHEEL +0 -0
ragbits/agents/_main.py
CHANGED
|
@@ -1036,12 +1036,11 @@ class Agent(
|
|
|
1036
1036
|
}
|
|
1037
1037
|
|
|
1038
1038
|
# Execute POST_TOOL hooks with chaining
|
|
1039
|
-
|
|
1039
|
+
post_tool_output = await self.hook_manager.execute_post_tool(
|
|
1040
1040
|
tool_call=tool_call,
|
|
1041
|
-
|
|
1041
|
+
tool_return=tool_return,
|
|
1042
1042
|
error=tool_error,
|
|
1043
1043
|
)
|
|
1044
|
-
tool_output = post_tool_result.output
|
|
1045
1044
|
|
|
1046
1045
|
# Raise error after hooks have been executed
|
|
1047
1046
|
if tool_error:
|
|
@@ -1051,8 +1050,8 @@ class Agent(
|
|
|
1051
1050
|
id=tool_call.id,
|
|
1052
1051
|
name=tool_call.name,
|
|
1053
1052
|
arguments=tool_call.arguments,
|
|
1054
|
-
result=tool_return.value,
|
|
1055
|
-
metadata=tool_return.metadata,
|
|
1053
|
+
result=post_tool_output.tool_return.value if post_tool_output.tool_return else None,
|
|
1054
|
+
metadata=post_tool_output.tool_return.metadata if post_tool_output.tool_return else None,
|
|
1056
1055
|
)
|
|
1057
1056
|
|
|
1058
1057
|
@requires_dependencies(["a2a.types"], "a2a")
|
ragbits/agents/hooks/manager.py
CHANGED
|
@@ -8,11 +8,12 @@ organization, and execution of hooks during lifecycle events.
|
|
|
8
8
|
import hashlib
|
|
9
9
|
import json
|
|
10
10
|
from collections import defaultdict
|
|
11
|
-
from typing import TYPE_CHECKING
|
|
11
|
+
from typing import TYPE_CHECKING
|
|
12
12
|
|
|
13
13
|
from ragbits.agents.confirmation import ConfirmationRequest
|
|
14
14
|
from ragbits.agents.hooks.base import Hook
|
|
15
15
|
from ragbits.agents.hooks.types import EventType, PostToolInput, PostToolOutput, PreToolInput, PreToolOutput
|
|
16
|
+
from ragbits.agents.tool import ToolReturn
|
|
16
17
|
from ragbits.core.llms.base import ToolCall
|
|
17
18
|
|
|
18
19
|
if TYPE_CHECKING:
|
|
@@ -156,7 +157,7 @@ class HookManager:
|
|
|
156
157
|
async def execute_post_tool(
|
|
157
158
|
self,
|
|
158
159
|
tool_call: ToolCall,
|
|
159
|
-
|
|
160
|
+
tool_return: ToolReturn | None,
|
|
160
161
|
error: Exception | None,
|
|
161
162
|
) -> PostToolOutput:
|
|
162
163
|
"""
|
|
@@ -166,7 +167,7 @@ class HookManager:
|
|
|
166
167
|
|
|
167
168
|
Args:
|
|
168
169
|
tool_call: The tool call that was executed
|
|
169
|
-
|
|
170
|
+
tool_return: Object representing the output of the tool (with value passed to the LLM and metadata)
|
|
170
171
|
error: Any error that occurred
|
|
171
172
|
|
|
172
173
|
Returns:
|
|
@@ -175,20 +176,20 @@ class HookManager:
|
|
|
175
176
|
hooks = self.get_hooks(EventType.POST_TOOL, tool_call.name)
|
|
176
177
|
|
|
177
178
|
# Start with original output
|
|
178
|
-
current_output =
|
|
179
|
+
current_output = tool_return
|
|
179
180
|
|
|
180
181
|
for hook in hooks:
|
|
181
182
|
# Create input with current state (chained from previous hook)
|
|
182
183
|
hook_input = PostToolInput(
|
|
183
184
|
tool_call=tool_call,
|
|
184
|
-
|
|
185
|
+
tool_return=current_output,
|
|
185
186
|
error=error,
|
|
186
187
|
)
|
|
187
188
|
|
|
188
189
|
result: PostToolOutput = await hook.execute(hook_input)
|
|
189
190
|
|
|
190
191
|
# Chain output for next hook
|
|
191
|
-
current_output = result.
|
|
192
|
+
current_output = result.tool_return
|
|
192
193
|
|
|
193
194
|
# Return final chained result
|
|
194
|
-
return PostToolOutput(
|
|
195
|
+
return PostToolOutput(tool_return=current_output)
|
ragbits/agents/hooks/types.py
CHANGED
|
@@ -12,6 +12,7 @@ from typing import Any, Literal, TypeAlias
|
|
|
12
12
|
from pydantic import BaseModel, Field, model_validator
|
|
13
13
|
|
|
14
14
|
from ragbits.agents.confirmation import ConfirmationRequest
|
|
15
|
+
from ragbits.agents.tool import ToolReturn
|
|
15
16
|
from ragbits.core.llms.base import ToolCall
|
|
16
17
|
|
|
17
18
|
|
|
@@ -73,13 +74,13 @@ class PostToolInput(HookEventIO):
|
|
|
73
74
|
Attributes:
|
|
74
75
|
event_type: Always EventType.POST_TOOL (unchangeable)
|
|
75
76
|
tool_call: The original tool call
|
|
76
|
-
|
|
77
|
+
tool_return: The result returned by the tool (None if error occurred)
|
|
77
78
|
error: Any error that occurred during execution (None if successful)
|
|
78
79
|
"""
|
|
79
80
|
|
|
80
81
|
event_type: Literal[EventType.POST_TOOL] = Field(default=EventType.POST_TOOL, frozen=True)
|
|
81
82
|
tool_call: ToolCall
|
|
82
|
-
|
|
83
|
+
tool_return: ToolReturn | None = None
|
|
83
84
|
error: Exception | None = None
|
|
84
85
|
|
|
85
86
|
|
|
@@ -120,20 +121,20 @@ class PostToolOutput(HookEventIO):
|
|
|
120
121
|
|
|
121
122
|
Attributes:
|
|
122
123
|
event_type: Always EventType.POST_TOOL (unchangeable)
|
|
123
|
-
|
|
124
|
+
tool_return: Tool output to use (original or modified) - None if the tool execution failed
|
|
124
125
|
|
|
125
126
|
Example:
|
|
126
127
|
```python
|
|
127
128
|
# Pass through unchanged
|
|
128
|
-
return PostToolOutput(
|
|
129
|
+
return PostToolOutput(tool_return=input.tool_return)
|
|
129
130
|
|
|
130
131
|
# Modify output
|
|
131
|
-
return PostToolOutput(
|
|
132
|
+
return PostToolOutput(tool_return=ToolReturn(value={"filtered": data}))
|
|
132
133
|
```
|
|
133
134
|
"""
|
|
134
135
|
|
|
135
136
|
event_type: Literal[EventType.POST_TOOL] = Field(default=EventType.POST_TOOL, frozen=True) # type: ignore[assignment]
|
|
136
|
-
|
|
137
|
+
tool_return: ToolReturn | None
|
|
137
138
|
|
|
138
139
|
|
|
139
140
|
# Type aliases for hook callbacks
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ragbits-agents
|
|
3
|
-
Version: 1.4.0.
|
|
3
|
+
Version: 1.4.0.dev202602030301
|
|
4
4
|
Summary: Building blocks for rapid development of GenAI applications
|
|
5
5
|
Project-URL: Homepage, https://github.com/deepsense-ai/ragbits
|
|
6
6
|
Project-URL: Bug Reports, https://github.com/deepsense-ai/ragbits/issues
|
|
@@ -22,7 +22,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
22
22
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
23
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
24
|
Requires-Python: >=3.10
|
|
25
|
-
Requires-Dist: ragbits-core==1.4.0.
|
|
25
|
+
Requires-Dist: ragbits-core==1.4.0.dev202602030301
|
|
26
26
|
Provides-Extra: a2a
|
|
27
27
|
Requires-Dist: a2a-sdk<1.0.0,>=0.2.9; extra == 'a2a'
|
|
28
28
|
Requires-Dist: fastapi<1.0.0,>=0.115.0; extra == 'a2a'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
ragbits/agents/__init__.py,sha256=rKqDbbppy70HmDN6AtC3eXzyVWTTagkRpLvPjWulGuY,1040
|
|
2
|
-
ragbits/agents/_main.py,sha256=
|
|
2
|
+
ragbits/agents/_main.py,sha256=TF0qvhLQ3LS2AmjQ0xjoXl8W47vnFjV1-aypnCEsYPk,52090
|
|
3
3
|
ragbits/agents/cli.py,sha256=xUS7k8IAn0479n165i4YVFKo4Jx0M2iCpaMILZi9xt8,17649
|
|
4
4
|
ragbits/agents/confirmation.py,sha256=cwdd1feSSobxa7gxBvEZcL9e3tcLdc8CyfvvQwaHF1Y,619
|
|
5
5
|
ragbits/agents/exceptions.py,sha256=TiompKlP1QRD4TZ7hpp52dyZqg0rjoq1t5QUTxFZud8,3552
|
|
@@ -11,8 +11,8 @@ ragbits/agents/a2a/server.py,sha256=4a-cq87OeMoVOjEM_PbwTSHhPTpJv8r_xOVaZAzFIiI,
|
|
|
11
11
|
ragbits/agents/hooks/__init__.py,sha256=xvWTFLkbM6aRLEz-Ypw9MMDOKVIJqhZzN5XE0jEvy3o,1984
|
|
12
12
|
ragbits/agents/hooks/base.py,sha256=Rl_SUgnI-e8Rgrg7TAlxDsdC2nqtRAOIGpIsPV3Y_Sk,3137
|
|
13
13
|
ragbits/agents/hooks/confirmation.py,sha256=ykSRR2sF8lbxG4pJN5amtT6qstnDoTbrYWZaafoSa9Y,1648
|
|
14
|
-
ragbits/agents/hooks/manager.py,sha256=
|
|
15
|
-
ragbits/agents/hooks/types.py,sha256=
|
|
14
|
+
ragbits/agents/hooks/manager.py,sha256=Exj-Q9Hajf61n_08pDVtI3ouTZ8EphNnSIxM5xx-EOI,7047
|
|
15
|
+
ragbits/agents/hooks/types.py,sha256=zQkLhrctjU8adELYb78ikX3Q0kqPp_LNrAvfJqHI7GU,4550
|
|
16
16
|
ragbits/agents/mcp/__init__.py,sha256=7icbSe4FCBMgPADNNoeQBKiLY8J6gIlqFS77gFGr6Ks,405
|
|
17
17
|
ragbits/agents/mcp/server.py,sha256=slob6ns-sbLmG-bQAbwz-23MWsaAENeKhE2eNdoI3Vs,16397
|
|
18
18
|
ragbits/agents/mcp/utils.py,sha256=o_UXS-olS1uRdfZHTRJdG697Xmq3q77twfcHzmyRTY0,1394
|
|
@@ -25,6 +25,6 @@ ragbits/agents/tools/memory.py,sha256=IrRGpZvdylNbn_Z7FFFwun9Rx3OSQimjVynSt3WgUo
|
|
|
25
25
|
ragbits/agents/tools/openai.py,sha256=SpoB6my_T6LwfHjrP7ivQL6H4KvwInVampXq-6nGAHE,4955
|
|
26
26
|
ragbits/agents/tools/todo.py,sha256=R86_Hu0HIl5Ujp8B2ctOo1iSLAHmfrzyu6jnyCLs4uc,18576
|
|
27
27
|
ragbits/agents/tools/types.py,sha256=6yNG7IjG476muiCIcXKRgDJSemCeO2ZgycpXLyfu8jc,441
|
|
28
|
-
ragbits_agents-1.4.0.
|
|
29
|
-
ragbits_agents-1.4.0.
|
|
30
|
-
ragbits_agents-1.4.0.
|
|
28
|
+
ragbits_agents-1.4.0.dev202602030301.dist-info/METADATA,sha256=6yp4rccNkmzSd4B8SM8Rq8TBFoSilNNEAgXqra9EwuE,2273
|
|
29
|
+
ragbits_agents-1.4.0.dev202602030301.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
30
|
+
ragbits_agents-1.4.0.dev202602030301.dist-info/RECORD,,
|
|
File without changes
|