Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions loopx/capabilities/manager_context/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,9 @@ The progressive quota hook's required command requests the Inbox Markdown view.
When every item on a page has the same `instruction`, `next_action` or
`receiver_followthrough`, apply that exact field from `shared_item_guidance`
to each item on that page. Differing values and all request bodies, current state, read receipts, warnings, and
cursors are delivered in full. If a Markdown page exceeds the 12,000-byte tool
output budget, the command returns a private, digest-checked reader for that
cursors are delivered in full. Markdown Inbox responses use a 5,000-byte
serialized output limit, including reader commands and navigation. If a page
is too large, the command returns a private, digest-checked reader for that
exact Inbox result. Compare each page's digest with the opening and use its
direct recovery command if the reference is unavailable. Read the captured
bytes to EOF, then use the Inbox `--cursor` or `--operation-cursor` for the next
Expand All @@ -382,8 +383,9 @@ delivery is explicitly off.
渐进 quota 的必读命令使用 Inbox Markdown 视图。当前页每条的 `instruction`、
`next_action` 或 `receiver_followthrough` 完全相同时,从 `shared_item_guidance`
读取原值并应用到本页每条。
不同指引、请求全文、当前状态、读回执、警告和游标均完整交付。Markdown 页超出
12,000 字节工具输出预算时,命令给出绑定原 Inbox 结果摘要的私有 reader。逐页与开场
不同指引、请求全文、当前状态、读回执、警告和游标均完整交付。Markdown Inbox
的序列化输出上限为 5,000 字节,含读取命令和导航。页面超限时,命令给出绑定原 Inbox
结果摘要的私有 reader。逐页与开场
摘要核对,引用不可用时使用直接恢复命令。先按字节偏移
读到 EOF,再按 Inbox 的 `--cursor` 或 `--operation-cursor` 读后续请求;这两类分页
不能混用。交付失败不表示 Inbox 为空。读回保存结果不会再次记 Inbox 读取回执、消费
Expand Down
7 changes: 4 additions & 3 deletions loopx/cli_commands/manager_inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def _render_read_markdown(result: dict) -> str:

def _read_markdown(result: dict, *, runtime_root: Path) -> tuple[str, bool]:
"""Deliver the already-recorded scoped read without repeating its effects."""
from ..control_plane.turn_driver.native_context_profile import NATIVE_CONTEXT_FIRST_READ_FALLBACK_BYTES
from ..control_plane.turn_driver.native_context_profile import NATIVE_INBOX_MARKDOWN_OUTPUT_BYTES

limit = NATIVE_CONTEXT_FIRST_READ_FALLBACK_BYTES
limit = NATIVE_INBOX_MARKDOWN_OUTPUT_BYTES
view = _share_item_guidance(result)
body = _render_read_markdown(view)
size = len((body + os.linesep).encode("utf-8"))
Expand Down Expand Up @@ -142,7 +142,8 @@ def _read_markdown(result: dict, *, runtime_root: Path) -> tuple[str, bool]:
"Follow next_command through eof in UTF-8 byte-offset order. Compare each reported digest with "
"this opening's SHA-256. Check each "
"page's content length against its offsets, and complete coverage through total_bytes. "
"If output is missing or truncated, reread that range of the same capture with a smaller page. "
"If output is missing or truncated, reread that range of the same capture with smaller "
"--page-bytes and --max-page-output-bytes. "

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 收紧未知容量时保留已声明的大页 Inbox 读取能力。用主干现有的明确 64,000 字节配置,在真实 File 和 SQLite 上读取同一批 23 条请求。两种后端都从主干的 5 次 capture reader 调用增加到本头的 59 次,逻辑页仍为 2 页,全文和原游标均读回。普通 reader 和直连恢复命令都忽略了原显式预算。 在 #9095 的预算 owner 上收紧未知容量时的 Markdown 开场和续读。对已明确声明且能保留较大输出的调用保留原 reader 路径。如需收缩已声明容量的行为,应更新相应契约,并以同一负载明确权衡补读成本。

