Subagents (spec 3.4.0): the reduced list, coded to subagents.md §12
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
Android's share of the tree (§12): a row per agent -- name (id) and position, the state word (loop.json team.read.states), the progress text without the clock, context % (floor(used x 100 / window), as team_read writes it) -- the main agent first, sub-managers' subagents indented under them, the ended ones after, dimmed, and the open slots. A subagent's row opens its conversation read-only through the agent route as a member, by name; the main agent's is the chat. The server has the tree (services/team.py tree_info, 98f053a) but no /api/v2 shape for it yet: the app reads it as `tree` in the activity (`Activity.tree`, null until the server sends it, and then the Tasks section leaves the team members to the list). To be re-pinned and wired to the real field when the server's fixture lands. TreeTest (the §12 example), screenshot 26-subagents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
19 files changed
+431
-1
No files matched your search
@@ -49,6 +49,12 @@ is in alpha and releases come off `main`.
|
||||
second (`· 1m 05s`). The same in the assistant's sheet. A server that does not send it yet
|
||||
is shown as before.
|
||||
|
||||
- **Subagents, as a list** (the server's subagent tree, once it sends one): the activity sheet
|
||||
shows the main agent and each subagent -- its name, its position, what it is doing now and
|
||||
how full its context is -- with the ones that ended after them, dimmed, saying how each ended
|
||||
(*done*, *out of context*, *stopped*), and the open slots. A subagent's row opens its
|
||||
conversation, read-only.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A corrected command on an approval runs as corrected.** A linked computer's approval card
|
||||
|
||||
@@ -104,4 +104,19 @@ object ActivityLogic {
|
||||
|
||||
/** A percentage as the server writes it: one decimal, none when it is whole. */
|
||||
fun percent(value: Double): String = trim(String.format(Locale.ROOT, "%.1f", value))
|
||||
|
||||
/**
|
||||
* A tree subagent as the agent route knows it: a team member, by its name (`GET
|
||||
* /chats/{chat}/agents/member/{name}`), which is how the server reads a member's conversation.
|
||||
*/
|
||||
fun ofTreeAgent(agent: TreeAgent): ActivityAgent = ActivityAgent(
|
||||
kind = "member",
|
||||
id = agent.name,
|
||||
name = agent.name,
|
||||
role = agent.position,
|
||||
brief = agent.task,
|
||||
state = agent.state,
|
||||
model = agent.model,
|
||||
transcript = true,
|
||||
)
|
||||
}
|
||||
@@ -648,6 +648,11 @@ data class Activity(
|
||||
val context: ContextUse? = null,
|
||||
val outputs: List<Output> = emptyList(),
|
||||
val plan: JsonObject? = null,
|
||||
/**
|
||||
* The subagent tree (harness spec 3.4.0, `subagents.md` §12), where the server sends it;
|
||||
* null from an older one, which the Tasks section's team members stand for.
|
||||
*/
|
||||
val tree: SubagentTree? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package eu.llembas.android.api
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
|
||||
/**
|
||||
* A chat's subagent tree (harness spec 3.4.0, `subagents.md` §12): the main agent at the root,
|
||||
* every subagent under its parent, open slots, and the subagents that ended. [agents] are in
|
||||
* tree order. Android shows it as a reduced list (§12): name, position, state, the progress
|
||||
* line's text and context use, and opens a subagent's conversation read-only.
|
||||
*/
|
||||
@Serializable
|
||||
data class SubagentTree(
|
||||
val min: Int = 1,
|
||||
val max: Int = 1,
|
||||
val size: Int = 0,
|
||||
@SerialName("open_slots") val openSlots: Int = 0,
|
||||
val agents: List<TreeAgent> = emptyList(),
|
||||
val ended: List<TreeAgent> = emptyList(),
|
||||
)
|
||||
|
||||
/** One agent of the tree. [position], [task] and a progress `what` are a model's words: text only. */
|
||||
@Serializable
|
||||
data class TreeAgent(
|
||||
val id: String = "",
|
||||
val name: String = "",
|
||||
val position: String = "",
|
||||
val parent: String? = null,
|
||||
val state: String = "",
|
||||
val model: String = "",
|
||||
val mode: String = "",
|
||||
val request: List<String> = emptyList(),
|
||||
val manager: Boolean = false,
|
||||
val task: String = "",
|
||||
val context: TreeContext? = null,
|
||||
val progress: Progress? = null,
|
||||
val findings: Int = 0,
|
||||
/** How many of the room's messages are to or from it (a count; a newer server may say more). */
|
||||
val messages: JsonElement? = null,
|
||||
/** When it ended, Unix milliseconds; null while it lives. */
|
||||
val ended: Long? = null,
|
||||
) {
|
||||
val isMain: Boolean get() = parent == null
|
||||
|
||||
/** `floor(used × 100 / window)`, as the server's `team_read` writes it; null without a window. */
|
||||
val contextPercent: Int? get() = context?.takeIf { it.window > 0 }?.let { (it.used.toLong() * 100 / it.window).toInt() }
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class TreeContext(val used: Int = 0, val window: Int = 0)
|
||||
|
||||
/** One row of the reduced list: an agent and how deep it sits under the main agent. */
|
||||
data class TreeRow(val agent: TreeAgent, val depth: Int, val ended: Boolean)
|
||||
|
||||
object TreeLogic {
|
||||
/** The states a subagent ends in (`subagents.md` §9). */
|
||||
val ENDED = setOf("done", "out_of_context", "stopped")
|
||||
|
||||
/**
|
||||
* The rows to draw: the live agents in tree order, each as deep as its parent chain (the main
|
||||
* agent 0), then the ended ones, flat. A parent the tree does not hold (moved, ended) counts
|
||||
* as the main agent, so no row is lost or drawn deeper than it can be.
|
||||
*/
|
||||
fun rows(tree: SubagentTree): List<TreeRow> {
|
||||
val byName = tree.agents.associateBy { it.name }
|
||||
fun depth(agent: TreeAgent, seen: Set<String> = emptySet()): Int {
|
||||
val parent = agent.parent?.let { byName[it] } ?: return if (agent.parent == null) 0 else 1
|
||||
if (parent.name in seen) return 1
|
||||
return depth(parent, seen + agent.name) + 1
|
||||
}
|
||||
return tree.agents.map { TreeRow(it, depth(it), ended = false) } + tree.ended.map { TreeRow(it, 1, ended = true) }
|
||||
}
|
||||
|
||||
/** Whether there is anything to show beyond the main agent alone. */
|
||||
fun hasSubagents(tree: SubagentTree?): Boolean = tree != null && (tree.agents.any { !it.isMain } || tree.ended.isNotEmpty() || tree.openSlots > 0)
|
||||
}
|
||||
@@ -81,6 +81,7 @@ import eu.llembas.android.api.AgentDetail
|
||||
import eu.llembas.android.api.ContextUse
|
||||
import eu.llembas.android.api.Output
|
||||
import eu.llembas.android.api.RoomMessage
|
||||
import eu.llembas.android.api.TreeLogic
|
||||
import eu.llembas.android.lembas
|
||||
import eu.llembas.android.ui.MarkdownText
|
||||
import eu.llembas.android.ui.explain
|
||||
@@ -329,7 +330,18 @@ fun ActivityContent(
|
||||
}
|
||||
}
|
||||
}
|
||||
item { Section(stringResource(R.string.activity_tasks)) { TasksSection(activity, readAt, now, actions, unfolded) } }
|
||||
// 3.4.0: the subagents as a reduced list, each opening its conversation read-only;
|
||||
// the Tasks section then holds the background jobs, the members being in the list.
|
||||
val tree = activity.tree?.takeIf { TreeLogic.hasSubagents(it) }
|
||||
if (tree != null) {
|
||||
item {
|
||||
Section(stringResource(R.string.team_agents), count = tree.agents.count { !it.isMain }.takeIf { it > 0 }) {
|
||||
SubagentList(tree) { agent -> actions.read(ActivityLogic.ofTreeAgent(agent)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
val tasks = if (tree != null) activity.copy(agents = activity.agents.filter { it.kind != "member" }) else activity
|
||||
item { Section(stringResource(R.string.activity_tasks)) { TasksSection(tasks, readAt, now, actions, unfolded) } }
|
||||
activity.team?.let { team ->
|
||||
item { Section(stringResource(R.string.team_room), count = team.room.size.takeIf { it > 0 }) { RoomSection(team) } }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package eu.llembas.android.ui.chat
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.llembas.android.R
|
||||
import eu.llembas.android.api.SubagentTree
|
||||
import eu.llembas.android.api.TreeAgent
|
||||
import eu.llembas.android.api.TreeLogic
|
||||
import eu.llembas.android.api.TreeRow
|
||||
import eu.llembas.android.ui.progressLineOf
|
||||
import eu.llembas.android.ui.theme.LocalPalette
|
||||
import eu.llembas.android.ui.theme.Palette
|
||||
|
||||
/**
|
||||
* The subagents as Android shows them (harness spec 3.4.0, `subagents.md` §12, the reduced
|
||||
* list): each row its name and id, its position, its state, what it is doing now (the progress
|
||||
* text, without the clock -- a row has no room) and how full its context is. The main agent
|
||||
* first; ended subagents after the live ones, dimmed, with how each ended. A subagent's row opens
|
||||
* its conversation, read-only ([onOpen]); the main agent's conversation is the chat itself.
|
||||
*/
|
||||
@Composable
|
||||
fun SubagentList(tree: SubagentTree, onOpen: (TreeAgent) -> Unit) {
|
||||
val palette = LocalPalette.current
|
||||
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
Text(
|
||||
stringResource(R.string.team_size, tree.size.toString(), tree.max.toString()),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = palette.inkMuted,
|
||||
)
|
||||
TreeLogic.rows(tree).forEach { row -> TreeRowItem(row, onOpen) }
|
||||
if (tree.openSlots > 0) {
|
||||
Text(
|
||||
stringResource(R.string.tree_open_slots, tree.openSlots.toString()),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = palette.inkFaint,
|
||||
modifier = Modifier.padding(start = 16.dp, top = 4.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One row, two lines on a fixed frame: the name and position give way (cut, not wrapped) to the
|
||||
* state word; the progress text gives way to the context percentage in a column of its own width.
|
||||
*/
|
||||
@Composable
|
||||
private fun TreeRowItem(row: TreeRow, onOpen: (TreeAgent) -> Unit) {
|
||||
val palette = LocalPalette.current
|
||||
val agent = row.agent
|
||||
val opens = !agent.isMain
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 48.dp)
|
||||
.then(if (opens) Modifier.clickable { onOpen(agent) } else Modifier)
|
||||
.alpha(if (row.ended) 0.6f else 1f)
|
||||
.padding(start = (16 * row.depth.coerceIn(0, 4)).dp, top = 6.dp, bottom = 6.dp),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
val title = if (agent.isMain) agent.name else "${agent.name} (${agent.id})"
|
||||
Text(
|
||||
listOf(title, agent.position).filter { it.isNotBlank() }.joinToString(" — "),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
Text(
|
||||
treeStateWord(agent.state),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = treeStateColour(palette, agent.state),
|
||||
maxLines = 1,
|
||||
modifier = Modifier.padding(start = 8.dp),
|
||||
)
|
||||
}
|
||||
val doing = if (row.ended) null else progressLineOf(agent.progress, withElapsed = false)
|
||||
val percent = agent.contextPercent
|
||||
if (doing != null || percent != null) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
doing.orEmpty(),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = palette.inkMuted,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
Text(
|
||||
percent?.let { stringResource(R.string.tree_context, it.toString()) }.orEmpty(),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = palette.inkFaint,
|
||||
textAlign = TextAlign.End,
|
||||
maxLines = 1,
|
||||
modifier = Modifier.width(88.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The state's word (`loop.json` `team.read.states`), the main agent's and every subagent's. */
|
||||
@Composable
|
||||
private fun treeStateWord(state: String): String = when (state) {
|
||||
"working" -> stringResource(R.string.tree_state_working)
|
||||
"waiting" -> stringResource(R.string.tree_state_waiting)
|
||||
"finished" -> stringResource(R.string.tree_state_finished)
|
||||
"idle" -> stringResource(R.string.tree_state_idle)
|
||||
"paused" -> stringResource(R.string.tree_state_paused)
|
||||
"done" -> stringResource(R.string.tree_state_done)
|
||||
"out_of_context" -> stringResource(R.string.tree_state_out_of_context)
|
||||
"stopped" -> stringResource(R.string.tree_state_stopped)
|
||||
else -> state
|
||||
}
|
||||
|
||||
private fun treeStateColour(palette: Palette, state: String): Color = when (state) {
|
||||
"working" -> palette.accent
|
||||
"waiting", "paused" -> palette.warning
|
||||
"done", "finished" -> palette.success
|
||||
"out_of_context" -> palette.danger
|
||||
else -> palette.inkFaint
|
||||
}
|
||||
@@ -224,6 +224,9 @@
|
||||
<string name="card_send">Odeslat</string>
|
||||
<string name="progress_thinking">Přemýšlí</string>
|
||||
<string name="progress_stopped">Zastaveno</string>
|
||||
<string name="tree_state_working">pracuje</string>
|
||||
<string name="tree_state_done">hotovo</string>
|
||||
<string name="tree_state_stopped">zastaveno</string>
|
||||
<string name="card_asker">%1$s se ptá:</string>
|
||||
<string name="card_it_says">Model uvádí: %1$s</string>
|
||||
<string name="card_change_before">Upravit to před spuštěním</string>
|
||||
|
||||
@@ -224,6 +224,9 @@
|
||||
<string name="card_send">Senden</string>
|
||||
<string name="progress_thinking">Denkt nach</string>
|
||||
<string name="progress_stopped">Angehalten</string>
|
||||
<string name="tree_state_working">arbeitet</string>
|
||||
<string name="tree_state_done">fertig</string>
|
||||
<string name="tree_state_stopped">angehalten</string>
|
||||
<string name="card_asker">%1$s fragt:</string>
|
||||
<string name="card_it_says">Es sagt: %1$s</string>
|
||||
<string name="card_change_before">Vor dem Ausführen ändern</string>
|
||||
|
||||
@@ -224,6 +224,9 @@
|
||||
<string name="card_send">Enviar</string>
|
||||
<string name="progress_thinking">Pensando</string>
|
||||
<string name="progress_stopped">Detenido</string>
|
||||
<string name="tree_state_working">trabajando</string>
|
||||
<string name="tree_state_done">terminado</string>
|
||||
<string name="tree_state_stopped">detenido</string>
|
||||
<string name="card_asker">%1$s pregunta:</string>
|
||||
<string name="card_it_says">Dice: %1$s</string>
|
||||
<string name="card_change_before">Cambiar esto antes de que se ejecute</string>
|
||||
|
||||
@@ -224,6 +224,9 @@
|
||||
<string name="card_send">Envoyer</string>
|
||||
<string name="progress_thinking">Réflexion</string>
|
||||
<string name="progress_stopped">Arrêté</string>
|
||||
<string name="tree_state_working">au travail</string>
|
||||
<string name="tree_state_done">terminé</string>
|
||||
<string name="tree_state_stopped">arrêté</string>
|
||||
<string name="card_asker">%1$s demande :</string>
|
||||
<string name="card_it_says">Il dit : %1$s</string>
|
||||
<string name="card_change_before">Modifier ceci avant l\'exécution</string>
|
||||
|
||||
@@ -224,6 +224,9 @@
|
||||
<string name="card_send">Küldés</string>
|
||||
<string name="progress_thinking">Gondolkodás</string>
|
||||
<string name="progress_stopped">Leállítva</string>
|
||||
<string name="tree_state_working">dolgozik</string>
|
||||
<string name="tree_state_done">kész</string>
|
||||
<string name="tree_state_stopped">leállítva</string>
|
||||
<string name="card_asker">%1$s kérdezi:</string>
|
||||
<string name="card_it_says">Ezt mondja: %1$s</string>
|
||||
<string name="card_change_before">Módosítás futtatás előtt</string>
|
||||
|
||||
@@ -224,6 +224,9 @@
|
||||
<string name="card_send">Invia</string>
|
||||
<string name="progress_thinking">Ragionamento</string>
|
||||
<string name="progress_stopped">Fermato</string>
|
||||
<string name="tree_state_working">al lavoro</string>
|
||||
<string name="tree_state_done">finito</string>
|
||||
<string name="tree_state_stopped">interrotto</string>
|
||||
<string name="card_asker">%1$s chiede:</string>
|
||||
<string name="card_it_says">Dice: %1$s</string>
|
||||
<string name="card_change_before">Modificalo prima che venga eseguito</string>
|
||||
|
||||
@@ -224,6 +224,9 @@
|
||||
<string name="card_send">Wyślij</string>
|
||||
<string name="progress_thinking">Rozumowanie</string>
|
||||
<string name="progress_stopped">Zatrzymano</string>
|
||||
<string name="tree_state_working">pracuje</string>
|
||||
<string name="tree_state_done">gotowe</string>
|
||||
<string name="tree_state_stopped">zatrzymane</string>
|
||||
<string name="card_asker">%1$s pyta:</string>
|
||||
<string name="card_it_says">Mówi: %1$s</string>
|
||||
<string name="card_change_before">Zmień to przed uruchomieniem</string>
|
||||
|
||||
@@ -224,6 +224,9 @@
|
||||
<string name="card_send">Poslať</string>
|
||||
<string name="progress_thinking">Premýšľa</string>
|
||||
<string name="progress_stopped">Zastavené</string>
|
||||
<string name="tree_state_working">pracuje</string>
|
||||
<string name="tree_state_done">hotovo</string>
|
||||
<string name="tree_state_stopped">zastavené</string>
|
||||
<string name="card_asker">%1$s sa pýta:</string>
|
||||
<string name="card_it_says">Model uvádza: %1$s</string>
|
||||
<string name="card_change_before">Upraviť to pred spustením</string>
|
||||
|
||||
@@ -252,6 +252,16 @@
|
||||
<string name="progress_stopped_steps">step limit</string>
|
||||
<string name="progress_stopped_budget">budget</string>
|
||||
<string name="progress_line">%1$s · %2$s</string>
|
||||
<string name="tree_state_working">working</string>
|
||||
<string name="tree_state_waiting">waiting for a slot</string>
|
||||
<string name="tree_state_finished">finished</string>
|
||||
<string name="tree_state_idle">idle</string>
|
||||
<string name="tree_state_paused">paused: context full</string>
|
||||
<string name="tree_state_done">done</string>
|
||||
<string name="tree_state_out_of_context">out of context</string>
|
||||
<string name="tree_state_stopped">stopped</string>
|
||||
<string name="tree_context">%1$s%% context</string>
|
||||
<string name="tree_open_slots">Open slots: %1$s</string>
|
||||
<string name="card_asker">%1$s asks:</string>
|
||||
<string name="card_it_says">It says: %1$s</string>
|
||||
<string name="card_change_before">Change this before it runs</string>
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package eu.llembas.android
|
||||
|
||||
import eu.llembas.android.api.ActivityLogic
|
||||
import eu.llembas.android.api.LembasJson
|
||||
import eu.llembas.android.api.SubagentTree
|
||||
import eu.llembas.android.api.TreeLogic
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/** The subagent tree (harness spec 3.4.0, `subagents.md` §12) and the reduced list's rows. */
|
||||
class TreeTest {
|
||||
/** §12's own example, with a sub-manager and one under it added. */
|
||||
private val tree = LembasJson.decodeFromString(
|
||||
SubagentTree.serializer(),
|
||||
"""
|
||||
{ "min": 1, "max": 4, "size": 3, "open_slots": 1,
|
||||
"agents": [
|
||||
{ "id": "lead", "name": "lead", "position": "the main agent", "parent": null, "state": "working",
|
||||
"model": "qwen-27b", "mode": "edit", "request": [], "manager": true,
|
||||
"context": { "used": 41200, "window": 131072 }, "progress": { "phase": "thinking", "since": 1762790400000 } },
|
||||
{ "id": "s1", "name": "parser", "position": "reviews the parser", "parent": "lead", "state": "working",
|
||||
"model": "qwen-27b", "mode": "manual", "request": ["write"], "manager": true, "task": "…",
|
||||
"context": { "used": 9100, "window": 131072 },
|
||||
"progress": { "phase": "running_tool", "since": 1762790401000, "tool": "read", "what": "src/parse.ts" },
|
||||
"findings": 2, "messages": 3 },
|
||||
{ "id": "s3", "name": "lexer", "position": "the lexer's tests", "parent": "parser", "state": "paused",
|
||||
"model": "qwen-27b", "mode": "manual", "request": [], "manager": false, "task": "…", "findings": 0, "messages": 0 }
|
||||
],
|
||||
"ended": [ { "id": "s0", "name": "scout", "position": "…", "parent": "lead", "state": "done", "ended": 1762790300000, "findings": 1 } ] }
|
||||
""",
|
||||
)
|
||||
|
||||
@Test
|
||||
fun theTreeReads() {
|
||||
assertEquals(1, tree.openSlots)
|
||||
val parser = tree.agents[1]
|
||||
assertEquals("s1", parser.id)
|
||||
assertEquals("running_tool", parser.progress?.phase)
|
||||
assertEquals(listOf("write"), parser.request)
|
||||
assertTrue(tree.agents[0].isMain)
|
||||
assertFalse(parser.isMain)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun contextIsFlooredAndNeedsAWindow() {
|
||||
assertEquals(31, tree.agents[0].contextPercent) // 41200 × 100 / 131072 = 31.43
|
||||
assertEquals(6, tree.agents[1].contextPercent)
|
||||
assertNull(tree.agents[2].contextPercent)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rowsInTreeOrderThenTheEnded() {
|
||||
val rows = TreeLogic.rows(tree)
|
||||
assertEquals(listOf("lead", "parser", "lexer", "scout"), rows.map { it.agent.name })
|
||||
assertEquals(listOf(0, 1, 2, 1), rows.map { it.depth })
|
||||
assertEquals(listOf(false, false, false, true), rows.map { it.ended })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aParentTheTreeDoesNotHoldIsTheMainAgents() {
|
||||
val moved = tree.copy(agents = tree.agents.map { if (it.name == "lexer") it.copy(parent = "gone") else it })
|
||||
assertEquals(1, TreeLogic.rows(moved).single { it.agent.name == "lexer" }.depth)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theMainAgentAloneIsNoList() {
|
||||
assertFalse(TreeLogic.hasSubagents(null))
|
||||
assertFalse(TreeLogic.hasSubagents(tree.copy(agents = tree.agents.take(1), ended = emptyList(), openSlots = 0)))
|
||||
assertTrue(TreeLogic.hasSubagents(tree.copy(agents = tree.agents.take(1), ended = emptyList(), openSlots = 2)))
|
||||
assertTrue(TreeLogic.hasSubagents(tree))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aSubagentOpensAsAMember() {
|
||||
val agent = ActivityLogic.ofTreeAgent(tree.agents[1])
|
||||
assertEquals("member", agent.kind)
|
||||
assertEquals("parser", agent.id)
|
||||
assertTrue(agent.transcript)
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,13 @@ import eu.llembas.android.api.ScheduleRun
|
||||
import eu.llembas.android.api.SchedulingModel
|
||||
import eu.llembas.android.api.SchedulingModels
|
||||
import eu.llembas.android.api.Step
|
||||
import eu.llembas.android.api.SubagentTree
|
||||
import eu.llembas.android.api.SubagentsOffer
|
||||
import eu.llembas.android.api.Tail
|
||||
import eu.llembas.android.api.ToolBlock
|
||||
import eu.llembas.android.api.ToolCall
|
||||
import eu.llembas.android.api.TreeAgent
|
||||
import eu.llembas.android.api.TreeContext
|
||||
import eu.llembas.android.assist.AssistTurn
|
||||
import eu.llembas.android.assist.AssistUiState
|
||||
import eu.llembas.android.assist.Connection
|
||||
@@ -199,6 +202,46 @@ object Fakes {
|
||||
live = writing.live!!.copy(progress = Progress(phase = "waiting_for_model", since = 1762790400000, model = "Qwen 27B", reason = "busy")),
|
||||
)
|
||||
|
||||
/**
|
||||
* The activity sheet of a chat with subagents (spec 3.4.0's tree): the main agent, a
|
||||
* sub-manager with one under it paused, one waiting for a slot, an open slot and one ended.
|
||||
*/
|
||||
val activityTree = activity.copy(
|
||||
tree = SubagentTree(
|
||||
min = 2,
|
||||
max = 5,
|
||||
size = 4,
|
||||
openSlots = 1,
|
||||
agents = listOf(
|
||||
TreeAgent(
|
||||
id = "lead", name = "lead", position = "the main agent", state = "working", model = "qwen", mode = "edit", manager = true,
|
||||
context = TreeContext(41_200, 131_072), progress = Progress(phase = "waiting_for_subagents", since = 1762790400000, running = 2),
|
||||
),
|
||||
TreeAgent(
|
||||
id = "s1", name = "parser", position = "reviews the parser and everything that reads its output", parent = "lead",
|
||||
state = "working", model = "qwen", mode = "edit", manager = true, context = TreeContext(9_100, 131_072),
|
||||
progress = Progress(phase = "running_tool", since = 1762790401000, tool = "read", what = "src/parse.ts"),
|
||||
),
|
||||
TreeAgent(
|
||||
id = "s3", name = "lexer", position = "the lexer's tests", parent = "parser", state = "paused",
|
||||
model = "qwen", mode = "manual", context = TreeContext(112_000, 131_072), progress = Progress(phase = "thinking", since = 1762790402000),
|
||||
),
|
||||
TreeAgent(id = "s4", name = "docs", position = "writes the changelog", parent = "lead", state = "waiting", model = "qwen", mode = "edit"),
|
||||
),
|
||||
ended = listOf(
|
||||
TreeAgent(
|
||||
id = "s2",
|
||||
name = "scout",
|
||||
position = "finds the old parser",
|
||||
parent = "lead",
|
||||
state = "out_of_context",
|
||||
ended = 1762790300000,
|
||||
findings = 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
/** A chat on a model with effort levels, a team and a plan: the tune sheet with everything. */
|
||||
val tuned = transcript.copy(
|
||||
chat = chat.copy(model = "gpt-oss", effort = "high", mode = "plan", agents = AgentsSetting(1, 4)),
|
||||
|
||||
@@ -174,6 +174,10 @@ class ScreenShots {
|
||||
shoot("14-activity", Phone.Small, fontScale = 1.5f, content = sheet)
|
||||
shoot("14-activity", Phone.Scroll, content = sheet)
|
||||
shoot("15-activity-open", Phone.Scroll, content = open)
|
||||
// Spec 3.4.0's subagents: the reduced list above the background tasks.
|
||||
val tree: @Composable () -> Unit = { SheetOver { ActivityContent(Fakes.activityTree, readAt = 0, now = 0, actions = NoActivityActions) } }
|
||||
shoot("26-subagents", Phone.Scroll, content = tree)
|
||||
shoot("26-subagents", Phone.Small, fontScale = 1.5f, content = tree)
|
||||
shoot("16-activity-new-chat") {
|
||||
SheetOver { ActivityContent(eu.llembas.android.api.Activity(), readAt = 0, now = 0, actions = NoActivityActions, canCompact = false) }
|
||||
}
|
||||
|
||||
@@ -271,6 +271,17 @@ STRINGS: dict[str, str] = {
|
||||
"progress_stopped_steps": "step limit",
|
||||
"progress_stopped_budget": "budget",
|
||||
"progress_line": "%1$s · %2$s",
|
||||
# The subagent tree (harness spec 3.4.0, subagents.md §12; loop.json team.read)
|
||||
"tree_state_working": "working",
|
||||
"tree_state_waiting": "waiting for a slot",
|
||||
"tree_state_finished": "finished",
|
||||
"tree_state_idle": "idle",
|
||||
"tree_state_paused": "paused: context full",
|
||||
"tree_state_done": "done",
|
||||
"tree_state_out_of_context": "out of context",
|
||||
"tree_state_stopped": "stopped",
|
||||
"tree_context": "%1$s%% context",
|
||||
"tree_open_slots": "Open slots: %1$s",
|
||||
"card_asker": "%1$s asks:",
|
||||
"card_it_says": "It says: %1$s",
|
||||
"card_change_before": "Change this before it runs",
|
||||
@@ -397,6 +408,7 @@ SERVER_ENGLISH: dict[str, str] = {
|
||||
"progress_failed": "Failed: {{reason}}",
|
||||
"progress_what_approval": "allow {{tool}}?",
|
||||
"progress_line": "{{text}} · {{elapsed}}",
|
||||
"tree_context": "{{percent}}% context",
|
||||
"card_asker": "%(job)s asks:",
|
||||
"card_it_says": "It says: %(purpose)s",
|
||||
"activity_used": "%(percent)s%% used",
|
||||
|
||||
Reference in new issue
Block a user