feat(ai): make the user's language explicit in the agent system prompt#2314
Merged
Conversation
Agents were only told to 'answer in the same language' (inferred), which produced English labels on non-English apps via the granular authoring path. AgentRuntime now detects the user's language from their latest message and states it explicitly in the system prompt (AgentChatContext.userLanguage), requiring generated labels in it — mirroring the autoPublish context block. Blueprint labels are fixed separately in service-ai-studio's propose_blueprint prompt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 5 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
What
The build/ask agents were only told "answer in the same language the user is using" — left to infer the language. On the granular authoring path this produced English labels on non-English apps, which then broke same-language object resolution on later turns ("给活动加按钮" couldn't map "活动" → an object labelled "Activity").
AgentRuntimenow detects the user's language from their latest message (detectUserLanguagein agent-routes) and states it explicitly in the agent system prompt viaAgentChatContext.userLanguage, requiring all generated labels to be written in it. This mirrors the existingautoPublishAiBuildscontext block.Scope (honest)
This covers the agent system prompt — i.e. the granular authoring path and the agent's own reasoning. Whole-app blueprints are generated by a separate internal
generateObjectcall that doesn't see the agent prompt; labels there are fixed in cloud#499 (thepropose_blueprintprompt). The two together cover both paths.Verification
agent-runtime-user-language.test.ts— the directive is injected (naming the language) whenuserLanguageis set, omitted otherwise. 2/2.🤖 Generated with Claude Code