fix: resolve CI failures — unused imports, type errors, test updates

- Remove 12 unused imports across node.py, tool_manager.py,
  event_adapter.py, legacy_response_adapter.py
- Fix Sequence[str] → list[str] type annotation in node.py
- Update test_agent_chat_app_runner.py: CotChatAgentRunner →
  AgentAppRunner (old runner classes replaced by unified runner)

Made-with: Cursor
This commit is contained in:
Yansong Zhang 2026-04-13 13:10:08 +08:00
parent c03b25a940
commit 5f87239abc
5 changed files with 6 additions and 18 deletions

View File

@ -12,7 +12,6 @@ from __future__ import annotations
import json
import logging
from collections.abc import Generator
from typing import Any
logger = logging.getLogger(__name__)

View File

@ -7,7 +7,6 @@ graphon NodeEventBase events consumable by the workflow engine.
from __future__ import annotations
from collections.abc import Generator
from typing import Any
from graphon.model_runtime.entities import LLMResultChunk
from graphon.node_events import (

View File

@ -10,12 +10,11 @@ from __future__ import annotations
import logging
import re
from collections.abc import Generator, Mapping, Sequence
from typing import TYPE_CHECKING, Any, Literal, cast
from typing import TYPE_CHECKING, Any, Literal
from graphon.enums import WorkflowNodeExecutionMetadataKey, WorkflowNodeExecutionStatus
from graphon.model_runtime.entities import (
AssistantPromptMessage,
LLMResult,
LLMResultChunk,
PromptMessage,
SystemPromptMessage,
@ -23,15 +22,10 @@ from graphon.model_runtime.entities import (
UserPromptMessage,
)
from graphon.model_runtime.entities.llm_entities import LLMUsage
from graphon.model_runtime.entities.message_entities import (
ImagePromptMessageContent,
PromptMessageContentUnionTypes,
)
from graphon.model_runtime.entities.model_entities import ModelFeature, ModelType
from graphon.node_events import (
NodeEventBase,
NodeRunResult,
StreamChunkEvent,
StreamCompletedEvent,
)
from graphon.nodes.base.node import Node
@ -545,11 +539,11 @@ class AgentV2Node(Node[AgentV2NodeData]):
content = jinja2_text or text
selectors = VariableTemplateParser(content).extract_variable_selectors()
for selector in selectors:
result[selector.variable] = selector.value_selector
result[selector.variable] = list(selector.value_selector)
else:
text_content = getattr(node_data.prompt_template, "text", "") or ""
selectors = VariableTemplateParser(text_content).extract_variable_selectors()
for selector in selectors:
result[selector.variable] = selector.value_selector
result[selector.variable] = list(selector.value_selector)
return {f"{node_id}.{key}": value for key, value in result.items()}

View File

@ -8,12 +8,8 @@ from __future__ import annotations
import json
import logging
from collections.abc import Generator
from typing import TYPE_CHECKING, Any
from graphon.file import File
from graphon.model_runtime.entities import PromptMessageTool
from core.agent.entities import AgentToolEntity, ExecutionContext
from core.agent.patterns.base import ToolInvokeHook
from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler

View File

@ -136,8 +136,8 @@ class TestAgentChatAppRunnerRun:
@pytest.mark.parametrize(
("mode", "expected_runner"),
[
(LLMMode.CHAT, "CotChatAgentRunner"),
(LLMMode.COMPLETION, "CotCompletionAgentRunner"),
(LLMMode.CHAT, "AgentAppRunner"),
(LLMMode.COMPLETION, "AgentAppRunner"),
],
)
def test_run_chain_of_thought_modes(self, runner, mocker, mode, expected_runner):
@ -286,7 +286,7 @@ class TestAgentChatAppRunnerRun:
)
runner_cls = mocker.MagicMock()
mocker.patch("core.app.apps.agent_chat.app_runner.FunctionCallAgentRunner", runner_cls)
mocker.patch("core.app.apps.agent_chat.app_runner.AgentAppRunner", runner_cls)
runner_instance = mocker.MagicMock()
runner_cls.return_value = runner_instance