langchain-agentx-python 2.5.3__py3-none-any.whl → 2.5.5__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.
Files changed (27) hide show
  1. langchain_agentx/__init__.py +1 -1
  2. langchain_agentx/loop/stream/loop_driver.py +6 -0
  3. langchain_agentx/tool_runtime/adapter.py +39 -0
  4. langchain_agentx/tool_runtime/execution/engine.py +7 -0
  5. langchain_agentx/tool_runtime/models.py +2 -0
  6. langchain_agentx/tools/edit/escape_normalizer.py +169 -0
  7. langchain_agentx/tools/edit/quote_normalizer.py +11 -7
  8. langchain_agentx/tools/edit/validator.py +15 -3
  9. langchain_agentx/tools/glob/tool.py +21 -7
  10. langchain_agentx/tools/grep/backend.py +7 -0
  11. langchain_agentx/tools/grep/models.py +9 -0
  12. langchain_agentx/tools/grep/prompt.py +2 -0
  13. langchain_agentx/tools/grep/tool.py +161 -6
  14. langchain_agentx/tools/read/limits.py +31 -0
  15. langchain_agentx/tools/read/models.py +9 -0
  16. langchain_agentx/tools/read/prompt.py +2 -1
  17. langchain_agentx/tools/read/read_room.py +295 -0
  18. langchain_agentx/tools/read/read_room_service.py +255 -0
  19. langchain_agentx/tools/read/tool.py +140 -9
  20. langchain_agentx/workflow/base.py +5 -8
  21. langchain_agentx/workflow/execution.py +35 -6
  22. langchain_agentx/workflow/run_session.py +68 -11
  23. {langchain_agentx_python-2.5.3.dist-info → langchain_agentx_python-2.5.5.dist-info}/METADATA +1 -1
  24. {langchain_agentx_python-2.5.3.dist-info → langchain_agentx_python-2.5.5.dist-info}/RECORD +27 -24
  25. {langchain_agentx_python-2.5.3.dist-info → langchain_agentx_python-2.5.5.dist-info}/LICENSE +0 -0
  26. {langchain_agentx_python-2.5.3.dist-info → langchain_agentx_python-2.5.5.dist-info}/WHEEL +0 -0
  27. {langchain_agentx_python-2.5.3.dist-info → langchain_agentx_python-2.5.5.dist-info}/top_level.txt +0 -0
