mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-19 18:45:15 +02:00
chore: linting
This commit is contained in:
parent
219a5977b7
commit
c187b04e82
25 changed files with 102 additions and 108 deletions
|
|
@ -362,9 +362,7 @@ async def test_full_resume_routing_glue_for_two_paused_subagents():
|
|||
SimpleNamespace(
|
||||
id="i-approver",
|
||||
value={
|
||||
"action_requests": [
|
||||
{"name": "approve", "args": {}, "description": ""}
|
||||
],
|
||||
"action_requests": [{"name": "approve", "args": {}, "description": ""}],
|
||||
"review_configs": [{}],
|
||||
"tool_call_id": "tcid-approver",
|
||||
},
|
||||
|
|
@ -403,8 +401,6 @@ async def test_full_resume_routing_glue_for_two_paused_subagents():
|
|||
|
||||
received_a = ast.literal_eval(result_a.update["decision_text"])
|
||||
assert received_a == {"decisions": flat_decisions[0:3]}
|
||||
assert result_b.update["decision_text"] == repr(
|
||||
{"decisions": flat_decisions[3:4]}
|
||||
)
|
||||
assert result_b.update["decision_text"] == repr({"decisions": flat_decisions[3:4]})
|
||||
|
||||
assert "surfsense_resume_value" not in parent_config["configurable"]
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ This module pins:
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
from typing import Annotated
|
||||
|
||||
|
|
@ -227,10 +228,8 @@ async def test_heterogeneous_decisions_route_to_correct_subagents_with_metadata_
|
|||
for msg in final_state.values.get("messages", []) or []:
|
||||
content = getattr(msg, "content", None)
|
||||
if isinstance(content, str):
|
||||
try:
|
||||
with contextlib.suppress(json.JSONDecodeError):
|
||||
payloads.append(json.loads(content))
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
expected_a = {"decisions": [a_approve, a_reject]}
|
||||
expected_b = {"decisions": [b_edit, b_approve, b_reject]}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ exploratory probe before this test was authored.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
from typing import Annotated
|
||||
|
||||
|
|
@ -243,10 +244,8 @@ async def test_partial_pause_routes_only_to_paused_branch_without_rerunning_comp
|
|||
for msg in final.values.get("messages", []) or []:
|
||||
content = getattr(msg, "content", None)
|
||||
if isinstance(content, str):
|
||||
try:
|
||||
with contextlib.suppress(json.JSONDecodeError):
|
||||
payloads.append(json.loads(content))
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
assert {"decisions": [{"type": "approve"}]} in payloads, (
|
||||
f"REGRESSION: sub-B did not receive its single approve on resume; "
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ Why a separate pin:
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
from typing import Annotated
|
||||
|
||||
|
|
@ -191,10 +192,8 @@ async def test_all_reject_decisions_route_to_each_subagent_with_messages_intact(
|
|||
for msg in final_state.values.get("messages", []) or []:
|
||||
content = getattr(msg, "content", None)
|
||||
if isinstance(content, str):
|
||||
try:
|
||||
with contextlib.suppress(json.JSONDecodeError):
|
||||
payloads.append(json.loads(content))
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
expected_a = {"decisions": [a_reject_0, a_reject_1]}
|
||||
expected_b = {"decisions": [b_reject_0]}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ silently pass such a bug because the slices would coincide.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
from typing import Annotated
|
||||
|
||||
|
|
@ -81,9 +82,7 @@ def _build_pausing_subagent(checkpointer: InMemorySaver, *, action_count: int):
|
|||
"review_configs": [{} for _ in range(action_count)],
|
||||
}
|
||||
)
|
||||
return {
|
||||
"messages": [AIMessage(content=json.dumps(decision, sort_keys=True))]
|
||||
}
|
||||
return {"messages": [AIMessage(content=json.dumps(decision, sort_keys=True))]}
|
||||
|
||||
g = StateGraph(_SubState)
|
||||
g.add_node("approve", approve_node)
|
||||
|
|
@ -202,7 +201,9 @@ async def test_parallel_resume_with_per_interrupt_id_keying_completes_both_subag
|
|||
await parent.ainvoke({"messages": [HumanMessage(content="seed")]}, config)
|
||||
|
||||
paused_state = await parent.aget_state(config)
|
||||
assert len(paused_state.interrupts) == 2, "fixture broken: expected 2 paused subagents"
|
||||
assert len(paused_state.interrupts) == 2, (
|
||||
"fixture broken: expected 2 paused subagents"
|
||||
)
|
||||
|
||||
pending = collect_pending_tool_calls(paused_state)
|
||||
assert dict(pending) == {tcid_a: 2, tcid_b: 3}, (
|
||||
|
|
@ -243,10 +244,8 @@ async def test_parallel_resume_with_per_interrupt_id_keying_completes_both_subag
|
|||
for msg in final_state.values.get("messages", []) or []:
|
||||
content = getattr(msg, "content", None)
|
||||
if isinstance(content, str):
|
||||
try:
|
||||
with contextlib.suppress(json.JSONDecodeError):
|
||||
payloads.append(json.loads(content))
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
expected_a = {"decisions": [a_d0, a_d1]}
|
||||
expected_b = {"decisions": [b_d0, b_d1, b_d2]}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ their per-slice payload.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
from typing import Annotated
|
||||
|
||||
|
|
@ -151,7 +152,11 @@ def _parent_dispatching_one_of_each(
|
|||
return [
|
||||
Send(
|
||||
"call_task",
|
||||
{"tcid": tcid_self, "desc": "approve email", "subtype": "self-gated-agent"},
|
||||
{
|
||||
"tcid": tcid_self,
|
||||
"desc": "approve email",
|
||||
"subtype": "self-gated-agent",
|
||||
},
|
||||
),
|
||||
Send(
|
||||
"call_task",
|
||||
|
|
@ -250,10 +255,8 @@ async def test_parallel_self_gated_and_middleware_gated_route_and_resume_cleanly
|
|||
for msg in final.values.get("messages", []) or []:
|
||||
content = getattr(msg, "content", None)
|
||||
if isinstance(content, str):
|
||||
try:
|
||||
with contextlib.suppress(json.JSONDecodeError):
|
||||
payloads.append(json.loads(content))
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
self_payloads = [p for p in payloads if p.get("kind") == "self_gated"]
|
||||
mw_payloads = [p for p in payloads if p.get("kind") == "middleware_gated"]
|
||||
|
|
|
|||
|
|
@ -121,7 +121,11 @@ async def test_two_parallel_atasks_same_subagent_type_different_tool_call_ids():
|
|||
shared_subagent = _build_success_subagent("ok")
|
||||
task_tool = build_task_tool_with_parent_config(
|
||||
[
|
||||
{"name": "approver", "description": "shared approver", "runnable": shared_subagent},
|
||||
{
|
||||
"name": "approver",
|
||||
"description": "shared approver",
|
||||
"runnable": shared_subagent,
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
|
|
@ -163,7 +167,10 @@ async def test_two_parallel_atasks_same_subagent_type_different_tool_call_ids():
|
|||
state_parent = await shared_subagent.aget_state(
|
||||
{"configurable": {"thread_id": "shared-subagent-thread"}}
|
||||
)
|
||||
assert state_parent.values == {} or state_parent.values.get("messages") in (None, [])
|
||||
assert state_parent.values == {} or state_parent.values.get("messages") in (
|
||||
None,
|
||||
[],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -181,8 +188,16 @@ async def test_one_atask_failure_does_not_corrupt_sibling_atask():
|
|||
surviving_subagent = _build_success_subagent("still here")
|
||||
task_tool = build_task_tool_with_parent_config(
|
||||
[
|
||||
{"name": "broken", "description": "always fails", "runnable": failing_subagent},
|
||||
{"name": "healthy", "description": "always succeeds", "runnable": surviving_subagent},
|
||||
{
|
||||
"name": "broken",
|
||||
"description": "always fails",
|
||||
"runnable": failing_subagent,
|
||||
},
|
||||
{
|
||||
"name": "healthy",
|
||||
"description": "always succeeds",
|
||||
"runnable": surviving_subagent,
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -84,9 +84,7 @@ async def test_resume_with_approve_envelope_returns_once_decision():
|
|||
config = {"configurable": {"thread_id": "perm-once"}}
|
||||
await graph.ainvoke({"messages": [HumanMessage(content="seed")]}, config)
|
||||
|
||||
await graph.ainvoke(
|
||||
Command(resume={"decisions": [{"type": "approve"}]}), config
|
||||
)
|
||||
await graph.ainvoke(Command(resume={"decisions": [{"type": "approve"}]}), config)
|
||||
final = await graph.aget_state(config)
|
||||
assert final.values.get("final_decision") == {"decision_type": "once"}
|
||||
|
||||
|
|
@ -116,9 +114,7 @@ async def test_resume_with_reject_and_feedback_carries_feedback_through():
|
|||
|
||||
await graph.ainvoke(
|
||||
Command(
|
||||
resume={
|
||||
"decisions": [{"type": "reject", "feedback": "use the trash bin"}]
|
||||
}
|
||||
resume={"decisions": [{"type": "reject", "feedback": "use the trash bin"}]}
|
||||
),
|
||||
config,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -141,9 +141,7 @@ async def test_kb_ruleset_resume_with_approve_lets_rm_through():
|
|||
config = {"configurable": {"thread_id": "kb-cloud-rm-approve"}}
|
||||
await graph.ainvoke({"messages": [HumanMessage(content="seed")]}, config)
|
||||
|
||||
await graph.ainvoke(
|
||||
Command(resume={"decisions": [{"type": "approve"}]}), config
|
||||
)
|
||||
await graph.ainvoke(Command(resume={"decisions": [{"type": "approve"}]}), config)
|
||||
final = await graph.aget_state(config)
|
||||
assert final.next == (), "graph must complete after approve"
|
||||
last_ai = next(
|
||||
|
|
|
|||
|
|
@ -100,7 +100,9 @@ class TestBuildLcHitlPayload:
|
|||
interrupt_type="x",
|
||||
)
|
||||
decisions.append(LC_DECISION_REJECT)
|
||||
assert payload["review_configs"][0]["allowed_decisions"] == [LC_DECISION_APPROVE]
|
||||
assert payload["review_configs"][0]["allowed_decisions"] == [
|
||||
LC_DECISION_APPROVE
|
||||
]
|
||||
|
||||
|
||||
class TestParseLcEnvelope:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue