Skip to content

Commit e4457a8

Browse files
committed
fix(lint): satisfy ruff on argus patches after upstream merge
Upstream's lint workflow caught three issues in our patches that the post-merge tree exposed: - prompt.py: two lines in the <file_editing> block exceeded line-length=240 (E501). Tightened the prose; same meaning, both lines now 224. - test_postgres_aprune.py: ruff I001 wanted the deerflow import grouped with other imports, but it has to live below pytest.importorskip(). Already had # noqa: E402 for that reason; extended to E402, I001. - factory.py + test_postgres_aprune.py: ruff format wanted the weakref dict declaration and two set comprehensions on single lines. Applied uvx ruff format. No behavior change.
1 parent 1168324 commit e4457a8

3 files changed

Lines changed: 6 additions & 16 deletions

File tree

backend/packages/harness/deerflow/agents/lead_agent/prompt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,14 @@ def _build_subagent_section(max_concurrent: int) -> str:
452452
- Final deliverables must be copied to `/mnt/user-data/outputs` and presented using `present_files` tool
453453
{acp_section}
454454
<file_editing>
455-
**Prefer targeted edits over full rewrites.** When modifying a file you wrote earlier in this conversation, the cost of rewriting is real: every byte of the rewritten file has to be re-emitted as model output and lives in conversation history forever. A 5-line fix in a 500-line file should be 5 lines, not 500.
455+
**Prefer targeted edits over full rewrites.** Rewriting a file you wrote earlier is expensive: every byte gets re-emitted and lives in conversation history forever. A 5-line fix in a 500-line file should be 5 lines, not 500.
456456
457457
**Tool ordering when changing files:**
458458
1. `str_replace` — for targeted modifications. Use this whenever you can describe the change as "replace X with Y" in an existing file. Faster than rewriting because only the diff goes through the LLM.
459459
2. `write_file` — for *new* files, or when the change covers more than ~80% of the file's contents.
460460
3. `bash` heredocs (`cat <<EOF > file`) — avoid for any file you might edit later. The full content gets baked into conversation history. Reserve heredocs for one-off scripts the agent itself will execute and discard.
461461
462-
**Before editing a file you wrote earlier in the same conversation, call `read_file` first.** Don't rely on memory of what you wrote — context can drift. `read_file` is cheap; `str_replace` failing because of a stale "expected old content" is expensive.
462+
**Before editing a file you wrote earlier in the same conversation, call `read_file` first.** Don't rely on memory — context drifts. `read_file` is cheap; `str_replace` failing on stale "expected old content" is expensive.
463463
464464
**For deliverables in `/mnt/user-data/outputs`:** write the file once with `write_file`. If you find a bug after writing, use `str_replace` to fix in place. Do not re-run a HEREDOC `cat > ...` to rewrite the whole file.
465465
</file_editing>

backend/packages/harness/deerflow/models/factory.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
#
3030
# WeakValueDictionary so the client is GC'd when its loop is GC'd; no leak
3131
# across long-lived processes that handle thousands of short-lived loops.
32-
_PER_LOOP_HTTPX_CLIENTS: "weakref.WeakValueDictionary[int, httpx.AsyncClient]" = (
33-
weakref.WeakValueDictionary()
34-
)
32+
_PER_LOOP_HTTPX_CLIENTS: "weakref.WeakValueDictionary[int, httpx.AsyncClient]" = weakref.WeakValueDictionary()
3533

3634

3735
def _httpx_client_for_current_loop() -> httpx.AsyncClient | None:

backend/tests/test_postgres_aprune.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# checkpointer at image build time, so the test runs in our CI.
2424
pytest.importorskip("langgraph.checkpoint.postgres.aio")
2525

26-
from deerflow.agents.checkpointer import _postgres_aprune # noqa: E402
26+
from deerflow.agents.checkpointer import _postgres_aprune # noqa: E402, I001
2727

2828

2929
# ---------------------------------------------------------------------------
@@ -101,10 +101,7 @@ async def test_keep_latest_issues_two_deletes(self):
101101
await _postgres_aprune._aprune(saver, ["t1", "t2"], strategy="keep_latest")
102102

103103
assert len(saver.cursor.calls) == 2
104-
tables_touched = [
105-
"checkpoints" if "FROM checkpoints" in sql else "checkpoint_writes"
106-
for sql, _ in saver.cursor.calls
107-
]
104+
tables_touched = ["checkpoints" if "FROM checkpoints" in sql else "checkpoint_writes" for sql, _ in saver.cursor.calls]
108105
assert set(tables_touched) == {"checkpoints", "checkpoint_writes"}
109106
# Blobs must not be touched
110107
for sql, _ in saver.cursor.calls:
@@ -119,12 +116,7 @@ async def test_delete_all_touches_all_three_tables(self):
119116
await _postgres_aprune._aprune(saver, ["t1"], strategy="delete_all")
120117

121118
assert len(saver.cursor.calls) == 3
122-
tables = {
123-
"checkpoints" if "FROM checkpoints " in sql else
124-
"checkpoint_blobs" if "FROM checkpoint_blobs " in sql else
125-
"checkpoint_writes"
126-
for sql, _ in saver.cursor.calls
127-
}
119+
tables = {"checkpoints" if "FROM checkpoints " in sql else "checkpoint_blobs" if "FROM checkpoint_blobs " in sql else "checkpoint_writes" for sql, _ in saver.cursor.calls}
128120
assert tables == {"checkpoints", "checkpoint_blobs", "checkpoint_writes"}
129121

130122
async def test_unknown_strategy_raises(self):

0 commit comments

Comments
 (0)