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.

fix: surface update_user_profile changes to the user to mitigate prompt injection

Rishabh Bajpai8153aa3e9071
diff --git a/app/src/main/java/com/gotcha/agent/ChatViewModel.kt b/app/src/main/java/com/gotcha/agent/ChatViewModel.kt
index ea21bac..c0560de 100644
--- a/app/src/main/java/com/gotcha/agent/ChatViewModel.kt
+++ b/app/src/main/java/com/gotcha/agent/ChatViewModel.kt
@@ -143,6 +143,18 @@ class ChatViewModel(application: Application) : AndroidViewModel(application), A
?: return@AgentEngine ToolResult.ok("No material change — profile left as is.")
settingsRepository.save(merged.updated)
settings = merged.updated
+ // Surface the change to the user: the profile is silently re-injected into every
+ // future prompt, so a prompt-injected update_user_profile call must not go
+ // unnoticed. A TOOL bubble in the transcript gives the user a chance to catch
+ // and revert a poisoned update. Dispatched to Main because this handler runs
+ // inside the tool executor's IO context while appendEngineUi touches UI state.
+ withContext(Dispatchers.Main) {
+ appendEngineUi(
+ MessageKind.TOOL,
+ "Assistant updated your profile: " +
+ merged.changedFields.joinToString(", ") + "."
+ )
+ }
ToolResult.ok(
"Updated " + merged.changedFields.joinToString(", ") + ". " +
"The new value will be used from the next message."