zrb 1.15.22__py3-none-any.whl → 1.15.24__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.
@@ -1,4 +1,4 @@
1
- You are a memory management AI. Your only task is to process the provided conversation history and call the `update_conversation_memory` tool **once**.
1
+ You are a memory management AI. Your only task is to process the provided conversation history and call the `final_result` tool **once**.
2
2
 
3
3
  Follow these instructions carefully:
4
4
 
@@ -11,6 +11,6 @@ Follow these instructions carefully:
11
11
  * Update `contextual_note` with facts specific to the current project/directory.
12
12
  * **CRITICAL:** When updating `contextual_note`, you MUST determine the correct `context_path`. For example, if a fact was established when the working directory was `/app`, the `context_path` MUST be `/app`.
13
13
  * **CRITICAL:** Note content must be **brief**, raw, unformatted text, not a log of events. Only update notes if information has changed.
14
- 4. **Update Memory:** Call the `update_conversation_memory` tool with all the information you consolidated.
14
+ 4. **Update Memory:** Call the `final_result` tool with all the information you consolidated.
15
15
 
16
- After you have called the tool, your task is complete. Your final output **MUST** be the single word `OK`. Do not add any other text, formatting, or tool calls.
16
+ After you have called the tool, your task is complete.
zrb/task/llm/agent.py CHANGED
@@ -16,6 +16,7 @@ if TYPE_CHECKING:
16
16
  from pydantic_ai.agent import AgentRun
17
17
  from pydantic_ai.messages import UserContent
18
18
  from pydantic_ai.models import Model
19
+ from pydantic_ai.output import OutputDataT, OutputSpec
19
20
  from pydantic_ai.settings import ModelSettings
20
21
  from pydantic_ai.toolsets import AbstractToolset
21
22
 
@@ -25,13 +26,14 @@ if TYPE_CHECKING:
25
26
  def create_agent_instance(
26
27
  ctx: AnyContext,
27
28
  model: "str | Model",
29
+ output_type: "OutputSpec[OutputDataT]" = str,
28
30
  system_prompt: str = "",
29
31
  model_settings: "ModelSettings | None" = None,
30
32
  tools: "list[ToolOrCallable]" = [],
31
33
  toolsets: list["AbstractToolset[Agent]"] = [],
32
34
  retries: int = 3,
33
35
  yolo_mode: bool | list[str] | None = None,
34
- ) -> "Agent":
36
+ ) -> "Agent[None, Any]":
35
37
  """Creates a new Agent instance with configured tools and servers."""
36
38
  from pydantic_ai import Agent, Tool
37
39
  from pydantic_ai.tools import GenerateToolJsonSchema