+ CONTEXT_CAPTURE_CODE_MODE_GUIDANCE
+ "Apply any shared_item_guidance to the items on this page. After the page is complete, "
"follow its next_cursor, operation_handoff_next_cursor, or native_child_results.next_cursor with the original Inbox command. "
Expand Down
3 changes: 3 additions & 0 deletions loopx/control_plane/turn_driver/native_context_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# Native openings cross a tool boundary, whether attached or linked. When
# that tool's cap is unknown, avoid the bulk-reader profile.
NATIVE_CONTEXT_FIRST_READ_FALLBACK_BYTES = 12000
# Native shell tools can clip a 12 KB Markdown Inbox response in model history.
# Leave headroom for their own framing, including on multilingual pages.
NATIVE_INBOX_MARKDOWN_OUTPUT_BYTES = 5000
# Keep the configuration declaration usable by older installed readers too.
NATIVE_CONTEXT_LARGE_OUTPUT_BYTES = 64000
NATIVE_CONTEXT_HISTORY_TOKENS = 20000
Expand Down
11 changes: 6 additions & 5 deletions tests/test_delegation_turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def test_unbound_cli_first_read_leaves_inbox_rows_to_its_required_read(tmp_path,
def invoke(argv):
result = subprocess.run(argv, cwd=project, capture_output=True, timeout=40)
assert result.returncode == 0, result.stderr
assert 0 < len(result.stdout) <= 12_000
# This view and its continuation run through the native shell tool.
assert 0 < len(result.stdout) <= 5_000
return result.stdout.decode()

def read_receipts():
Expand Down Expand Up @@ -257,7 +258,7 @@ def read_receipts():
if logical_pages == 1:
reference_path.unlink()
failed = subprocess.run(shlex.split(page["command"]), cwd=project, capture_output=True, timeout=40)
assert failed.returncode == 1 and len(failed.stdout) <= 12_000
assert failed.returncode == 1 and len(failed.stdout) <= 5_000
assert "content" not in json.loads(failed.stdout)
recovered = json.loads(invoke(direct))
assert recovered["offset"] == 0 and recovered["sha256"] == pinned
Expand Down Expand Up @@ -294,7 +295,7 @@ def test_large_inbox_does_not_fall_back_to_unbounded_output(flow):
invocation = [sys.executable, "-m", "loopx.entrypoint", "--registry", str(registry), "--runtime-root", str(root),
"manager-inbox", "read", "--format", "markdown", "--goal-id", "research", "--agent-id", "worker"]
result = subprocess.run(invocation, cwd=root, capture_output=True, timeout=40)
assert result.returncode == 1 and len(result.stdout) <= 12_000
assert result.returncode == 1 and len(result.stdout) <= 5_000
output = result.stdout.decode()
failure = json.loads(output.split("\n```json\n", 1)[1].removesuffix("\n```\n"))
assert not failure["ok"] and not failure["read_complete"]
Expand Down Expand Up @@ -331,7 +332,7 @@ def test_large_inbox_reader_commands_run_verbatim_in_powershell(flow, directory)
opening = subprocess.run([*powershell, "-Command", required_read["command"]], cwd=root, env=environment,
capture_output=True, timeout=60)
assert opening.returncode == 0, opening.stderr
assert 0 < len(opening.stdout) <= 12_000
assert 0 < len(opening.stdout) <= 5_000
markdown = opening.stdout.decode().replace("\r\n", "\n")
view = json.loads(markdown.split("\n```json\n", 1)[1].removesuffix("\n```\n"))
before = {p.relative_to(root): p.read_bytes() for p in _root(root).rglob("*.json")}
Expand All @@ -342,7 +343,7 @@ def test_large_inbox_reader_commands_run_verbatim_in_powershell(flow, directory)
output = subprocess.run([*powershell, "-Command", command], cwd=root, env=environment,
capture_output=True, timeout=60)
assert output.returncode == 0, output.stderr
assert 0 < len(output.stdout) <= 12_000
assert 0 < len(output.stdout) <= 5_000
page = json.loads(output.stdout)
assert page["ok"] and page["offset"] == len(original) and page["sha256"] == view["sha256"]
original.extend(page["content"].encode())
Expand Down
Loading