Agent strategy run cut by PLUGIN_MAX_EXECUTION_TIMEOUT is reported only as "Internal Server Error"

Open
#863 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend

Research direction

Start at the <-timer.C branch in internal/service/base_sse.go, where the timeout currently calls exception.InternalServerError, then read internal/types/exception/factory.go to see how error types and messages are built. Reproduce by setting a short PLUGIN_MAX_EXECUTION_TIMEOUT and running a long agent strategy dispatch. Done means a timeout returns its own error type and message naming the configured limit, while client disconnects and real internal errors keep their existing types.

Written by the indexing model from the issue text.

Description

Self Checks

To make sure we get to you in time, please check the following :)

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • "Please do not modify this template :) and fill in all the required fields."

Versions

  1. dify-plugin-daemon Version: 0.6.14-local
  2. dify-api Version: 1.19.0 (self-hosted docker-compose). The same defaults and code path are present in 1.20.0 and in current main of this repo.

Agent strategy plugin: langgenius/agent 0.0.51 (Function Calling). Model plugin: langgenius/openai_api_compatible 0.0.84.

Describe the bug

PLUGIN_MAX_EXECUTION_TIMEOUT (default 600) caps the whole dispatch/agent_strategy/invoke stream, so it is effectively the maximum total runtime of an Agent node in a workflow, not just a single model or tool call. That limit by itself is reasonable and configurable. The problem is how it is reported.

When the timer fires, baseSSEService writes exception.InternalServerError(errors.New("killed by timeout")) (internal/service/base_sse.go, the <-timer.C branch). InternalServerError logs the real reason and returns the fixed message "Internal Server Error" (internal/types/exception/factory.go). The workflow therefore fails with only:

req_id: <id> PluginDaemonInternalServerError: Internal Server Error

Nothing in the run tells the user that a time limit was reached, or which setting controls it. The reason is visible only in the daemon's own log:

ERROR dify-plugin-daemon factory.go:28 PluginDaemonInternalServerError error="killed by timeout"

Many people hit this generic message and it gets mixed up with other causes, for example #760 (a stream that never closes) and #371 / #290. A run that really is long and a run that hangs look identical from the Dify side.

To Reproduce

  1. Self-hosted docker-compose with default plugin daemon settings (PLUGIN_MAX_EXECUTION_TIMEOUT=600).
  2. Create a workflow Start → Agent (Function Calling, Maximum Iterations 30) → End. Give the Agent one API tool that takes 50 s per call, and a model that keeps calling the tool, about 22 calls (~18 minutes in total). Every individual model and tool call is well under its own per-call timeout.
  3. Run the workflow through the API in streaming mode.
  4. The Agent node fails at 600.2 s with PluginDaemonInternalServerError: Internal Server Error. The daemon log shows killed by timeout.
  5. Set PLUGIN_MAX_EXECUTION_TIMEOUT=2400 on the plugin daemon, restart it and run the same workflow again: it succeeds in 1101 s.

Expected behavior

  • When the execution timer fires, return a timeout-specific error type and message that the API can pass on to the user. For example: plugin execution exceeded PLUGIN_MAX_EXECUTION_TIMEOUT (600s). A client disconnect or a real internal error would keep its own type.
  • Document, next to PLUGIN_MAX_EXECUTION_TIMEOUT in the env examples, that it also limits the total runtime of an Agent node (the whole agent strategy run), so long-running agents need it raised.

Screenshots

N/A

Additional context

The test used a mock OpenAI-compatible model endpoint and a mock HTTP tool, so model latency was not a factor. Raising only this one setting moved the cut-off, which confirms it is the limit that applies.

Dominant language
Go
Stars
462
Forks
326
Avg merge
22h 15m
Merged PRs (30d)
8

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from langgenius/dify-plugin-daemon

All issues in langgenius/dify-plugin-daemon

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.