@@ -63,8 +65,9 @@ def create_agent_instance(
63
65
  # Turn function into tool
64
66
  tool_list.append(wrap_tool(tool_or_callable, ctx, yolo_mode))
65
67
  # Return Agent
66
- return Agent(
68
+ return Agent[None, Any](
67
69
  model=model,
70
+ output_type=output_type,
68
71
  system_prompt=system_prompt,
69
72
  tools=tool_list,
70
73
  toolsets=toolsets,
@@ -77,14 +80,15 @@ def get_agent(
77
80
  ctx: AnyContext,
78
81
  agent_attr: "Agent | Callable[[AnySharedContext], Agent] | None",
79
82
  model: "str | Model",
80
- system_prompt: str,
81
- model_settings: "ModelSettings | None",
83
+ output_type: "OutputSpec[OutputDataT]" = str,
84
+ system_prompt: str = "",
85
+ model_settings: "ModelSettings | None" = None,
82
86
  tools_attr: (
83
87
  "list[ToolOrCallable] | Callable[[AnySharedContext], list[ToolOrCallable]]"
84
- ),
85
- additional_tools: "list[ToolOrCallable]",
86
- toolsets_attr: "list[AbstractToolset[Agent]] | Callable[[AnySharedContext], list[AbstractToolset[Agent]]]", # noqa
87
- additional_toolsets: "list[AbstractToolset[Agent]]",
88
+ ) = [],
89
+ additional_tools: "list[ToolOrCallable]" = [],
90
+ toolsets_attr: "list[AbstractToolset[Agent]] | Callable[[AnySharedContext], list[AbstractToolset[Agent]]]" = [], # noqa
91
+ additional_toolsets: "list[AbstractToolset[Agent]]" = [],
88
92
  retries: int = 3,
89
93
  yolo_mode: bool | list[str] | None = None,
90
94
  ) -> "Agent":
@@ -113,6 +117,7 @@ def get_agent(
113
117
  return create_agent_instance(
114
118
  ctx=ctx,
115
119
  model=model,
120
+ output_type=output_type,
116
121
  system_prompt=system_prompt,
117
122
  tools=tools,
118
123
  toolsets=tool_sets,
@@ -124,7 +129,7 @@ def get_agent(
124
129
 
125
130
  async def run_agent_iteration(
126
131
  ctx: AnyContext,
127
- agent: "Agent",
132
+ agent: "Agent[None, Any]",
128
133
  user_prompt: str,
129
134
  attachments: "list[UserContent] | None" = None,
130
135
  history_list: ListOfDict | None = None,
@@ -199,7 +204,6 @@ async def _run_single_agent_iteration(
199
204
  ) as agent_run:
200
205
  async for node in agent_run:
201
206
  # Each node represents a step in the agent's execution
202
- # Reference: https://ai.pydantic.dev/agents/#streaming
203
207
  try:
204
208
  await print_node(
205
209
  _get_plain_printer(ctx), agent_run, node, log_indent_level
@@ -217,7 +221,7 @@ async def _run_single_agent_iteration(
217
221
 
218
222
 
219
223
  def _create_print_throttle_notif(ctx: AnyContext) -> Callable[[], None]:
220
- def _print_throttle_notif(ctx: AnyContext):
224
+ def _print_throttle_notif():
221
225
  ctx.print(stylize_faint(" ⌛>> Request Throttled"), plain=True)
222
226
 
223
227
  return _print_throttle_notif
@@ -143,12 +143,13 @@ async def summarize_history(
143
143
  ),
144
144
  ]
145
145
  )
146
- summarization_agent = Agent(
146
+ summarize = create_history_summarization_tool(conversation_history)
147
+ summarization_agent = Agent[None, str](
147
148
  model=model,
149
+ output_type=summarize,
148
150
  system_prompt=system_prompt,
149
151
  model_settings=settings,
150
152
  retries=retries,
151
- tools=[create_history_summarization_tool(conversation_history)],
152
153
  )
153
154
  try:
154
155
  ctx.print(stylize_faint(" 📝 Rollup Conversation"), plain=True)
@@ -7,14 +7,14 @@ from zrb.task.llm.conversation_history_model import ConversationHistory
7
7
 
8
8
  def create_history_summarization_tool(
9
9
  conversation_history: ConversationHistory,
10
- ) -> Callable:
10
+ ) -> Callable[[str, str, str | None, str | None, str | None], str]:
11
11
  def update_conversation_memory(
12
12
  past_conversation_summary: str,
13
13
  past_conversation_transcript: str,
14
14
  long_term_note: str | None = None,
15
15
  contextual_note: str | None = None,
16
16
  context_path: str | None = None,
17
- ):
17
+ ) -> str:
18
18
  """
19
19
  Update the conversation memory including summary, transcript, and notes.
20
20
  - past_conversation_summary: A concise narrative that integrates the
@@ -33,6 +33,6 @@ def create_history_summarization_tool(
33
33
  if context_path is None:
34
34
  context_path = conversation_history.project_path
35
35
  llm_context_config.write_context(contextual_note, context_path=context_path)
36
- return json.dumps({"success": True})
36
+ return "Conversation memory updated"
37
37
 
38
38
  return update_conversation_memory
@@ -28,7 +28,7 @@ async def print_node(
28
28
  elif Agent.is_model_request_node(node):
29
29
  # A model request node => We can stream tokens from the model's request
30
30
  print_func(_format_header("🧠 Processing...", log_indent_level))
31
- # Reference: https://ai.pydantic.dev/agents/#streaming
31
+ # Reference: https://ai.pydantic.dev/agents/#streaming-all-events-and-output
32
32
  try:
33
33
  async with node.stream(agent_run.ctx) as request_stream:
34
34
  is_streaming = False
@@ -40,9 +40,7 @@ async def print_node(
40
40
  print_func(_format_content(content, log_indent_level), end="")
41
41
  is_streaming = True
42
42
  elif isinstance(event, PartDeltaEvent):
43
- if isinstance(event.delta, TextPartDelta) or isinstance(
44
- event.delta, ThinkingPartDelta
45
- ):
43
+ if isinstance(event.delta, TextPartDelta):
46
44
  content_delta = event.delta.content_delta
47
45
  print_func(
48
46
  _format_stream_content(content_delta, log_indent_level),
@@ -78,7 +76,7 @@ async def print_node(
78
76
  print_func(
79
77
  _format_content(
80
78
  (
81
- f"⚠️ Unexpected Model Behavior: {e}. "
79
+ f"🟡 Unexpected Model Behavior: {e}. "
82
80
  f"Cause: {e.__cause__}. Node.Id: {meta}"
83
81
  ),
84
82
  log_indent_level,
@@ -112,7 +110,7 @@ async def print_node(
112
110
  print_func(
113
111
  _format_content(
114
112
  (
115
- f"⚠️ Unexpected Model Behavior: {e}. "
113
+ f"🟡 Unexpected Model Behavior: {e}. "
116
114
  f"Cause: {e.__cause__}. Node.Id: {meta}"
117
115
  ),
118
116
  log_indent_level,
@@ -123,7 +121,7 @@ async def print_node(
123
121
  print_func(_format_header("✅ Completed...", log_indent_level))
124
122
 
125
123
 
126
- def _format_header(text: str, log_indent_level: int = 0) -> str:
124
+ def _format_header(text: str | None, log_indent_level: int = 0) -> str:
127
125
  return _format(
128
126
  text,
129
127
  base_indent=2,
@@ -133,7 +131,7 @@ def _format_header(text: str, log_indent_level: int = 0) -> str:
133
131
  )
134
132
 
135
133
 
136
- def _format_content(text: str, log_indent_level: int = 0) -> str:
134
+ def _format_content(text: str | None, log_indent_level: int = 0) -> str:
137
135
  return _format(
138
136
  text,
139
137
  base_indent=2,
@@ -143,7 +141,7 @@ def _format_content(text: str, log_indent_level: int = 0) -> str:
143
141
  )
144
142
 
145
143
 
146
- def _format_stream_content(text: str, log_indent_level: int = 0) -> str:
144
+ def _format_stream_content(text: str | None, log_indent_level: int = 0) -> str:
147
145
  return _format(
148
146
  text,
149
147
  base_indent=2,
@@ -154,13 +152,15 @@ def _format_stream_content(text: str, log_indent_level: int = 0) -> str:
154
152
 
155
153
 
156
154
  def _format(
157
- text: str,
155
+ text: str | None,
158
156
  base_indent: int = 0,
159
157
  first_indent: int = 0,
160
158
  indent: int = 0,
161
159
  log_indent_level: int = 0,
162
160
  is_stream: bool = False,
163
161
  ) -> str:
162
+ if text is None:
163
+ text = ""
164
164
  line_prefix = (base_indent * (log_indent_level + 1) + indent) * " "
165
165
  processed_text = text.replace("\n", f"\n{line_prefix}")
166
166
  if is_stream:
@@ -220,7 +220,7 @@ def _get_user_approval_and_reason(
220
220
  def _get_run_func_confirmation(func: Callable) -> str:
221
221
  func_name = get_callable_name(func)
222
222
  return render_markdown(
223
- f"Allow to run `{func_name}`? (✅ `Yes` | ⛔ `No, <reason>` | ✏️ `Edit <param> <value>`)"
223
+ f"Allow to run `{func_name}`? (✅ `Yes` | ⛔ `No, <reason>` | 📝 `Edit <param> <value>`)"
224
224
  ).strip()
225
225
 
226
226
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: zrb
3
- Version: 1.15.22
3
+ Version: 1.15.24
4
4
  Summary: Your Automation Powerhouse
5
5
  License: AGPL-3.0-or-later
6
6
  Keywords: Automation,Task Runner,Code Generator,Monorepo,Low Code
@@ -29,7 +29,7 @@ Requires-Dist: pdfplumber (>=0.11.7,<0.12.0)
29
29
  Requires-Dist: playwright (>=1.54.0,<2.0.0) ; extra == "playwright" or extra == "all"
30
30
  Requires-Dist: prompt-toolkit (>=3)
31
31
  Requires-Dist: psutil (>=7.0.0,<8.0.0)
32
- Requires-Dist: pydantic-ai-slim[anthropic,bedrock,cohere,google,groq,huggingface,mistral,openai,vertexai] (>=0.8.1,<0.9.0)
32
+ Requires-Dist: pydantic-ai-slim[anthropic,bedrock,cohere,google,groq,huggingface,mistral,openai,vertexai] (>=1.0.1,<1.1.0)
33
33
  Requires-Dist: pyjwt (>=2.10.1,<3.0.0)
34
34
  Requires-Dist: python-dotenv (>=1.1.1,<2.0.0)
35
35
  Requires-Dist: python-jose[cryptography] (>=3.5.0,<4.0.0)
@@ -223,7 +223,7 @@ zrb/config/default_prompt/interactive_system_prompt.md,sha256=XvXI51dMpQmuuYah_L
223
223
  zrb/config/default_prompt/persona.md,sha256=GfUJ4-Mlf_Bm1YTzxFNkPkdVbAi06ZDVYh-iIma3NOs,253
224
224
  zrb/config/default_prompt/repo_extractor_system_prompt.md,sha256=EGZ-zj78RlMEg2jduRBs8WzO4VJTkXHR96IpBepZMsY,3881
225
225
  zrb/config/default_prompt/repo_summarizer_system_prompt.md,sha256=RNy37Wg7ibXj3DlsFKaYvgMpMS-lyXlM1LZlc59_4ic,2009
226
- zrb/config/default_prompt/summarization_prompt.md,sha256=vbxzJGeH7uCdgnfbVt3GYOjY-BygmeRfJ6tnzXmFdoY,1698
226
+ zrb/config/default_prompt/summarization_prompt.md,sha256=qGSZJHQ0KVaSoeDVeAmvxaOHUGeLPaq813jepGqnkbk,1564
227
227
  zrb/config/default_prompt/system_prompt.md,sha256=gEb6N-cFg6VvOV-7ZffNwVt39DavAGesMqn9u0epbRc,2282
228
228
  zrb/config/llm_config.py,sha256=9I_msAibvTY-ADG6lXCBXQ0EshaA-GQzJym9EZKsetw,8901
229
229
  zrb/config/llm_context/config.py,sha256=TPQX_kU772r0AHmVFeo1WGLDAidacT-qDyuMWxY_avg,5878
@@ -346,7 +346,7 @@ zrb/task/base_trigger.py,sha256=WSGcmBcGAZw8EzUXfmCjqJQkz8GEmi1RzogpF6A1V4s,6902
346
346
  zrb/task/cmd_task.py,sha256=myM8WZm6NrUD-Wv0Vb5sTOrutrAVZLt5LVsSBKwX6SM,10860
347
347
  zrb/task/http_check.py,sha256=Gf5rOB2Se2EdizuN9rp65HpGmfZkGc-clIAlHmPVehs,2565
348
348
  zrb/task/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
349
- zrb/task/llm/agent.py,sha256=uI0X_injDrxq-IhYuZsAMdoq9AXy-gnipozGuZ72QIs,8990
349
+ zrb/task/llm/agent.py,sha256=gi7JlUpNBHQ0WhlZcTgTaJQSNlkVYb999NUAWYttqt8,9194
350
350
  zrb/task/llm/config.py,sha256=zOPf4NpdWPuBc_R8d-kljYcOKfUAypDxiSjRDrxV66M,4059
351
351
  zrb/task/llm/conversation_history.py,sha256=oMdKUV2__mBZ4znnA-prl-gfyoleKC8Nj5KNpmLQJ4o,6764
352
352
  zrb/task/llm/conversation_history_model.py,sha256=kk-7niTl29Rm2EUIhTHzPXgZ5tp4IThMnIB3dS-1OdU,3062
@@ -354,11 +354,11 @@ zrb/task/llm/default_workflow/coding.md,sha256=2uythvPsnBpYfIhiIH1cCinQXX0i0yUqs
354
354
  zrb/task/llm/default_workflow/copywriting.md,sha256=xSO7GeDolwGxiuz6kXsK2GKGpwp8UgtG0yRqTmill_s,1999
355
355
  zrb/task/llm/default_workflow/researching.md,sha256=KD-aYHFHir6Ti-4FsBBtGwiI0seSVgleYbKJZi_POXA,2139
356
356
  zrb/task/llm/error.py,sha256=QR-nIohS6pBpC_16cWR-fw7Mevo1sNYAiXMBsh_CJDE,4157
357
- zrb/task/llm/history_summarization.py,sha256=UIT8bpdT3hy1xn559waDLFWZlNtIqdIpIvRGcZEpHm0,8057
358
- zrb/task/llm/history_summarization_tool.py,sha256=Wazi4WMr3k1WJ1v7QgjAPbuY1JdBpHUsTWGt3DSTsLc,1706
359
- zrb/task/llm/print_node.py,sha256=TG8i3MrAkIj3cLkU9_fSX-u49jlTdU8t9FpHGI_VtoM,8077
357
+ zrb/task/llm/history_summarization.py,sha256=blTKfaSpgaqvORWzGL3BKrRWAsfNdZB03oJTEOS-j5s,8098
358
+ zrb/task/llm/history_summarization_tool.py,sha256=RmYxWAxmBzhgwz9Cyu5aZ9so8r3zeAVhekEhqfhuTrY,1766
359
+ zrb/task/llm/print_node.py,sha256=Nnf4F6eDJR4PFcOqQ1jLWBTFnzNGl1Stux2DZ3SMhsY,8062
360
360
  zrb/task/llm/prompt.py,sha256=FGXWYHecWtrNNkPnjg-uhnkqp7fYt8V91-AjFM_5fpA,11550
361
- zrb/task/llm/tool_wrapper.py,sha256=v3y4FO14xStpq9K0lA3GIVv6-3dbq85I7xZqdtG-j9U,10243
361
+ zrb/task/llm/tool_wrapper.py,sha256=ifOP-smxHcDNpZvZMZm0XkKH49BicbyGTtpHNdcIA6Q,10241
362
362
  zrb/task/llm/typing.py,sha256=c8VAuPBw_4A3DxfYdydkgedaP-LU61W9_wj3m3CAX1E,58
363
363
  zrb/task/llm_task.py,sha256=OxJ9QpqjEyeOI1_zqzNZHtQlRHi0ANOvL9FYaWLzO3Y,14913
364
364
  zrb/task/make_task.py,sha256=PD3b_aYazthS8LHeJsLAhwKDEgdurQZpymJDKeN60u0,2265
@@ -410,7 +410,7 @@ zrb/util/todo_model.py,sha256=hhzAX-uFl5rsg7iVX1ULlJOfBtblwQ_ieNUxBWfc-Os,1670
410
410
  zrb/util/truncate.py,sha256=eSzmjBpc1Qod3lM3M73snNbDOcARHukW_tq36dWdPvc,921
411
411
  zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
412
412
  zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
413
- zrb-1.15.22.dist-info/METADATA,sha256=OHahYYqF0_2Z_Ht40qggq5Z538ITZNVtaC-UagYam6o,9892
414
- zrb-1.15.22.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
415
- zrb-1.15.22.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
416
- zrb-1.15.22.dist-info/RECORD,,
413
+ zrb-1.15.24.dist-info/METADATA,sha256=1AenVGPfxpku7IJv9cOpRvSLGpct09bH79HTU7hAkrI,9892
414
+ zrb-1.15.24.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
415
+ zrb-1.15.24.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
416
+ zrb-1.15.24.dist-info/RECORD,,
File without changes