Skip to content

feat(ai): make the user's language explicit in the agent system prompt#2314

Merged
os-zhuang merged 1 commit into
mainfrom
fix/ai-explicit-user-language
Jun 25, 2026
Merged

feat(ai): make the user's language explicit in the agent system prompt#2314
os-zhuang merged 1 commit into
mainfrom
fix/ai-explicit-user-language

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

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").

AgentRuntime now detects the user's language from their latest message (detectUserLanguage in agent-routes) and states it explicitly in the agent system prompt via AgentChatContext.userLanguage, requiring all generated labels to be written in it. This mirrors the existing autoPublishAiBuilds context 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 generateObject call that doesn't see the agent prompt; labels there are fixed in cloud#499 (the propose_blueprint prompt). The two together cover both paths.

Verification

  • New agent-runtime-user-language.test.ts — the directive is injected (naming the language) when userLanguage is set, omitted otherwise. 2/2.
  • Detection claims only non-Latin scripts (CJK/Cyrillic/Arabic); Latin-script languages are left to the model (matched well, unreliable to detect by script).

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 25, 2026 3:11am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/m labels Jun 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): packages/services.

5 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/guides/packages.mdx (via packages/services)
  • content/docs/guides/runtime-services/audit-service.mdx (via packages/services)
  • content/docs/guides/runtime-services/index.mdx (via packages/services)
  • content/docs/guides/runtime-services/settings-service.mdx (via packages/services)
  • content/docs/protocol/objectos/i18n-standard.mdx (via packages/services)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang merged commit 4a242ad into main Jun 25, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the fix/ai-explicit-user-language branch June 25, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant