Plan Agent targets before launching Genies

Teach the Agent runtime and UI to resolve target packages from installed apps and start one child Genie session per selected package, with an optional package override for debugging.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Iliyan Malchev
2026-03-19 11:22:33 -07:00
parent fa0c22441c
commit 3a5ab674f0
10 changed files with 415 additions and 137 deletions

View File

@@ -171,12 +171,8 @@ class MainActivity : Activity() {
}
fun startDirectAgentSession(@Suppress("UNUSED_PARAMETER") view: View) {
val targetPackage = findViewById<EditText>(R.id.agent_target_package).text.toString().trim()
val targetPackageOverride = findViewById<EditText>(R.id.agent_target_package).text.toString().trim()
val prompt = findViewById<EditText>(R.id.agent_prompt).text.toString().trim()
if (targetPackage.isEmpty()) {
showToast("Enter a target package")
return
}
if (prompt.isEmpty()) {
showToast("Enter a prompt")
return
@@ -184,9 +180,13 @@ class MainActivity : Activity() {
ensureCodexdRunningForAgent()
thread {
val result = runCatching {
val plan = AgentTaskPlanner.plan(
context = this,
userObjective = prompt,
targetPackageOverride = targetPackageOverride.ifBlank { null },
)
agentSessionController.startDirectSession(
targetPackage = targetPackage,
prompt = prompt,
plan = plan,
allowDetachedMode = true,
)
}
@@ -195,8 +195,9 @@ class MainActivity : Activity() {
refreshAgentSessions()
}
result.onSuccess { sessionStart ->
focusedFrameworkSessionId = sessionStart.childSessionId
showToast("Started ${sessionStart.childSessionId} via ${sessionStart.geniePackage}")
focusedFrameworkSessionId = sessionStart.childSessionIds.firstOrNull()
val targetSummary = sessionStart.plannedTargets.joinToString(", ")
showToast("Started ${sessionStart.childSessionIds.size} Genie session(s) for $targetSummary via ${sessionStart.geniePackage}")
refreshAgentSessions()
}
}