mirror of
https://github.com/langgenius/dify.git
synced 2026-06-26 14:51:13 +08:00
Merge commit 'c51c96b991' into feat/agent-v2
This commit is contained in:
commit
0d7d1704f7
@ -267,7 +267,11 @@ class AgentStubDriveCommitRequest(BaseModel):
|
||||
|
||||
|
||||
class AgentStubDriveItem(BaseModel):
|
||||
"""One manifest or commit item returned by the Agent Stub drive API."""
|
||||
"""One manifest or commit item returned by the Agent Stub drive API.
|
||||
|
||||
Known stable fields stay typed, while extra response metadata from the Dify
|
||||
API is preserved for forward compatibility.
|
||||
"""
|
||||
|
||||
key: str
|
||||
size: int | None = None
|
||||
@ -282,7 +286,7 @@ class AgentStubDriveItem(BaseModel):
|
||||
is_skill: bool | None = None
|
||||
skill_metadata: str | None = None
|
||||
|
||||
model_config: ClassVar[ConfigDict] = ConfigDict(extra="forbid")
|
||||
model_config: ClassVar[ConfigDict] = ConfigDict(extra="allow")
|
||||
|
||||
|
||||
class AgentStubDriveManifestResponse(BaseModel):
|
||||
|
||||
@ -196,6 +196,7 @@ def test_request_agent_stub_drive_manifest_sync_gets_manifest_request() -> None:
|
||||
"items": [
|
||||
{
|
||||
"key": "skills/example/SKILL.md",
|
||||
"name": "SKILL.md",
|
||||
"size": 12,
|
||||
"hash": "sha256:abc",
|
||||
"mime_type": "text/markdown",
|
||||
@ -220,6 +221,7 @@ def test_request_agent_stub_drive_manifest_sync_gets_manifest_request() -> None:
|
||||
http_client.close()
|
||||
|
||||
assert response.items[0].key == "skills/example/SKILL.md"
|
||||
assert response.items[0].model_extra == {"name": "SKILL.md"}
|
||||
|
||||
|
||||
def test_request_agent_stub_drive_commit_sync_posts_commit_request() -> None:
|
||||
|
||||
@ -11,6 +11,7 @@ from dify_agent.agent_stub.protocol.agent_stub import (
|
||||
AgentStubDriveCommitItem,
|
||||
AgentStubDriveCommitRequest,
|
||||
AgentStubDriveFileRef,
|
||||
AgentStubDriveManifestResponse,
|
||||
AgentStubFileMapping,
|
||||
agent_stub_connections_url,
|
||||
agent_stub_drive_base_for_ref,
|
||||
@ -159,6 +160,7 @@ def test_agent_stub_drive_commit_request_validates_file_refs() -> None:
|
||||
]
|
||||
)
|
||||
|
||||
assert request.items[0].file_ref is not None
|
||||
assert request.items[0].file_ref.kind == "tool_file"
|
||||
|
||||
with pytest.raises(ValidationError, match="tool_file"):
|
||||
@ -168,6 +170,15 @@ def test_agent_stub_drive_commit_request_validates_file_refs() -> None:
|
||||
assert item_without_file_ref.file_ref is None
|
||||
|
||||
|
||||
def test_agent_stub_drive_manifest_response_preserves_extra_item_fields() -> None:
|
||||
response = AgentStubDriveManifestResponse.model_validate(
|
||||
{"items": [{"key": "skills/example/SKILL.md", "name": "SKILL.md"}]}
|
||||
)
|
||||
|
||||
assert response.items[0].model_extra == {"name": "SKILL.md"}
|
||||
assert response.items[0].model_dump(mode="json")["name"] == "SKILL.md"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("transfer_method", ["tool_file", "local_file", "datasource_file"])
|
||||
def test_agent_stub_file_mapping_rejects_non_remote_with_url(
|
||||
transfer_method: Literal["tool_file", "local_file", "datasource_file"],
|
||||
|
||||
@ -57,6 +57,7 @@ def test_dify_api_agent_stub_drive_handler_injects_execution_context_for_manifes
|
||||
"items": [
|
||||
{
|
||||
"key": "skills/example/SKILL.md",
|
||||
"name": "SKILL.md",
|
||||
"size": 12,
|
||||
"hash": "sha256:abc",
|
||||
"mime_type": "text/markdown",
|
||||
@ -82,6 +83,7 @@ def test_dify_api_agent_stub_drive_handler_injects_execution_context_for_manifes
|
||||
include_download_url=True,
|
||||
)
|
||||
assert response.items[0].download_url == "https://files.example.com/download"
|
||||
assert response.items[0].model_extra == {"name": "SKILL.md"}
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user