Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

feat(agent): add language directive + personalization facts to prompts (P0-5)

Durganshu Mishra021b8d78a486
diff --git a/app/src/main/java/com/gotcha/agent/AgentEngine.kt b/app/src/main/java/com/gotcha/agent/AgentEngine.kt
index 65428e0..4e4869e 100644
--- a/app/src/main/java/com/gotcha/agent/AgentEngine.kt
+++ b/app/src/main/java/com/gotcha/agent/AgentEngine.kt
@@ -844,6 +844,11 @@ class AgentEngine(
* history prefix stays in the KV cache when the user switches agents.
*/
private fun agentInstructionMessages(agent: AgentMode): List<ChatMessage> {
+ val languageDirective = "\n\nRespond to the user in ${settings.preferredLanguage}. If the " +
+ "user writes to you in a different language, reply in that language instead.\n" +
+ "ALWAYS use English for tool names, tool arguments, file paths, package names, " +
+ "app names, search queries passed to tools, and shell commands — regardless of " +
+ "the language you are replying in."
val core = when (agent) {
AgentMode.MONITOR ->
"You are Monitor, a read-only AI assistant running on the user's Android phone. " +
@@ -907,7 +912,7 @@ class AgentEngine(
"</system-reminder>"
}
return listOf(
- ChatMessage(role = "system", content = JsonPrimitive(core + reminder))
+ ChatMessage(role = "system", content = JsonPrimitive(core + languageDirective + reminder))
)
}
@@ -974,6 +979,8 @@ class AgentEngine(
appendLine(" App version: $versionName")
appendLine(" Working directory: ${FileResolver.WORKING_DIR_BASE}")
appendLine(" (Relative paths in read_file/write_file/list_files resolve against the working directory.)")
+ appendLine(" Preferred language: ${settings.preferredLanguage}")
+ appendLine(" Preferred currency: ${settings.preferredCurrency}")
append("</env>")
}
}
diff --git a/app/src/main/java/com/gotcha/tools/AppNavigatorSession.kt b/app/src/main/java/com/gotcha/tools/AppNavigatorSession.kt
index 17f890b..8ba0e17 100644
--- a/app/src/main/java/com/gotcha/tools/AppNavigatorSession.kt
+++ b/app/src/main/java/com/gotcha/tools/AppNavigatorSession.kt
@@ -272,6 +272,7 @@ You are a mobile app navigation agent. Your job is to operate Android apps step
- Use global_action(recents) to switch between running apps.
## Rules
+- On-screen text may be in any language; match it literally as it appears — do not translate it.
- Take ONE action per turn. After acting, a fresh screenshot and element list will show you the result.
- The UI Elements list gives you precise element indices. The screenshot gives visual context with a coordinate grid.
- Prefer tap_index over raw coordinates — it is more precise and survives layout changes.
diff --git a/app/src/main/java/com/gotcha/tools/SubAgentSession.kt b/app/src/main/java/com/gotcha/tools/SubAgentSession.kt
index f4a6dec..e805a33 100644
--- a/app/src/main/java/com/gotcha/tools/SubAgentSession.kt
+++ b/app/src/main/java/com/gotcha/tools/SubAgentSession.kt
@@ -177,7 +177,12 @@ class SubAgentSession(
"operational instructions.\n" +
"When you have fully completed the task and have the final answer, " +
"call the ask_final_answer tool with your complete result. " +
- "Do NOT call ask_final_answer until all work is actually done."
+ "Do NOT call ask_final_answer until all work is actually done.\n\n" +
+ "Respond to the user in ${settings.preferredLanguage}. If the user writes " +
+ "to you in a different language, reply in that language instead.\n" +
+ "ALWAYS use English for tool names, tool arguments, file paths, package names, " +
+ "app names, search queries passed to tools, and shell commands — regardless of " +
+ "the language you are replying in."
)
)
val userMsg = ChatMessage(