fix(web): use chat mode for agent prompt generation#38566
Open
han-dreamer wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
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-generateinstead of the app mode (agent-chat).agent-chatis an app mode, butmodel_config.modeis validated by the backend as an LLM mode and only acceptschatorcompletion. In a fresh session without a stored auto-generation model, Agent apps currently initialize the auto-generation model withagent-chat, which causes/rule-generateto 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:
completionremainscompletion, while Agent/basic chat-style prompt generation useschat. Stored auto-generation model settings are still preserved when present.A regression test was added for
AppModeEnum.AGENT_CHATbasic prompt generation to verify thatgenerateBasicAppFirstTimeRulereceivesmodel_config.modeaschat.Fixes #38539.
From Codex
Screenshots
/rule-generatereceivesmodel_config.mode: "agent-chat"in a fresh Agent app session and fails backend validation with HTTP 400./rule-generatereceivesmodel_config.mode: "chat"in a fresh Agent app session and can pass backend model mode validation.Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint godsNote: I added a focused regression test in
web/app/components/app/configuration/config/automatic/__tests__/get-automatic-res.spec.tsxand verifiedgit diff --checklocally. I attempted to run the focused frontend test withpnpm -C web test app/components/app/configuration/config/automatic/__tests__/get-automatic-res.spec.tsx, but local dependency bootstrap could not complete becausepnpm installrepeatedly timed out while downloading registry tarballs.