增强文档改写配图与深度研究流式稳定性,并完善 8BF/会商工作区。
全文改写支持可选配图与思考过程展示,深度研究接入 DashScope 原生出图并剥离内联 think 标签;8BF 会商补齐第一步工作区与任务卡回退,同时限制热重载扫描范围。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
819e537aa3
commit
15a46b903a
48 files changed
+3724
-616
No files matched your search
@@ -38,17 +38,27 @@ class _ChainStore:
|
||||
return self.chain
|
||||
|
||||
|
||||
class _AgentStore:
|
||||
def __init__(self, agents: dict[str, dict[str, object]] | None = None) -> None:
|
||||
self.agents = agents or {}
|
||||
|
||||
async def get_any(self, agent_id: str) -> dict[str, object] | None:
|
||||
return self.agents.get(agent_id)
|
||||
|
||||
|
||||
def _request(
|
||||
role: str,
|
||||
chain: dict[str, object] | None = None,
|
||||
*,
|
||||
email: str = "lqq@example.com",
|
||||
agents: dict[str, dict[str, object]] | None = None,
|
||||
):
|
||||
return SimpleNamespace(
|
||||
app=SimpleNamespace(
|
||||
state=SimpleNamespace(
|
||||
business_mapping_store=_MappingStore(),
|
||||
roundtable_chain_store=_ChainStore(chain),
|
||||
agent_store=_AgentStore(agents),
|
||||
)
|
||||
),
|
||||
state=SimpleNamespace(user=SimpleNamespace(id="admin-id", email=email, system_role=role)),
|
||||
@@ -130,3 +140,34 @@ async def test_global_mapping_rejects_a_private_chain() -> None:
|
||||
|
||||
assert error.value.status_code == 400
|
||||
assert request.app.state.business_mapping_store.calls == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_global_mapping_rejects_a_chain_with_an_unpublished_agent_seat() -> None:
|
||||
request = _request(
|
||||
"admin",
|
||||
{
|
||||
"id": "chain-8bf",
|
||||
"title": "岗位协同链",
|
||||
"is_public": True,
|
||||
"seats": [
|
||||
{"agent_id": "published", "name": "已发布智能体"},
|
||||
{"agent_id": "private", "name": "未发布智能体"},
|
||||
],
|
||||
},
|
||||
agents={
|
||||
"published": {"id": "published", "user_id": "owner", "published": True, "is_private": False},
|
||||
"private": {"id": "private", "user_id": "owner", "published": False, "is_private": False},
|
||||
},
|
||||
)
|
||||
|
||||
with pytest.raises(HTTPException) as error:
|
||||
await business_mapping_router.update_mapping(
|
||||
request,
|
||||
"8BF",
|
||||
business_mapping_router.BusinessMappingUpdateRequest(chain_id="chain-8bf"),
|
||||
)
|
||||
|
||||
assert error.value.status_code == 400
|
||||
assert "未发布智能体" in error.value.detail
|
||||
assert request.app.state.business_mapping_store.calls == []
|
||||
@@ -4,6 +4,7 @@ import pytest
|
||||
|
||||
from app.gateway import deep_research_job_executor as executor_module
|
||||
from app.gateway.deep_research_job_executor import DeepResearchJobExecutor
|
||||
from deerflow.agents.deep_research.events import DeepResearchEvent
|
||||
from deerflow.agents.deep_research.types import DeepResearchResult
|
||||
|
||||
|
||||
@@ -64,3 +65,8 @@ async def test_report_projection_failure_never_marks_job_completed(monkeypatch):
|
||||
)
|
||||
|
||||
assert jobs.progress_calls == []
|
||||
|
||||
|
||||
def test_terminal_timeline_events_are_valid_durable_event_types():
|
||||
assert DeepResearchEvent(type="job_completed", phase="done").type == "job_completed"
|
||||
assert DeepResearchEvent(type="job_failed", phase="done").type == "job_failed"
|
||||
@@ -117,6 +117,61 @@ async def test_queued_job_still_starts_when_session_projection_temporarily_fails
|
||||
assert dispatcher.nudges == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_chat_report_card_can_enable_images_after_collection(monkeypatch):
|
||||
"""The write-time card override must win over the collection-time default."""
|
||||
|
||||
async def fake_require_user(request): # noqa: ANN001
|
||||
return "u1"
|
||||
|
||||
class _ChatSessionStore(_SessionStore):
|
||||
async def get(self, session_id: str, *, user_id: str): # noqa: ARG002
|
||||
return {
|
||||
"id": session_id,
|
||||
"query": "测试主题",
|
||||
"title": "测试主题",
|
||||
"runtime_thread_id": "collector-thread",
|
||||
"config_snapshot": {
|
||||
"mode": "basic",
|
||||
"collection_mode": "chat",
|
||||
"generate_images": False,
|
||||
"max_generated_images": 2,
|
||||
},
|
||||
}
|
||||
|
||||
class _CapturingJobStore(_JobStore):
|
||||
def __init__(self) -> None:
|
||||
self.created: dict | None = None
|
||||
|
||||
async def try_create_or_get_active(self, **kwargs): # noqa: ANN003
|
||||
self.created = kwargs
|
||||
return {"id": "drj_images", "status": "queued"}, True
|
||||
|
||||
monkeypatch.setattr(deep_research, "_require_user", fake_require_user)
|
||||
sessions = _ChatSessionStore()
|
||||
jobs = _CapturingJobStore()
|
||||
response = await deep_research.start_job(
|
||||
"drs_1",
|
||||
deep_research.StartJobRequest(
|
||||
entry="chat",
|
||||
config={"generate_images": True, "max_generated_images": 3},
|
||||
),
|
||||
_request(sessions=sessions, jobs=jobs, dispatcher=_Dispatcher()),
|
||||
)
|
||||
|
||||
assert response["jobId"] == "drj_images"
|
||||
assert jobs.created is not None
|
||||
snapshot = jobs.created["input_snapshot"]["config"]
|
||||
assert snapshot["generate_images"] is True
|
||||
assert snapshot["max_generated_images"] == 3
|
||||
# The session snapshot is persisted too, so a reload/replay keeps the
|
||||
# write-time choice instead of reverting to the creation-time false.
|
||||
assert any(
|
||||
update.get("config_snapshot", {}).get("generate_images") is True
|
||||
for update in sessions.updates
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_stream_stays_open_when_durable_replay_has_a_transient_failure(monkeypatch):
|
||||
"""A stream DB blip must yield a recoverable warning, not an ASGI error group."""
|
||||
|
||||
@@ -206,14 +206,14 @@ def test_position_intent_prompt_keeps_the_original_step_one_guardrails():
|
||||
assert phrase in prompt
|
||||
|
||||
|
||||
def test_position_intent_clarification_waits_for_the_user_before_ready():
|
||||
"""A same-run READY block must not consume the user-assistance pause."""
|
||||
def test_fresh_intent_clarification_waits_for_the_user_before_ready():
|
||||
"""A same-run READY block must not consume a fresh assistance pause."""
|
||||
assert intent_router._clarification_blocks_ready(
|
||||
intent_router.POSITION_INTENT_AGENT_ID,
|
||||
{"name": "ask_clarification"},
|
||||
is_fresh=True,
|
||||
)
|
||||
assert not intent_router._clarification_blocks_ready(
|
||||
assert intent_router._clarification_blocks_ready(
|
||||
intent_router.INTENT_AGENT_ID,
|
||||
{"name": "ask_clarification"},
|
||||
is_fresh=True,
|
||||
|
||||
Reference in new issue
Block a user