dify/api/core/app
Yansong Zhang b21a443d56 fix(api): resolve all remaining known issues
1. Fix workflow-level total_tokens=0:
   Call graph_runtime_state.add_tokens(usage.total_tokens) in both
   _run_without_tools and _run_with_tools paths after node execution.
   Previously only graphon's internal ModelInvokeCompletedEvent handler
   called add_tokens, which agent-v2 doesn't emit.

2. Fix Turn 2 SSE empty response:
   Set PUBSUB_REDIS_CHANNEL_TYPE=streams in .env. Redis Streams
   provides durable event delivery (consumers can replay past events),
   solving the pub/sub at-most-once timing issue.

3. Skill -> Agent runtime integration:
   SandboxBuilder.build() now auto-includes SkillInitializer if not
   already present. This ensures sandbox.attrs has the skill bundle
   loaded for downstream consumers (tool execution in sandbox).

4. LegacyResponseAdapter:
   New module at core/app/apps/common/legacy_response_adapter.py.
   Filters workflow-specific SSE events (workflow_started, node_started,
   node_finished, workflow_finished) from the stream, passing through
   only message/message_end/agent_log/error/ping events that old
   clients expect.

46 unit tests pass.

Made-with: Cursor
2026-04-09 12:53:11 +08:00
..
app_config refactor(api): migrate consumers to shared RAG domain entities from core/rag/entities/ (#34692) 2026-04-07 23:22:56 +00:00
apps fix(api): resolve all remaining known issues 2026-04-09 12:53:11 +08:00
entities feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
features refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
file_access refactor(api): continue decoupling dify_graph from API concerns (#33580) 2026-03-25 20:32:24 +08:00
layers feat(api): port Sandbox + VirtualEnvironment + Skill system from feat/support-agent-sandbox (Phase 5-6) 2026-04-08 17:39:02 +08:00
llm refactor: use EnumText for Provider.quota_type and consolidate ProviderQuotaType (#34299) 2026-03-31 00:29:57 +00:00
task_pipeline refactor: migrate session.query to select API in core misc modules (#34608) 2026-04-07 04:08:34 +00:00
workflow chore(api): align Python support with 3.12 (#34419) 2026-04-02 05:07:32 +00:00
__init__.py FEAT: NEW WORKFLOW ENGINE (#3160) 2024-04-08 18:51:46 +08:00