Contract at server dev 2fd3c03: the tree frame, and a subagent asking
CI / check (push) Canceled after 0s

The server's /api/v2 now carries the 3.4.0 subagents (2fd3c03):
- the stream's `tree` frame {tree} (event_tree.json): LiveReply keeps it,
  ChatState keeps the last one after the reply ends (cleared when another
  chat opens), and the activity sheet draws it as the reduced list. The
  provisional `Activity.tree` is gone -- the tree never came that way.
- an ask item's `subagent {id, name, position}` (event_ask.json card4): the
  approval names it with the page's sentence ("Subagent parser (s1),
  reviews the parser, asks:"), translated from the server's catalogue.
- an agent chat's `subagents.offered` is true where the instance allows
  them (chat_agent.json): the Subagents setting shows for an existing agent
  chat by the chat's own word.

ContractTest: the tree frame, the subagent's card; the agent chat offered.
Screenshot 24-approval-subagent; 26-subagents from the tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Opus 5.5 committed 2026-11-10 10:01:22 +00:00
1 parent 3e1c320b00
commit 415dc653c3
24 files changed
+239 -62

No files matched your search

@@ -2,6 +2,7 @@ package eu.llembas.android
import eu.llembas.android.api.APP_API
import eu.llembas.android.api.AskFrame
import eu.llembas.android.api.CardSubagent
import eu.llembas.android.api.Chat
import eu.llembas.android.api.ChatPage
import eu.llembas.android.api.DoneFrame
@@ -18,6 +19,7 @@ import eu.llembas.android.api.SteeredFrame
import eu.llembas.android.api.StepsFrame
import eu.llembas.android.api.Tail
import eu.llembas.android.api.ToolCall
import eu.llembas.android.api.TreeFrame
import eu.llembas.android.ui.chat.approvalTexts
import kotlinx.serialization.KSerializer
import kotlinx.serialization.builtins.ListSerializer
@@ -137,7 +139,7 @@ class ContractTest {
fun aDeviceApprovalCorrectsItsDetail() {
// A device's approval: the heading in `title`, the command in `detail` -- the text an
// `editable` item corrects -- no "Something else", and the subagent asking in `job`.
val approval = read("event_ask", AskFrame.serializer()).cards.single { it.kind == "approval" }
val approval = read("event_ask", AskFrame.serializer()).cards.first { it.kind == "approval" }
val item = approval.items.single()
assertEquals("Run a command", item.title)
assertEquals("rm -rf build", item.detail)
@@ -163,12 +165,36 @@ class ContractTest {
assertNull(chat.subagents)
assertEquals(4, chat.agents?.max)
assertFalse(page.more)
// The agent chat's own facts: not offered (its subagents run on its device), the cap said.
// The agent chat's own facts (3.4.0): offered -- the setting goes to its device -- the cap said.
val agent = read("chat_agent", Chat.serializer())
assertEquals(false, agent.subagents?.offered)
assertEquals(true, agent.subagents?.offered)
assertEquals(32, agent.subagents?.cap)
}
@Test
fun aTreeSubagentAsksThePerson() {
// A device's subagent asks for what nobody in its tree may allow: the card names it.
val cards = read("event_ask", AskFrame.serializer()).cards
val item = cards.single { c -> c.items.any { it.subagent != null } }.items.single()
assertEquals(CardSubagent(id = "s1", name = "parser", position = "reviews the parser"), item.subagent)
assertEquals("git push", item.detail)
assertEquals("", item.job)
assertNull(cards.first().items.single().subagent)
}
@Test
fun theTreeFrame() {
val tree = read("event_tree", TreeFrame.serializer()).tree!!
assertEquals(1, tree.openSlots)
assertEquals(listOf("lead", "parser"), tree.agents.map { it.name })
assertEquals("Review src/parse.ts.", tree.agents[1].task)
assertEquals(6, tree.agents[1].contextPercent)
assertEquals("done", tree.ended.single().state)
assertNull(tree.ended.single().progress)
// The stream carries it; the reply keeps it.
assertEquals(tree, LiveReply("m").apply("tree", text("event_tree")).tree)
}
@Test
fun everyFrameParses() {
assertTrue(read("event_steps", StepsFrame.serializer()).steps.isNotEmpty())
@@ -177,7 +203,7 @@ class ContractTest {
assertEquals("Bake lembas", read("event_plan", Plan.serializer()).title)
assertTrue(read("event_status", StatusFrame.serializer()).text.isNotEmpty())
val cards = read("event_ask", AskFrame.serializer()).cards
assertEquals(listOf("question", "approval", "plan"), cards.map { it.kind })
assertEquals(listOf("question", "approval", "plan", "approval"), cards.map { it.kind })
assertEquals(listOf("Honey", "Plain"), cards[0].items[0].options.map { it.label })
assertTrue(cards[1].items[0].editable)
assertNotNull(cards[2].items[0].plan)
@@ -43,8 +43,8 @@ class SubagentsTest {
val chat = read("chat", Chat.serializer())
assertEquals(SubagentsOffer(offered = true, namedOnly = false, cap = 32), chat.subagents)
val agentChat = read("chat_agent", Chat.serializer())
// An agent chat is never offered subagents by the server (they run on its device); the cap is said.
assertEquals(SubagentsOffer(offered = false, cap = 32), agentChat.subagents)
// An agent chat is offered subagents (3.4.0): its device runs them, the setting goes down.
assertEquals(SubagentsOffer(offered = true, cap = 32), agentChat.subagents)
val activity = read("activity", ActivityEnvelope.serializer()).activity
assertEquals(true, activity.subagentsOffered)
@@ -203,41 +203,39 @@ object Fakes {
)
/**
* The activity sheet of a chat with subagents (spec 3.4.0's tree): the main agent, a
* The subagent tree beside the activity sheet (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"),
val 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),
),
ended = listOf(
TreeAgent(
id = "s2",
name = "scout",
position = "finds the old parser",
parent = "lead",
state = "out_of_context",
ended = 1762790300000,
findings = 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,
),
),
)
@@ -175,7 +175,9 @@ class ScreenShots {
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) } }
val tree: @Composable () -> Unit = {
SheetOver { ActivityContent(Fakes.activity, readAt = 0, now = 0, actions = NoActivityActions, tree = Fakes.tree) }
}
shoot("26-subagents", Phone.Scroll, content = tree)
shoot("26-subagents", Phone.Small, fontScale = 1.5f, content = tree)
shoot("16-activity-new-chat") {
@@ -216,9 +218,11 @@ class ScreenShots {
fun cards() {
val frame = requireNotNull(javaClass.classLoader!!.getResource("event_ask.json")).readText()
val cards = eu.llembas.android.api.LembasJson.decodeFromString(eu.llembas.android.api.AskFrame.serializer(), frame).cards
val approval = cards.single { it.kind == "approval" }
val approval = cards.first { it.kind == "approval" }
val fromSubagent = cards.first { it.kind == "approval" && it.items.any { item -> item.subagent != null } }
val question = cards.first { it.kind == "question" }
shoot("24-approval") { SheetOver { CardSheet(approval, onAnswer = {}) } }
shoot("24-approval-subagent") { SheetOver { CardSheet(fromSubagent, onAnswer = {}) } }
shoot("24-approval", Phone.Small, fontScale = 1.5f) { SheetOver { CardSheet(approval, onAnswer = {}) } }
shoot("25-question") { SheetOver { CardSheet(question, onAnswer = {}) } }
}