Skip to content

AIチャットの応答言語仕様を直近のユーザ発話に合わせる形へ更新 - #6507

Merged
TinyKitten merged 4 commits into
devfrom
claude/ai-chat-language-detection-ofr0yt
Aug 1, 2026
Merged

TinyKitten merged 4 commits into
devfrom
claude/ai-chat-language-detection-ofr0yt

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

概要

AI チャット(行き先提案エージェント)の応答言語の仕様を、端末の言語設定追従から「直近のユーザ発話の言語に合わせる」へ改める。英語端末で日本語を打っても英語で返ってきていたため。

判定はサーバ側のシステムプロンプトでモデルに行わせる方針とし、アプリ側には言語判定を持たせない。そのためこの PR はドキュメントのみの変更で、アプリのコード変更はない。実装は BFF 側(TrainLCD/BFF#38)で行う。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • docs/spec/ai-agent/architecture.md の「多言語対応」節を更新。エージェント応答言語は直近のユーザ発話と同じ言語に合わせ、指示はシステムプロンプトの出力規約で行う(クライアントは言語判定をしない)ことを明記
  • 同節に locale の役割を 2 つに限定して記載。(1) モデルが入力言語を判別できないときの既定言語のヒント、(2) サーバ生成の定型文(トピックゲートの謝絶文、モデル出力が空だったときのフォールバック文)の言語選択
  • 429(レート制限)の文言は上記に含まれないことを明記。サーバの 429 応答本文は機械可読なエラーメッセージのみで、表示文言はクライアントの translate('destinationAgentRateLimited')(端末の言語設定に従う)。エラー処理表の 429 行も実装に合わせて修正
  • リクエスト仕様の locale フィールドの説明を上記に合わせて修正(従来は「応答言語の指示に使う」)
  • 「応答の構造化と実在性保証」節に reply の言語規約を追記

locale のワイヤ形式は従来どおり ja | en で変更なし。アプリ側の送信ロジック(src/hooks/useDestinationAgent.ts)も現状のまま。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

省略: コード変更なし(ドキュメントのみ)。markdownlint-cli2 はクリーン。

関連Issue

スクリーンショット(任意)

@TinyKitten TinyKitten self-assigned this Aug 1, 2026
@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

AIエージェントの言語選択仕様を更新しました。通常の応答は直近のユーザー発話の言語で生成します。localeは判定不能時の既定言語と、サーバ生成定型文の言語選択に使用します。

Changes

言語選択ポリシー

Layer / File(s) Summary
localeと応答言語の規約更新
docs/spec/ai-agent/architecture.md
localeを応答言語の直接指定から既定言語へ変更しました。通常のreplyは直近のユーザー発話と同じ言語で生成します。
サーバ生成定型文の言語選択
docs/spec/ai-agent/architecture.md
トピックゲート謝絶文やレート制限メッセージなどの定型文では、localeを言語選択に使用します。クライアント側では言語判定を行いません。

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

  • TrainLCD/BFF issue 37 — 同じlocaleの意味変更と、ユーザー入力を基準にした応答言語を扱っています。

Poem

うさぎが仕様をぴょんと更新
発話の言葉で返事を生成
localeは迷子の時の道しるべ
定型文にも言葉を添えて
月夜の設計、すっきり整理 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed タイトルは、AIチャットの応答言語を直近のユーザ発話に合わせる仕様変更を明確に示しています。
Description check ✅ Passed 概要、変更内容、変更種別、テスト方針、関連Issueを記載しており、ドキュメント変更の目的と範囲を十分に説明しています。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/ai-chat-language-detection-ofr0yt

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/spec/ai-agent/architecture.md`:
- Around line 746-754: エラー処理表の429レート制限メッセージを、`locale`
に応じてサーバ生成定型文を選択する仕様と一致させてください。該当する429メッセージの記載を`locale`対応の表現へ更新するか、日本語が例示であることを明記し、直近の言語仕様と矛盾しない内容にしてください。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9b11c908-af52-4228-b610-02eac5ee514c

📥 Commits

Reviewing files that changed from the base of the PR and between a240506 and ee577a2.

📒 Files selected for processing (1)
  • docs/spec/ai-agent/architecture.md

Comment thread docs/spec/ai-agent/architecture.md Resolved
@TinyKitten
TinyKitten merged commit 2f666ac into dev Aug 1, 2026
3 checks passed
@TinyKitten
TinyKitten deleted the claude/ai-chat-language-detection-ofr0yt branch August 1, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants