Skip to content

Commit 27e62d8

Browse files
loopx-agenthuangruiteng
authored andcommitted
Keep native capture navigation within small output budgets
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
1 parent af341e8 commit 27e62d8

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎loopx/cli_commands/quota_context_reader.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,9 @@ def _native_context_reference(projected: dict[str, Any], reference: dict[str, An
577577
if value is None or isinstance(value, (str, bool, int, float))
578578
and len(json.dumps(value, ensure_ascii=False).encode("utf-8")) <= 240}
579579
result["instruction"] = CONTEXT_CAPTURE_NAVIGATION_GUIDANCE if progressive_enabled else CONTEXT_CAPTURE_READ_GUIDANCE
580-
result["instruction"] += " Use --select or --list with recovery.command for fields in that view."
580+
result["instruction"] += " Use --select or --list on recovery.command."
581581
if progressive_enabled:
582-
result["instruction"] += " Use the source in context_details for deferred fields."
582+
result["instruction"] += " Deferred fields use context_details."
583583
if mode != "full":
584584
result["instruction"] += (" command reads the delta; baseline_reference identifies its exact saved base when file-backed. "
585585
"recovery.command reads current facts directly without that baseline.")

‎tests/control_plane/test_context_first_read.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@
1919
from tests.control_plane.codex_checkpoint_fixture import selected_context_values
2020

2121

22+
def test_small_native_navigation_keeps_both_reader_routes():
23+
from loopx.cli_commands.quota_context_reader import _native_context_reference, _native_output_bytes
24+
25+
# Fixed reader paths isolate the caller's budget from checkout and temporary directory names.
26+
capture = {"path": f"/project/{'x' * 255}/required-context.json", "sha256": "a" * 64}
27+
view = _native_context_reference(
28+
{}, capture, mode="full", current=capture, current_document={"ok": True},
29+
total_bytes=2000, metadata=None, progressive_enabled=True, field_index=None,
30+
initial_read_pointers=None, initial_read_reference=None, page_bytes=3200,
31+
output_bytes=3200, first_read_budget=(3200, 3200),
32+
reader_argv=["/install/bin/loopx", "--cli-bin", "/install/bin/loopx"],
33+
)
34+
35+
assert len(_native_output_bytes(view)) <= 3200
36+
recovery = shlex.split(view["recovery"]["command"])
37+
assert recovery[recovery.index("--capture-file") + 1] == capture["path"]
38+
assert recovery[recovery.index("--capture-sha256") + 1] == capture["sha256"]
39+
assert recovery[recovery.index("--max-page-output-bytes") + 1] == "3200"
40+
assert all(term in view["instruction"] for term in ("--select", "--list", "recovery.command", "context_details"))
41+
2242
@pytest.fixture
2343
def decision():
2444
return {

0 commit comments

Comments
 (0)