@@ -11,7 +11,7 @@ from langchain_agentx import create_loop_agent
11
11
  ```
12
12
  """
13
13
 
14
- __version__ = "2.5.3"
14
+ __version__ = "2.5.5"
15
15
 
16
16
  from .mcp.call import McpToolCaller
17
17
  from .mcp.client_manager import McpClientManager, McpConnectedClient
@@ -119,6 +119,12 @@ class LoopStreamDriver:
119
119
  finally:
120
120
  unregister_agent_loop(agent_loop)
121
121
  self._log_stream_closeout_summary()
122
+ # 与 closeout 摘要分离:generator 即将退出时打点(Doc-36 C-DRV-1)。
123
+ logger.info(
124
+ "loop_stream_driver_exited: graph_completed=%s raw_events_consumed=%s",
125
+ self.result.graph_completed,
126
+ self.result.raw_events_consumed,
127
+ )
122
128
 
123
129
  async def _stream_single_drain(
124
130
  self,
@@ -60,6 +60,40 @@ from langchain_agentx.observability.replay.store import (
60
60
  from .base import RuntimeTool
61
61
  from .pipeline import ToolExecutorPipeline
62
62
 
63
+ _READ_ROOM_STATE_KEY = "_read_room_service"
64
+ _READ_ROOM_RESOLVE_LOCK = threading.Lock()
65
+
66
+
67
+ def _resolve_read_room_service(
68
+ *,
69
+ state: MutableMapping[str, Any],
70
+ model: Any,
71
+ capabilities: Any | None,
72
+ ) -> Any | None:
73
+ """方案 A:同 turn 共享 ReadRoomService(挂 state);并行建 ctx 时加锁防双装。"""
74
+ import os
75
+
76
+ from langchain_agentx.tools.read.read_room_service import ReadRoomService
77
+
78
+ with _READ_ROOM_RESOLVE_LOCK:
79
+ existing = state.get(_READ_ROOM_STATE_KEY) if isinstance(state, dict) else None
80
+ if isinstance(existing, ReadRoomService):
81
+ return existing
82
+
83
+ registry = (
84
+ getattr(capabilities, "model_profile_registry", None) if capabilities else None
85
+ )
86
+ # 默认开启动态抬升;设 READ_ROOM_ENABLE_RAISE=0 可退回 L0 探针行为
87
+ enable_raise = os.getenv("READ_ROOM_ENABLE_RAISE", "1") != "0"
88
+ svc = ReadRoomService(
89
+ model=model,
90
+ model_profile_registry=registry,
91
+ enable_raise=enable_raise,
92
+ )
93
+ if isinstance(state, dict):
94
+ state[_READ_ROOM_STATE_KEY] = svc
95
+ return svc
96
+
63
97
 
64
98
  def _resolve_tool_call_id(
65
99
  *,
@@ -391,6 +425,11 @@ class LangChainAdapter:
391
425
  thinking_generation_enabled=thinking_generation_enabled,
392
426
  ui_verbose=ui_verbose,
393
427
  ui_show_thinking=ui_show_thinking,
428
+ read_room_service=_resolve_read_room_service(
429
+ state=state,
430
+ model=model,
431
+ capabilities=capabilities,
432
+ ),
394
433
  )
395
434
 
396
435
  def apply_pipeline_side_effects_immediate(
@@ -78,6 +78,10 @@ class RuntimeToolExecutionEngine:
78
78
  state: MutableMapping[str, Any],
79
79
  config: RunnableConfig | None = None,
80
80
  ) -> list[ToolExecutionRecord]:
81
+ from langchain_agentx.tools.read.read_room_service import begin_read_room_turn
82
+
83
+ # 对齐 CC:每 tools turn 换 ReadRoom 账本(WeakMap 换 ToolUseContext)
84
+ begin_read_room_turn(state)
81
85
  records: list[ToolExecutionRecord] = []
82
86
  for batch in batches:
83
87
  records.extend(
@@ -92,6 +96,9 @@ class RuntimeToolExecutionEngine:
92
96
  state: MutableMapping[str, Any],
93
97
  config: RunnableConfig | None = None,
94
98
  ) -> list[ToolExecutionRecord]:
99
+ from langchain_agentx.tools.read.read_room_service import begin_read_room_turn
100
+
101
+ begin_read_room_turn(state)
95
102
  records: list[ToolExecutionRecord] = []
96
103
  for batch in batches:
97
104
  records.extend(
@@ -158,6 +158,8 @@ class ToolExecutionContext:
158
158
  """宿主 verbose 模式(主 Agent thinking 展示策略,供 CLI 投影层读取)。"""
159
159
  ui_show_thinking: bool | None = None
160
160
  """宿主 UI 的显式 thinking 展示意图;仅供展示层消费,不参与 request-side thinking 控制。"""
161
+ read_room_service: Any | None = None
162
+ """可选;本 turn ReadRoomService(方案 A)。同 state 共享 tracker;由 adapter/bind 注入。"""
161
163
 
162
164
  def persist_permission_updates(
163
165
  self,
@@ -0,0 +1,169 @@
1
+ """
2
+ tools/edit/escape_normalizer.py — \\uXXXX 匹配与替换风格还原
3
+
4
+ 职责:
5
+ 对齐 CC FileEditTool/utils.ts(unescape / findEscapedMatch / restoreEscapeStyle /
6
+ findActualString 第 3–4 级)。模型与文件在「原文 vs \\uXXXX」不对称时完成匹配,
7
+ 并按文件侧风格改写 new_string。
8
+
9
+ 链路位置:
10
+ QuoteNormalizer.find_actual_old_string_in_text 第 3–4 级;
11
+ EditStringValidator 命中后 restore_escape_style 写回 data["new_string"]。
12
+
13
+ 当前裁剪:
14
+ 仅 \\uXXXX(四位十六进制);不做 CC 全量模糊匹配;超长/正则失败 → None。
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import re
20
+
21
+ _UNICODE_ESCAPE_RE = re.compile(r"\\u[0-9a-fA-F]{4}")
22
+ _NON_ASCII_RE = re.compile(r"[\u0080-\uffff]")
23
+ _REGEXP_SPECIAL = re.compile(r"[.*+?^${}()|[\]\\]")
24
+
25
+
26
+ def unescape_unicode(s: str) -> str:
27
+ """对齐 CC ``unescapeUnicode``:解码 \\uXXXX,保留已转义的反斜杠对。"""
28
+
29
+ def _repl(m: re.Match[str]) -> str:
30
+ if m.group(1) is not None:
31
+ return m.group(0)
32
+ return chr(int(m.group(2), 16))
33
+
34
+ return re.sub(r"(\\\\)|\\u([0-9a-fA-F]{4})", _repl, s)
35
+
36
+
37
+ def escaped_length(s: str) -> int:
38
+ non_ascii = sum(1 for ch in s if ord(ch) >= 128)
39
+ return len(s) + 5 * non_ascii
40
+
41
+
42
+ def _count_trailing_backslashes(s: str, pos: int) -> int:
43
+ count = 0
44
+ while pos - 1 - count >= 0 and s[pos - 1 - count] == "\\":
45
+ count += 1
46
+ return count
47
+
48
+
49
+ def _escape_regexp_char(ch: str) -> str:
50
+ if _REGEXP_SPECIAL.match(ch):
51
+ return "\\" + ch
52
+ return ch
53
+
54
+
55
+ def find_escaped_match(search: str, file_content: str) -> str | None:
56
+ """模型给原文、文件含 \\uXXXX 时搜索;边界规则对齐 CC ``findEscapedMatch``。"""
57
+ if _count_trailing_backslashes(search, len(search)) % 2 == 1:
58
+ return None
59
+
60
+ non_ascii_offsets: list[int] = [0] if search[:1] == "\\" else []
61
+ unescaped_index = 0
62
+ for ch in search:
63
+ if ord(ch) >= 128:
64
+ non_ascii_offsets.append(unescaped_index)
65
+ unescaped_index += 6
66
+ else:
67
+ unescaped_index += 1
68
+
69
+ pattern_parts: list[str] = []
70
+ for ch in search:
71
+ code = ord(ch)
72
+ if code >= 128:
73
+ pattern_parts.append("\\\\u")
74
+ for hex_digit in f"{code:04x}":
75
+ if hex_digit >= "a":
76
+ pattern_parts.append(f"[{hex_digit}{hex_digit.upper()}]")
77
+ else:
78
+ pattern_parts.append(hex_digit)
79
+ else:
80
+ pattern_parts.append(_escape_regexp_char(ch))
81
+ pattern = "".join(pattern_parts)
82
+
83
+ try:
84
+ re_obj = re.compile(pattern)
85
+ except re.error:
86
+ return None
87
+
88
+ for m in re_obj.finditer(file_content):
89
+ at = m.start()
90
+ if all(
91
+ _count_trailing_backslashes(file_content, at + offset) % 2 == 0
92
+ for offset in non_ascii_offsets
93
+ ):
94
+ matched = m.group(0)
95
+ if file_content.find(matched) == at:
96
+ return matched
97
+ return None
98
+ return None
99
+
100
+
101
+ def restore_escape_style(
102
+ old_string: str, actual_old_string: str, new_string: str
103
+ ) -> str:
104
+ """对齐 CC ``restoreEscapeStyle``:按文件侧 \\u / 原文风格改写 new_string。"""
105
+ if old_string == actual_old_string:
106
+ return new_string
107
+
108
+ if (
109
+ _NON_ASCII_RE.search(old_string)
110
+ and escaped_length(old_string) == len(actual_old_string)
111
+ and find_escaped_match(old_string, actual_old_string) is not None
112
+ ):
113
+ char_to_escape: dict[int, str] = {}
114
+ lowercase_hex = 0
115
+ uppercase_hex = 0
116
+ file_index = 0
117
+ for ch in old_string:
118
+ code = ord(ch)
119
+ if code >= 128:
120
+ hex_part = actual_old_string[file_index + 2 : file_index + 6]
121
+ char_to_escape[code] = hex_part
122
+ for c in hex_part:
123
+ if "a" <= c <= "f":
124
+ lowercase_hex += 1
125
+ elif "A" <= c <= "F":
126
+ uppercase_hex += 1
127
+ file_index += 6
128
+ else:
129
+ file_index += 1
130
+
131
+ def _esc(m: re.Match[str]) -> str:
132
+ code = ord(m.group(0))
133
+ mapped = char_to_escape.get(code)
134
+ if mapped is not None:
135
+ return "\\u" + mapped
136
+ hx = f"{code:04x}"
137
+ if uppercase_hex > lowercase_hex:
138
+ hx = hx.upper()
139
+ return "\\u" + hx
140
+
141
+ return _NON_ASCII_RE.sub(_esc, new_string)
142
+
143
+ if (
144
+ _UNICODE_ESCAPE_RE.search(old_string)
145
+ and unescape_unicode(old_string) == actual_old_string
146
+ ):
147
+ return unescape_unicode(new_string)
148
+
149
+ return new_string
150
+
151
+
152
+ class EscapeNormalizer:
153
+ """\\uXXXX 双向匹配与 restore;供 QuoteNormalizer / Validator 组合。"""
154
+
155
+ def find_via_escape(self, file_text: str, old_string: str) -> str | None:
156
+ if _UNICODE_ESCAPE_RE.search(old_string):
157
+ decoded = unescape_unicode(old_string)
158
+ if decoded != old_string and decoded in file_text:
159
+ return decoded
160
+ if _NON_ASCII_RE.search(old_string):
161
+ if escaped_length(old_string) > len(file_text) or "\\u" not in file_text:
162
+ return None
163
+ return find_escaped_match(old_string, file_text)
164
+ return None
165
+
166
+ def restore(
167
+ self, old_string: str, actual_old_string: str, new_string: str
168
+ ) -> str:
169
+ return restore_escape_style(old_string, actual_old_string, new_string)
@@ -2,21 +2,26 @@
2
2
  tools/edit/quote_normalizer.py — QuoteNormalizer
3
3
 
4
4
  职责:
5
- 弯/直引号等价比较;在字面量不匹配时扫描等长窗口,返回**文件中实际子串**
6
- (edit-runtime-tool-v2 §0;CC ``findActualString`` 简化版)。
5
+ 弯/直引号等价比较;在字面量不匹配时扫描等长窗口,返回**文件中实际子串**;
6
+ 第 3–4 级委托 EscapeNormalizer(\\uXXXX),对齐 CC ``findActualString``。
7
7
 
8
8
  链路位置:
9
9
  ``EditStringValidator.validate``;可注入单测替身。
10
10
 
11
11
  当前裁剪范围:
12
- 仅 U+201C/U+201D/U+2018/U+2019 与 ASCII 引号;不等长匹配留待后续版本。
12
+ 引号仅 U+201C/U+201D/U+2018/U+2019;转义仅 \\uXXXX(见 escape_normalizer)。
13
13
  """
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
+ from .escape_normalizer import EscapeNormalizer
18
+
17
19
 
18
20
  class QuoteNormalizer:
19
- """引号规范化与 ``old_string`` 在正文中的实际定位。"""
21
+ """引号规范化与 ``old_string`` 在正文中的实际定位(四级)。"""
22
+
23
+ def __init__(self, escape_normalizer: EscapeNormalizer | None = None) -> None:
24
+ self._escape = escape_normalizer or EscapeNormalizer()
20
25
 
21
26
  def normalize_for_match(self, s: str) -> str:
22
27
  """比较用规范化:弯引号映射为 ASCII,其余字符不变。"""
@@ -32,8 +37,7 @@ class QuoteNormalizer:
32
37
 
33
38
  def find_actual_old_string_in_text(self, file_text: str, old_string: str) -> str | None:
34
39
  """
35
- 若 ``old_string`` 已字面出现于 ``file_text``,原样返回;
36
- 否则扫描与 ``len(old_string)`` 等长的窗口,规范化相等则返回**窗口原文**。
40
+ 1) 精确 2) 等长引号窗 3) \\u 解码 4) \\u 转义搜索(后两级可不等长)。
37
41
  """
38
42
  if old_string in file_text:
39
43
  return old_string
@@ -45,4 +49,4 @@ class QuoteNormalizer:
45
49
  cand = file_text[i : i + n]
46
50
  if self.normalize_for_match(cand) == norm_old:
47
51
  return cand
48
- return None
52
+ return self._escape.find_via_escape(file_text, old_string)
@@ -23,6 +23,7 @@ from langchain_agentx.tools.shared.read_state_guard import MustReadGuard
23
23
  from langchain_agentx.utils.unc_path import is_unc_path_skip_local_stat
24
24
 
25
25
  from .backend import apply_edit_to_content
26
+ from .escape_normalizer import EscapeNormalizer
26
27
  from .limits import get_edit_limits
27
28
  from .models import EditToolInput
28
29
  from .quote_normalizer import QuoteNormalizer
@@ -39,6 +40,7 @@ class EditStringValidator:
39
40
  staleness_checker: Any | None = None,
40
41
  must_read_guard: MustReadGuard | None = None,
41
42
  quote_normalizer: QuoteNormalizer | None = None,
43
+ escape_normalizer: EscapeNormalizer | None = None,
42
44
  settings_validator: SettingsValidator | None = None,
43
45
  ) -> None:
44
46
  self._state_bridge = state_bridge
@@ -47,7 +49,10 @@ class EditStringValidator:
47
49
  state_bridge,
48
50
  tool_label="EditRuntimeTool",
49
51
  )
50
- self._quote_normalizer = quote_normalizer or QuoteNormalizer()
52
+ self._escape_normalizer = escape_normalizer or EscapeNormalizer()
53
+ self._quote_normalizer = quote_normalizer or QuoteNormalizer(
54
+ escape_normalizer=self._escape_normalizer
55
+ )
51
56
  self._settings_validator = settings_validator or SettingsValidator()
52
57
 
53
58
  def validate(
@@ -123,16 +128,23 @@ class EditStringValidator:
123
128
  except OSError as exc:
124
129
  return ValidationResult(ok=False, message=str(exc))
125
130
 
131
+ model_old = inp.old_string
126
132
  resolved = self._quote_normalizer.find_actual_old_string_in_text(
127
- text, inp.old_string
133
+ text, model_old
128
134
  )
129
135
  if resolved is None:
130
136
  return ValidationResult(
131
137
  ok=False,
132
138
  message="old_string not found in file.",
133
139
  )
134
- if resolved != inp.old_string:
140
+ if resolved != model_old:
135
141
  data["old_string"] = resolved
142
+ restored_new = self._escape_normalizer.restore(
143
+ model_old, resolved, inp.new_string
144
+ )
145
+ if restored_new != inp.new_string:
146
+ data["new_string"] = restored_new
147
+ if resolved != model_old or restored_new != inp.new_string:
136
148
  try:
137
149
  inp = EditToolInput.model_validate(data)
138
150
  except Exception as exc:
@@ -79,6 +79,16 @@ def _directory_listing_glob_hint(pattern: str) -> str | None:
79
79
  )
80
80
 
81
81
 
82
+ def _glob_truncation_note(num_files: int, total_matches: int) -> str:
83
+ """对齐 CC ``globTruncationNote`` exact 档(countIsComplete=true;本仓无 timedOut)。"""
84
+ remaining = total_matches - num_files
85
+ return (
86
+ f"Showing {num_files} of {total_matches} matching files; "
87
+ f"{remaining} more are not listed. "
88
+ "Narrow the pattern or path to see the rest."
89
+ )
90
+
91
+
82
92
  class GlobRuntimeTool(RuntimeTool):
83
93
  name: str = TOOL_NAME
84
94
  description: str = DESCRIPTION
@@ -348,16 +358,14 @@ class GlobRuntimeTool(RuntimeTool):
348
358
  payload_lines = list(result.filenames)
349
359
  hints: list[ToolHint] | None = None
350
360
  if result.truncated:
361
+ note = _glob_truncation_note(result.num_files, result.total_matches)
351
362
  summary += (
352
- f" (results truncated at {self.max_results}"
363
+ f" (Showing {result.num_files} of {result.total_matches}"
353
364
  + (f", offset {result.offset}" if result.offset else "")
354
365
  + ")"
355
366
  )
356
- hint_msg = (
357
- "Results are truncated. Consider using a more specific path or pattern."
358
- )
359
- payload_lines.append(f"({hint_msg})")
360
- hints = [ToolHint(message=hint_msg)]
367
+ payload_lines.append(f"({note})")
368
+ hints = [ToolHint(message=note)]
361
369
 
362
370
  return ToolResultEnvelope(
363
371
  status="ok",
@@ -382,14 +390,20 @@ class GlobRuntimeTool(RuntimeTool):
382
390
  _ = data, ctx
383
391
  if not isinstance(result, GlobToolOutput):
384
392
  return None
385
- return {
393
+ out: dict[str, Any] = {
386
394
  "pattern": result.pattern,
387
395
  "duration_ms": result.duration_ms,
388
396
  "num_files": result.num_files,
389
397
  "truncated": result.truncated,
398
+ "total_matches": result.total_matches,
390
399
  # 对齐 CC:提供完整文件列表(CC UI 可展示所有匹配文件)
391
400
  "filenames": result.filenames,
392
401
  }
402
+ if result.truncated:
403
+ out["truncation_note"] = _glob_truncation_note(
404
+ result.num_files, result.total_matches
405
+ )
406
+ return out
393
407
 
394
408
  def _to_relative(self, path: str) -> str:
395
409
  return self._paths.to_relative_under(path, self._workspace_root_hint)
@@ -189,6 +189,7 @@ class RipgrepBackend:
189
189
  case_insensitive: bool,
190
190
  multiline: bool,
191
191
  plugin_glob_exclusions: list[str] | None = None,
192
+ only_matching: bool = False,
192
193
  ) -> list[str]:
193
194
  args: list[str] = ["--hidden"]
194
195
  for d in self.VCS_EXCLUDE_DIRS:
@@ -204,6 +205,8 @@ class RipgrepBackend:
204
205
  args.append("-c")
205
206
  if output_mode == GrepOutputMode.content and show_line_numbers:
206
207
  args.append("-n")
208
+ if only_matching and output_mode == GrepOutputMode.content:
209
+ args.append("-o")
207
210
  if output_mode == GrepOutputMode.content:
208
211
  if context is not None:
209
212
  args.extend(["-C", str(context)])
@@ -254,6 +257,7 @@ class RipgrepBackend:
254
257
  show_line_numbers: bool = True,
255
258
  case_insensitive: bool = False,
256
259
  multiline: bool = False,
260
+ only_matching: bool = False,
257
261
  plugin_glob_exclusions: list[str] | None = None,
258
262
  cancel_event: threading.Event | None = None,
259
263
  ) -> list[str]:
@@ -270,6 +274,7 @@ class RipgrepBackend:
270
274
  case_insensitive=case_insensitive,
271
275
  multiline=multiline,
272
276
  plugin_glob_exclusions=plugin_glob_exclusions,
277
+ only_matching=only_matching,
273
278
  )
274
279
  return self._execute(args, search_path, cancel_event=cancel_event)
275
280
 
@@ -320,6 +325,7 @@ class RipgrepBackend:
320
325
  show_line_numbers: bool = True,
321
326
  case_insensitive: bool = False,
322
327
  multiline: bool = False,
328
+ only_matching: bool = False,
323
329
  max_lines: int,
324
330
  plugin_glob_exclusions: list[str] | None = None,
325
331
  cancel_event: threading.Event | None = None,
@@ -341,6 +347,7 @@ class RipgrepBackend:
341
347
  case_insensitive=case_insensitive,
342
348
  multiline=multiline,
343
349
  plugin_glob_exclusions=plugin_glob_exclusions,
350
+ only_matching=only_matching,
344
351
  )
345
352
  cmd = [self._rg_path, *args, os.path.realpath(search_path)]
346
353
  search_cwd = resolve_ripgrep_subprocess_cwd(search_path)
@@ -79,6 +79,14 @@ class GrepToolInput(BaseModel):
79
79
  description="Case insensitive search (rg -i).",
80
80
  validation_alias=AliasChoices("case_insensitive", "-i"),
81
81
  )
82
+ only_matching: bool = Field(
83
+ default=False,
84
+ description=(
85
+ "Print only the matched (non-empty) parts of each matching line "
86
+ "(rg -o / --only-matching). Requires output_mode: content."
87
+ ),
88
+ validation_alias=AliasChoices("only_matching", "-o"),
89
+ )
82
90
  file_type: str | None = Field(
83
91
  default=None,
84
92
  description='File type for rg --type (e.g. "js", "py", "rust").',
@@ -123,5 +131,6 @@ class GrepToolOutput(BaseModel):
123
131
  truncated: bool = False
124
132
  applied_limit: int | None = None
125
133
  applied_offset: int | None = None
134
+ total_before_page: int = 0
126
135
 
127
136
  duration_ms: float = 0.0
@@ -25,6 +25,8 @@ def get_prompt() -> str:
25
25
  "(use `interface\\{\\}` to find `interface{}` in Go)\n"
26
26
  "- Multiline matching: By default patterns match within single lines only. "
27
27
  "For cross-line patterns like `struct \\{[\\s\\S]*?field\\`, use multiline: true\n"
28
+ "- only_matching / -o: in content mode, print only the matched parts of each line "
29
+ "(rg -o); rejected in other output modes\n"
28
30
  )
29
31
 
30
32