Skip to content

fix(web): use chat mode for agent prompt generation#38566

Open
han-dreamer wants to merge 1 commit into
langgenius:mainfrom
han-dreamer:fix/agent-autogen-model-mode
Open

fix(web): use chat mode for agent prompt generation#38566
han-dreamer wants to merge 1 commit into
langgenius:mainfrom
han-dreamer:fix/agent-autogen-model-mode

Conversation

@han-dreamer

Copy link
Copy Markdown

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

This PR normalizes the initial model mode used by prompt auto-generation so Agent apps send an LLM mode (chat) to /rule-generate instead of the app mode (agent-chat).

agent-chat is an app mode, but model_config.mode is validated by the backend as an LLM mode and only accepts chat or completion. In a fresh session without a stored auto-generation model, Agent apps currently initialize the auto-generation model with agent-chat, which causes /rule-generate to fail with HTTP 400 before rule generation starts.

The fix maps the initial auto-generation model mode from the app mode to a valid LLM mode: completion remains completion, while Agent/basic chat-style prompt generation uses chat. Stored auto-generation model settings are still preserved when present.

A regression test was added for AppModeEnum.AGENT_CHAT basic prompt generation to verify that generateBasicAppFirstTimeRule receives model_config.mode as chat.

Fixes #38539.

From Codex

Screenshots

Before After
/rule-generate receives model_config.mode: "agent-chat" in a fresh Agent app session and fails backend validation with HTTP 400. /rule-generate receives model_config.mode: "chat" in a fresh Agent app session and can pass backend model mode validation.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Note: I added a focused regression test in web/app/components/app/configuration/config/automatic/__tests__/get-automatic-res.spec.tsx and verified git diff --check locally. I attempted to run the focused frontend test with pnpm -C web test app/components/app/configuration/config/automatic/__tests__/get-automatic-res.spec.tsx, but local dependency bootstrap could not complete because pnpm install repeatedly timed out while downloading registry tarballs.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 8, 2026
@github-actions github-actions Bot added the web This relates to changes on the web. label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Agent app prompt auto-generation sends app mode agent-chat as model_config.mode to /rule-generate

1 participant