- ModelInfo.subagents, ModelList.subagents_cap, Chat.subagents {offered, named_only, cap},
Activity.subagents_offered, ContextUse.auto_compact/until_compact/compactable: all
optional, so an older server still parses and the app falls back to its old guess.
- The Subagents setting: shown by offered, the one-request note when named_only, sliders
from 1 to the cap (ticks up to 8), none at a cap of 1.
- Compact disabled when the server says there is nothing to compact yet.
- The context's number columns widen with the type (they touched at 1.5x).
- SubagentsTest; shots 07-tune-one-at-a-time and a tall 411x2000 for the activity sheet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
22 files changed
+248
-41
No files matched your search
+5
-1
@@ -9,7 +9,11 @@ is in alpha and releases come off `main`.
|
||||
|
||||
- **Subagents, by that name.** Everything the app says about the work a chat hands off now
|
||||
calls it a subagent -- the strip, the activity sheet and the chat's options. The team's size
|
||||
in Options is **Subagents**, fewest and most.
|
||||
in Options is **Subagents**, fewest and most -- shown when the instance says subagents are
|
||||
offered for the chat (or, for a new chat, for the model chosen), and only up to the most the
|
||||
instance allows. When the chat's model serves one request at a time, the setting says that
|
||||
subagents need another model, on another server, named in the chat. Which model a subagent
|
||||
runs on is not a setting: it is the chat's own, unless you name another in the chat.
|
||||
- **The activity sheet, laid out as a side panel is on a computer**, and always one tap away:
|
||||
the button at the top of every chat (a new one too) opens it as a sheet. **Context**: how
|
||||
much of the window is used, in per cent and in tokens of the window, a bar split by what
|
||||
|
||||
@@ -60,9 +60,13 @@ object ActivityLogic {
|
||||
/**
|
||||
* How many tokens are left before the chat compacts itself: the window's [ContextUse.threshold]
|
||||
* per cent, less what is used. Null when it never will -- the threshold is 0 (off) or 100,
|
||||
* or the window is unknown -- since a count against an unknown window is a guess.
|
||||
* or the window is unknown -- since a count against an unknown window is a guess. The
|
||||
* server's [ContextUse.untilCompact] and [ContextUse.autoCompact] win where it says them.
|
||||
*/
|
||||
fun untilAutoCompact(context: ContextUse): Int? {
|
||||
// The server's own count, where it gives one.
|
||||
if (context.autoCompact == false) return null
|
||||
context.untilCompact?.let { return it.coerceAtLeast(0) }
|
||||
if (context.limit <= 0 || context.threshold !in 1..99) return null
|
||||
return (context.limit.toLong() * context.threshold / 100 - context.used).toInt().coerceAtLeast(0)
|
||||
}
|
||||
|
||||
@@ -144,7 +144,10 @@ class ApiClient(val base: String, private val token: String, val http: OkHttpCli
|
||||
// --- Account -----------------------------------------------------------------------------
|
||||
suspend fun me(): Me = get("/me")
|
||||
|
||||
suspend fun models(chatId: String? = null): List<ModelInfo> = get<ModelList>(if (chatId != null) "/models?chat=$chatId" else "/models").models
|
||||
suspend fun models(chatId: String? = null): List<ModelInfo> = modelList(chatId).models
|
||||
|
||||
/** The models with the instance's subagent cap; with [chatId], whether each is offered subagents on that chat. */
|
||||
suspend fun modelList(chatId: String? = null): ModelList = get(if (chatId != null) "/models?chat=$chatId" else "/models")
|
||||
|
||||
suspend fun folders(): List<Folder> = get<FolderList>("/folders").folders
|
||||
|
||||
|
||||
@@ -95,6 +95,8 @@ data class ModelInfo(
|
||||
/** The picture's path on the instance (`/api/v2/models/images/…`), read with the token. */
|
||||
val image: String? = null,
|
||||
val default: Boolean = false,
|
||||
/** Whether a new chat on this model is offered subagents (server 2.0.0-beta.7); null from an older one. */
|
||||
val subagents: SubagentsOffer? = null,
|
||||
) {
|
||||
/**
|
||||
* The levels, for a server that says them; an older one said only `efforts`, offered after
|
||||
@@ -118,12 +120,12 @@ data class ModelInfo(
|
||||
val onLevel: String get() = offered.firstOrNull { it != "off" } ?: effort
|
||||
|
||||
/**
|
||||
* Whether a new chat on this model may have a team, as far as the app can tell: the model
|
||||
* serves two requests at once (`parallel` ≥ 2, or no stated limit) and takes tools. The
|
||||
* server also needs subagents on, which only an existing chat's activity says
|
||||
* (`team_offered`); a setting it does not use is kept and does nothing.
|
||||
* Whether a new chat on this model is offered subagents: the server's word
|
||||
* (`subagents.offered`) when it says it. An older server did not, and then the app guesses
|
||||
* from the model alone: it serves two requests at once (`parallel` ≥ 2, or no stated
|
||||
* limit) and takes tools.
|
||||
*/
|
||||
val mayHaveTeam: Boolean get() = tools && (parallel == null || parallel >= 2)
|
||||
val mayHaveTeam: Boolean get() = subagents?.offered ?: (tools && (parallel == null || parallel >= 2))
|
||||
|
||||
companion object {
|
||||
val CONTROLS = setOf("none", "switch", "slider")
|
||||
@@ -131,7 +133,20 @@ data class ModelInfo(
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ModelList(val models: List<ModelInfo> = emptyList())
|
||||
data class ModelList(
|
||||
val models: List<ModelInfo> = emptyList(),
|
||||
/** The instance's cap on a chat's subagents (server 2.0.0-beta.7); null from an older one. */
|
||||
@SerialName("subagents_cap") val subagentsCap: Int? = null,
|
||||
)
|
||||
|
||||
/**
|
||||
* Whether subagents are offered (harness spec 3.3.0, `subagents.md` §4): [offered] when
|
||||
* subagents are on and at least one model could serve; [namedOnly] when only a model the person
|
||||
* names in the chat could -- the chat's own serves one request at a time -- and the setting then
|
||||
* says so. [cap] is the instance's most, on a chat (not on a model).
|
||||
*/
|
||||
@Serializable
|
||||
data class SubagentsOffer(val offered: Boolean = false, @SerialName("named_only") val namedOnly: Boolean = false, val cap: Int? = null)
|
||||
|
||||
@Serializable
|
||||
data class Folder(val id: String, val name: String = "", @SerialName("parent_id") val parentId: String? = null, val kind: String = "", val position: Int = 0)
|
||||
@@ -172,6 +187,8 @@ data class Chat(
|
||||
val plan: JsonObject? = null,
|
||||
/** The team's size: how many agents, its own included, the chat may have. */
|
||||
val agents: AgentsSetting? = null,
|
||||
/** Whether this chat is offered subagents, and the cap (server 2.0.0-beta.7); null from an older one. */
|
||||
val subagents: SubagentsOffer? = null,
|
||||
) {
|
||||
val isAgent: Boolean get() = kind == "agent"
|
||||
}
|
||||
@@ -588,6 +605,14 @@ data class ContextUse(
|
||||
val percent: Double? = null,
|
||||
val measured: Boolean = false,
|
||||
val threshold: Int = 0,
|
||||
/**
|
||||
* The compaction facts (server 2.0.0-beta.7): whether the chat compacts by itself, how many
|
||||
* tokens before it does (null: never, or not known), and whether Compact can run now.
|
||||
* Null from an older server; the app then works the first two out from [threshold].
|
||||
*/
|
||||
@SerialName("auto_compact") val autoCompact: Boolean? = null,
|
||||
@SerialName("until_compact") val untilCompact: Int? = null,
|
||||
val compactable: Boolean? = null,
|
||||
@SerialName("tools_count") val toolsCount: Int = 0,
|
||||
@SerialName("mcp_count") val mcpCount: Int = 0,
|
||||
val categories: List<ContextPart> = emptyList(),
|
||||
@@ -613,6 +638,8 @@ data class Activity(
|
||||
val agents: List<ActivityAgent> = emptyList(),
|
||||
val team: ActivityTeam? = null,
|
||||
@SerialName("team_offered") val teamOffered: Boolean = false,
|
||||
/** The same fact by the word a person reads (server 2.0.0-beta.7). */
|
||||
@SerialName("subagents_offered") val subagentsOffered: Boolean? = null,
|
||||
val context: ContextUse? = null,
|
||||
val outputs: List<Output> = emptyList(),
|
||||
val plan: JsonObject? = null,
|
||||
|
||||
@@ -63,6 +63,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -373,7 +374,7 @@ private fun Empty(text: String) {
|
||||
@Composable
|
||||
private fun ContextSection(context: ContextUse?, canCompact: Boolean, compacting: Boolean, onCompact: () -> Unit) {
|
||||
val palette = LocalPalette.current
|
||||
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
if (context == null) {
|
||||
Empty(stringResource(R.string.activity_not_measured))
|
||||
} else {
|
||||
@@ -405,9 +406,12 @@ private fun ContextSection(context: ContextUse?, canCompact: Boolean, compacting
|
||||
}
|
||||
}
|
||||
// Each row a fixed grid: swatch, the name that gives, two number columns of their own
|
||||
// width -- the numbers line up whatever the names say in which language.
|
||||
// width -- the numbers line up whatever the names say in which language. The columns
|
||||
// are as wide as five of their own figures, so large type widens them with it.
|
||||
val figures = MaterialTheme.typography.bodySmall.fontSize * 4.6f
|
||||
val column = with(LocalDensity.current) { figures.toDp() }
|
||||
context.categories.forEach { part ->
|
||||
Row(Modifier.fillMaxWidth().heightIn(min = 24.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Row(Modifier.fillMaxWidth().heightIn(min = 22.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(Modifier.size(10.dp).clip(RoundedCornerShape(2.dp)).background(categoryColour(palette, part.key)))
|
||||
Text(
|
||||
categoryName(part.key),
|
||||
@@ -420,14 +424,16 @@ private fun ContextSection(context: ContextUse?, canCompact: Boolean, compacting
|
||||
ActivityLogic.compactTokens(part.tokens),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
textAlign = TextAlign.End,
|
||||
modifier = Modifier.width(56.dp),
|
||||
maxLines = 1,
|
||||
modifier = Modifier.width(column),
|
||||
)
|
||||
Text(
|
||||
part.percent?.let { "${ActivityLogic.percent(it)}%" } ?: "—",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = palette.inkMuted,
|
||||
textAlign = TextAlign.End,
|
||||
modifier = Modifier.width(56.dp),
|
||||
maxLines = 1,
|
||||
modifier = Modifier.padding(start = 4.dp).width(column),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -446,14 +452,16 @@ private fun ContextSection(context: ContextUse?, canCompact: Boolean, compacting
|
||||
when {
|
||||
context == null -> ""
|
||||
until != null -> stringResource(R.string.activity_until_compact, ActivityLogic.compactTokens(until))
|
||||
context.threshold <= 0 -> stringResource(R.string.activity_compact_off)
|
||||
context.autoCompact == false || context.threshold <= 0 -> stringResource(R.string.activity_compact_off)
|
||||
else -> ""
|
||||
},
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = palette.inkMuted,
|
||||
modifier = Modifier.weight(1f).padding(end = 8.dp),
|
||||
)
|
||||
OutlinedButton(onClick = onCompact, enabled = canCompact && !compacting && context != null) {
|
||||
// The server says when there is nothing to summarise yet (`compactable`); an older
|
||||
// one does not, and then its refusal says it in words.
|
||||
OutlinedButton(onClick = onCompact, enabled = canCompact && !compacting && context != null && context.compactable != false) {
|
||||
if (compacting) {
|
||||
CircularProgressIndicator(Modifier.size(16.dp), strokeWidth = 2.dp)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
|
||||
@@ -61,8 +61,10 @@ data class ChatState(
|
||||
val activityAt: Long = 0,
|
||||
/** The strip's counts, from the events route (or the first read). */
|
||||
val summary: ActivitySummary? = null,
|
||||
/** Whether this chat may have a team: the server's word for a chat that exists. */
|
||||
/** Whether this chat is offered subagents: the activity's word for a chat that exists. */
|
||||
val teamOffered: Boolean = false,
|
||||
/** The instance's cap on a chat's subagents, from the models list; null from an older server. */
|
||||
val modelsCap: Int? = null,
|
||||
/** Whether the events route is followed; without it an open panel polls. */
|
||||
val activityLive: Boolean = false,
|
||||
/** A Compact asked for from the activity sheet and not answered yet. */
|
||||
@@ -95,8 +97,22 @@ val ChatState.modelInfo: ModelInfo? get() = models.firstOrNull { it.id == modelI
|
||||
val ChatState.level: String?
|
||||
get() = modelInfo?.takeIf { it.levelControl != "none" }?.level(if (chat == null) draft.effort else chat.effort?.ifBlank { null })
|
||||
|
||||
/** Whether a team may be asked for: the server's word for a chat that exists, the model's facts for a new one. */
|
||||
fun ChatState.offersTeam(agent: Boolean): Boolean = if (chat != null) teamOffered else !agent && modelInfo?.mayHaveTeam == true
|
||||
/**
|
||||
* Whether the Subagents setting is shown (plan rule 4): the chat's own word for a chat that
|
||||
* exists (`subagents.offered`, else the activity's), the model's for a new one.
|
||||
*/
|
||||
fun ChatState.offersTeam(agent: Boolean): Boolean = if (chat != null) chat.subagents?.offered ?: teamOffered else !agent && modelInfo?.mayHaveTeam == true
|
||||
|
||||
/**
|
||||
* Whether subagents need a model the person names in the chat: the chat's own serves one
|
||||
* request at a time. The setting then says so; there is no default to fall back on.
|
||||
*/
|
||||
val ChatState.subagentsNamedOnly: Boolean
|
||||
get() = (if (chat != null) chat.subagents?.namedOnly else modelInfo?.subagents?.namedOnly) ?: false
|
||||
|
||||
/** The most subagents a chat may have here: the chat's cap, else the instance's, else the spec's. */
|
||||
val ChatState.subagentsCap: Int
|
||||
get() = (chat?.subagents?.cap ?: modelsCap ?: AgentsSetting.CAP).coerceAtLeast(1)
|
||||
|
||||
/** The team's size in force. */
|
||||
val ChatState.agents: AgentsSetting get() = chat?.agents ?: draft.agents ?: AgentsSetting()
|
||||
@@ -170,7 +186,9 @@ class ChatViewModel(app: Application) :
|
||||
try {
|
||||
val client = api()
|
||||
_state.update { it.copy(loading = chatId != null || agent, error = null) }
|
||||
val models = runCatching { client.models(chatId) }.getOrDefault(emptyList())
|
||||
val list = runCatching { client.modelList(chatId) }.getOrNull()
|
||||
val models = list?.models.orEmpty()
|
||||
_state.update { it.copy(modelsCap = list?.subagentsCap) }
|
||||
if (chatId == null) {
|
||||
val devices = if (agent) client.devices() else emptyList()
|
||||
_state.update { it.copy(models = models, devices = devices, loading = false) }
|
||||
@@ -184,7 +202,7 @@ class ChatViewModel(app: Application) :
|
||||
// Whether a team is offered and what runs in the background: the cheap read,
|
||||
// without the context count. A server without the panel has no answer.
|
||||
runCatching { client.activity(chatId, context = false) }.onSuccess { a ->
|
||||
_state.update { it.copy(teamOffered = a.teamOffered, summary = a.summary) }
|
||||
_state.update { it.copy(teamOffered = a.subagentsOffered ?: a.teamOffered, summary = a.summary) }
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
fail(e)
|
||||
@@ -348,7 +366,9 @@ class ChatViewModel(app: Application) :
|
||||
// Another model may serve one request at a time, or more: whether a team is offered
|
||||
// follows it.
|
||||
if (key == "model") {
|
||||
runCatching { api.activity(chat.id, context = false) }.onSuccess { r -> _state.update { it.copy(teamOffered = r.teamOffered) } }
|
||||
runCatching { api.activity(chat.id, context = false) }.onSuccess { r ->
|
||||
_state.update { it.copy(teamOffered = r.subagentsOffered ?: r.teamOffered) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +392,7 @@ class ChatViewModel(app: Application) :
|
||||
if (_state.value.summary == null) {
|
||||
// A chat its first message just made: whether a team is offered, read once.
|
||||
runCatching { client.activity(chat.id, context = false) }.onSuccess { a ->
|
||||
_state.update { it.copy(teamOffered = a.teamOffered, summary = a.summary) }
|
||||
_state.update { it.copy(teamOffered = a.subagentsOffered ?: a.teamOffered, summary = a.summary) }
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -410,7 +430,7 @@ class ChatViewModel(app: Application) :
|
||||
activity = if (context) read else read.copy(context = s.activity?.context),
|
||||
activityAt = SystemClock.elapsedRealtime(),
|
||||
summary = read.summary,
|
||||
teamOffered = read.teamOffered,
|
||||
teamOffered = read.subagentsOffered ?: read.teamOffered,
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -429,13 +429,26 @@ fun TuneContent(state: ChatState, actions: ChatActions, agent: Boolean, modifier
|
||||
color = palette.inkMuted,
|
||||
modifier = Modifier.padding(horizontal = 24.dp),
|
||||
)
|
||||
val now = state.agents
|
||||
Column(Modifier.padding(horizontal = 24.dp)) {
|
||||
AgentsSlider(stringResource(R.string.team_fewest), now.min) { v ->
|
||||
setTeam(actions, chat == null, AgentsSetting(v, maxOf(v, now.max)))
|
||||
}
|
||||
AgentsSlider(stringResource(R.string.team_most), now.max) { v ->
|
||||
setTeam(actions, chat == null, AgentsSetting(minOf(now.min, v), v))
|
||||
if (state.subagentsNamedOnly) {
|
||||
// The chat's model serves one request at a time: no default to fall back on.
|
||||
Text(
|
||||
stringResource(R.string.subagents_named_only),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = palette.warning,
|
||||
modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp),
|
||||
)
|
||||
}
|
||||
val cap = state.subagentsCap
|
||||
val now = state.agents.let { AgentsSetting(it.min.coerceIn(1, cap), it.max.coerceIn(1, cap)) }
|
||||
// An instance that allows only one has nothing to choose between.
|
||||
if (cap > 1) {
|
||||
Column(Modifier.padding(horizontal = 24.dp)) {
|
||||
AgentsSlider(stringResource(R.string.team_fewest), now.min, cap) { v ->
|
||||
setTeam(actions, chat == null, AgentsSetting(v, maxOf(v, now.max)))
|
||||
}
|
||||
AgentsSlider(stringResource(R.string.team_most), now.max, cap) { v ->
|
||||
setTeam(actions, chat == null, AgentsSetting(minOf(now.min, v), v))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -560,11 +573,11 @@ private fun DeviceChoices(devices: List<LinkedDevice>, current: LinkedDevice?, o
|
||||
}
|
||||
|
||||
/**
|
||||
* One end of the team's size: its label and value on a row of their own, so the two sliders
|
||||
* line up whatever the words, and the slider under them.
|
||||
* One end of the Subagents setting: its label and value on a row of their own, so the two
|
||||
* sliders line up whatever the words, and the slider under them, from 1 to the instance's [cap].
|
||||
*/
|
||||
@Composable
|
||||
fun AgentsSlider(label: String, value: Int, onChange: (Int) -> Unit) {
|
||||
fun AgentsSlider(label: String, value: Int, cap: Int, onChange: (Int) -> Unit) {
|
||||
var shown by remember(value) { mutableStateOf(value.toFloat()) }
|
||||
Column(Modifier.padding(top = 8.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
@@ -574,9 +587,11 @@ fun AgentsSlider(label: String, value: Int, onChange: (Int) -> Unit) {
|
||||
Slider(
|
||||
value = shown,
|
||||
onValueChange = { shown = it },
|
||||
onValueChangeFinished = { onChange(Math.round(shown).coerceIn(1, AgentsSetting.CAP)) },
|
||||
valueRange = 1f..AgentsSetting.CAP.toFloat(),
|
||||
// Continuous: 31 tick marks would be noise, and the value is rounded anyway.
|
||||
onValueChangeFinished = { onChange(Math.round(shown).coerceIn(1, cap)) },
|
||||
valueRange = 1f..cap.toFloat(),
|
||||
// Up to the instance's cap: a tick per value for a few, continuous past that, where
|
||||
// tick marks would be noise (the value is rounded anyway).
|
||||
steps = if (cap <= 8) cap - 2 else 0,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -113,6 +113,7 @@
|
||||
<string name="team_most">Nejvíce</string>
|
||||
<string name="team_hint">Nejméně a nejvíce pro tento chat, včetně jeho vlastního agenta. Nad jednoho může předávat práci subagentům a vést je.</string>
|
||||
<string name="team_chip">Subagenti %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">Tento model obslouží jen jeden požadavek najednou: subagenti potřebují jiný model, na jiném serveru, pojmenovaný v chatu.</string>
|
||||
<string name="thinking_switch">Přemýšlet před odpovědí</string>
|
||||
<string name="level_off">vypnuto</string>
|
||||
<string name="level_default">výchozí</string>
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<string name="team_most">Höchstens</string>
|
||||
<string name="team_hint">Die wenigsten und die meisten für diesen Chat, sein eigener Agent eingeschlossen. Ab zwei kann er Arbeit an Subagenten abgeben und sie leiten.</string>
|
||||
<string name="team_chip">Subagenten %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">Dieses Modell beantwortet nur eine Anfrage auf einmal: Subagenten brauchen ein anderes Modell auf einem anderen Server, im Chat genannt.</string>
|
||||
<string name="thinking_switch">Vor der Antwort nachdenken</string>
|
||||
<string name="level_off">aus</string>
|
||||
<string name="level_default">Standard</string>
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<string name="team_most">Máximo</string>
|
||||
<string name="team_hint">El mínimo y el máximo para este chat, incluido su propio agente. Por encima de uno, puede repartir trabajo entre subagentes y dirigirlos.</string>
|
||||
<string name="team_chip">Subagentes %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">Este modelo atiende una sola petición a la vez: los subagentes necesitan otro modelo, en otro servidor, nombrado en el chat.</string>
|
||||
<string name="thinking_switch">Razonar antes de responder</string>
|
||||
<string name="level_off">desactivado</string>
|
||||
<string name="level_default">predeterminado</string>
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<string name="team_most">Au plus</string>
|
||||
<string name="team_hint">Le minimum et le maximum pour ce chat, son propre agent compris. Au-delà d\'un, il peut confier du travail à des sous-agents et les diriger.</string>
|
||||
<string name="team_chip">Sous-agents %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">Ce modèle ne traite qu\'une requête à la fois : les sous-agents ont besoin d\'un autre modèle, sur un autre serveur, nommé dans le chat.</string>
|
||||
<string name="thinking_switch">Réfléchir avant de répondre</string>
|
||||
<string name="level_off">désactivé</string>
|
||||
<string name="level_default">par défaut</string>
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<string name="team_most">Legfeljebb</string>
|
||||
<string name="team_hint">A legkevesebb és a legtöbb ehhez a csevegéshez, a saját ügynökével együtt. Egy fölött munkát adhat alügynököknek, és vezeti őket.</string>
|
||||
<string name="team_chip">Alügynökök %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">Ez a modell egyszerre csak egy kérést szolgál ki: az alügynököknek másik modell kell, másik szerveren, a csevegésben megnevezve.</string>
|
||||
<string name="thinking_switch">Gondolkodjon válasz előtt</string>
|
||||
<string name="level_off">ki</string>
|
||||
<string name="level_default">alapértelmezett</string>
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<string name="team_most">Massimo</string>
|
||||
<string name="team_hint">Il minimo e il massimo per questa chat, compreso il suo agente. Sopra uno, può affidare lavoro a subagenti e guidarli.</string>
|
||||
<string name="team_chip">Subagenti %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">Questo modello serve una sola richiesta alla volta: i subagenti hanno bisogno di un altro modello, su un altro server, nominato nella chat.</string>
|
||||
<string name="thinking_switch">Ragiona prima di rispondere</string>
|
||||
<string name="level_off">disattivato</string>
|
||||
<string name="level_default">predefinito</string>
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<string name="team_most">Najwięcej</string>
|
||||
<string name="team_hint">Najmniej i najwięcej dla tego czatu, łącznie z jego własnym agentem. Powyżej jednego może przekazywać pracę subagentom i nimi kierować.</string>
|
||||
<string name="team_chip">Subagenci %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">Ten model obsługuje tylko jedno żądanie naraz: subagenci potrzebują innego modelu, na innym serwerze, nazwanego w czacie.</string>
|
||||
<string name="thinking_switch">Rozumuj przed odpowiedzią</string>
|
||||
<string name="level_off">wył.</string>
|
||||
<string name="level_default">domyślna</string>
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<string name="team_most">Najviac</string>
|
||||
<string name="team_hint">Najmenej a najviac pre tento chat, vrátane jeho vlastného agenta. Nad jedného môže odovzdávať prácu subagentom a viesť ich.</string>
|
||||
<string name="team_chip">Subagenti %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">Tento model obslúži len jednu požiadavku naraz: subagenti potrebujú iný model, na inom serveri, pomenovaný v chate.</string>
|
||||
<string name="thinking_switch">Premýšľať pred odpoveďou</string>
|
||||
<string name="level_off">vypnuté</string>
|
||||
<string name="level_default">predvolené</string>
|
||||
|
||||
@@ -114,6 +114,7 @@
|
||||
<string name="team_most">Most</string>
|
||||
<string name="team_hint">The fewest and most for this chat, its own agent included. Above one, it can hand work to subagents while it leads them.</string>
|
||||
<string name="team_chip">Subagents %1$s–%2$s</string>
|
||||
<string name="subagents_named_only">This model serves one request at a time: subagents need another model, on another server, named in the chat.</string>
|
||||
<string name="thinking_switch">Think before answering</string>
|
||||
<string name="level_off">off</string>
|
||||
<string name="level_default">default</string>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package eu.llembas.android
|
||||
|
||||
import eu.llembas.android.api.Activity
|
||||
import eu.llembas.android.api.ActivityLogic
|
||||
import eu.llembas.android.api.AgentsSetting
|
||||
import eu.llembas.android.api.Chat
|
||||
import eu.llembas.android.api.ContextUse
|
||||
import eu.llembas.android.api.LembasJson
|
||||
import eu.llembas.android.api.ModelInfo
|
||||
import eu.llembas.android.api.ModelList
|
||||
import eu.llembas.android.api.SubagentsOffer
|
||||
import eu.llembas.android.ui.chat.ChatState
|
||||
import eu.llembas.android.ui.chat.Draft
|
||||
import eu.llembas.android.ui.chat.offersTeam
|
||||
import eu.llembas.android.ui.chat.subagentsCap
|
||||
import eu.llembas.android.ui.chat.subagentsNamedOnly
|
||||
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 Subagents setting by the server's word (harness spec 3.3.0, `subagents.md` §4): shown
|
||||
* when it says subagents are offered, with its note when only a named model could serve, up to
|
||||
* the instance's cap -- and, from a server that says none of it, the app's old guess.
|
||||
*/
|
||||
class SubagentsTest {
|
||||
private val serving = ModelInfo(id = "qwen", tools = true, parallel = 4)
|
||||
|
||||
@Test
|
||||
fun theServersWordWinsOverTheGuess() {
|
||||
// The guess would offer them (tools, four at once); the server says no.
|
||||
val refused = serving.copy(subagents = SubagentsOffer(offered = false))
|
||||
assertFalse(refused.mayHaveTeam)
|
||||
// The guess would not (one at a time); the server offers them for a named model.
|
||||
val oneAtATime = serving.copy(parallel = 1, subagents = SubagentsOffer(offered = true, namedOnly = true))
|
||||
assertTrue(oneAtATime.mayHaveTeam)
|
||||
// An older server: the guess.
|
||||
assertTrue(serving.mayHaveTeam)
|
||||
assertFalse(serving.copy(parallel = 1).mayHaveTeam)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aNewChatAsksItsModel() {
|
||||
val state = ChatState(models = listOf(serving.copy(parallel = 1, subagents = SubagentsOffer(offered = true, namedOnly = true))), modelsCap = 8)
|
||||
assertTrue(state.offersTeam(agent = false))
|
||||
assertFalse(state.offersTeam(agent = true))
|
||||
assertTrue(state.subagentsNamedOnly)
|
||||
assertEquals(8, state.subagentsCap)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anOpenChatAsksItself() {
|
||||
val chat = Chat(id = "c1", model = "qwen", subagents = SubagentsOffer(offered = false, cap = 6))
|
||||
// The activity's older word says yes; the chat's own says no, and wins.
|
||||
val state = ChatState(chat = chat, models = listOf(serving), teamOffered = true, modelsCap = 8)
|
||||
assertFalse(state.offersTeam(agent = false))
|
||||
assertEquals(6, state.subagentsCap)
|
||||
assertFalse(state.subagentsNamedOnly)
|
||||
// A chat from an older server: the activity's word, and the spec's cap.
|
||||
val older = ChatState(chat = chat.copy(subagents = null), teamOffered = true, draft = Draft())
|
||||
assertTrue(older.offersTeam(agent = false))
|
||||
assertEquals(AgentsSetting.CAP, older.subagentsCap)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theNewFieldsParseAndTheOldOnesStillDo() {
|
||||
val list = LembasJson.decodeFromString(
|
||||
ModelList.serializer(),
|
||||
"""{"models": [{"id": "qwen", "subagents": {"offered": true, "named_only": false}}], "subagents_cap": 12}""",
|
||||
)
|
||||
assertEquals(12, list.subagentsCap)
|
||||
assertEquals(SubagentsOffer(offered = true), list.models.single().subagents)
|
||||
val bare = LembasJson.decodeFromString(ModelList.serializer(), """{"models": [{"id": "qwen"}]}""")
|
||||
assertNull(bare.subagentsCap)
|
||||
assertNull(bare.models.single().subagents)
|
||||
|
||||
val activity = LembasJson.decodeFromString(
|
||||
Activity.serializer(),
|
||||
"""{"team_offered": true, "subagents_offered": false,
|
||||
"context": {"used": 1000, "limit": 10000, "threshold": 95, "auto_compact": true, "until_compact": 8000, "compactable": false}}""",
|
||||
)
|
||||
assertEquals(false, activity.subagentsOffered)
|
||||
assertEquals(8000, ActivityLogic.untilAutoCompact(activity.context!!))
|
||||
assertEquals(false, activity.context!!.compactable)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun autoCompactOffIsOffWhateverTheThreshold() {
|
||||
val context = ContextUse(used = 1000, limit = 10000, threshold = 95, autoCompact = false, untilCompact = 8500)
|
||||
assertNull(ActivityLogic.untilAutoCompact(context))
|
||||
// Without the server's facts: worked out from the threshold.
|
||||
assertEquals(8500, ActivityLogic.untilAutoCompact(ContextUse(used = 1000, limit = 10000, threshold = 95)))
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ 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.SubagentsOffer
|
||||
import eu.llembas.android.api.Tail
|
||||
import eu.llembas.android.api.ToolBlock
|
||||
import eu.llembas.android.api.ToolCall
|
||||
@@ -184,6 +185,11 @@ object Fakes {
|
||||
chat = chat.copy(model = "gpt-oss", effort = "high", mode = "plan", agents = AgentsSetting(1, 4)),
|
||||
)
|
||||
|
||||
/** A chat whose model serves one request at a time, on an instance that caps subagents at 6. */
|
||||
val tunedOneAtATime = tuned.copy(
|
||||
chat = tuned.chat!!.copy(agents = AgentsSetting(2, 3), subagents = SubagentsOffer(offered = true, namedOnly = true, cap = 6)),
|
||||
)
|
||||
|
||||
val chats = ChatsState(
|
||||
chats = listOf(
|
||||
chat,
|
||||
|
||||
@@ -103,8 +103,9 @@ class ScreenShots {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun tune() = shoot("07-tune") {
|
||||
SheetOver { TuneContent(Fakes.tuned, NoChatActions, agent = false) }
|
||||
fun tune() {
|
||||
shoot("07-tune") { SheetOver { TuneContent(Fakes.tuned, NoChatActions, agent = false) } }
|
||||
shoot("07-tune-one-at-a-time") { SheetOver { TuneContent(Fakes.tunedOneAtATime, NoChatActions, agent = false) } }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,7 +141,8 @@ class ScreenShots {
|
||||
shoot("14-activity", content = sheet)
|
||||
shoot("14-activity", Phone.Small, content = sheet)
|
||||
shoot("14-activity", Phone.Small, fontScale = 1.5f, content = sheet)
|
||||
shoot("15-activity-open", content = open)
|
||||
shoot("14-activity", Phone.Scroll, content = sheet)
|
||||
shoot("15-activity-open", Phone.Scroll, content = open)
|
||||
shoot("16-activity-new-chat") {
|
||||
SheetOver { ActivityContent(eu.llembas.android.api.Activity(), readAt = 0, now = 0, actions = NoActivityActions, canCompact = false) }
|
||||
}
|
||||
|
||||
@@ -14,10 +14,14 @@ import com.github.takahirom.roborazzi.inspectionMode
|
||||
import com.github.takahirom.roborazzi.size
|
||||
import eu.llembas.android.ui.theme.LembasTheme
|
||||
|
||||
/** The phones the screens are looked at on: a large one, and a small one where things crowd. */
|
||||
/**
|
||||
* The phones the screens are looked at on: a large one, and a small one where things crowd.
|
||||
* [Scroll] is the large one's width, tall enough to see a sheet's whole scroll at once.
|
||||
*/
|
||||
enum class Phone(val tag: String, val widthDp: Int, val heightDp: Int) {
|
||||
Large("411x891", 411, 891),
|
||||
Small("360x640", 360, 640),
|
||||
Scroll("411x2000", 411, 2000),
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -127,6 +127,7 @@ STRINGS: dict[str, str] = {
|
||||
"team_most": "Most",
|
||||
"team_hint": "The fewest and most for this chat, its own agent included. Above one, it can hand work to subagents while it leads them.",
|
||||
"team_chip": "Subagents %1$s–%2$s",
|
||||
"subagents_named_only": "This model serves one request at a time: subagents need another model, on another server, named in the chat.",
|
||||
"thinking_switch": "Think before answering",
|
||||
"level_off": "off",
|
||||
"level_default": "default",
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
"signin_open_browser": "Otevřít v prohlížeči",
|
||||
"signin_too_new": "Tato instance používá novější rozhraní API pro aplikace než tato aplikace. Aktualizujte aplikaci.",
|
||||
"signin_too_old": "Tato instance používá starší LLeMbas. Tato aplikace potřebuje LLeMbas 2.0 nebo novější.",
|
||||
"subagents_named_only": "Tento model obslouží jen jeden požadavek najednou: subagenti potřebují jiný model, na jiném serveru, pojmenovaný v chatu.",
|
||||
"suggest_check": "Zkontroluj",
|
||||
"suggest_check_line": "text, chyby a tón",
|
||||
"suggest_explain": "Vysvětli",
|
||||
@@ -288,6 +289,7 @@
|
||||
"signin_open_browser": "Im Browser öffnen",
|
||||
"signin_too_new": "Diese Instanz spricht eine neuere App-API als diese App. Aktualisieren Sie die App.",
|
||||
"signin_too_old": "Auf dieser Instanz läuft ein älteres LLeMbas. Diese App braucht LLeMbas 2.0 oder neuer.",
|
||||
"subagents_named_only": "Dieses Modell beantwortet nur eine Anfrage auf einmal: Subagenten brauchen ein anderes Modell auf einem anderen Server, im Chat genannt.",
|
||||
"suggest_check": "Prüfe",
|
||||
"suggest_check_line": "einen Text auf Fehler und Ton",
|
||||
"suggest_explain": "Erkläre",
|
||||
@@ -451,6 +453,7 @@
|
||||
"signin_open_browser": "Abrir en el navegador",
|
||||
"signin_too_new": "Esta instancia habla una API de aplicaciones más reciente que esta aplicación. Actualice la aplicación.",
|
||||
"signin_too_old": "Esta instancia usa una versión anterior de LLeMbas. Esta aplicación necesita LLeMbas 2.0 o posterior.",
|
||||
"subagents_named_only": "Este modelo atiende una sola petición a la vez: los subagentes necesitan otro modelo, en otro servidor, nombrado en el chat.",
|
||||
"suggest_check": "Revisa",
|
||||
"suggest_check_line": "un texto: errores y tono",
|
||||
"suggest_explain": "Explica",
|
||||
@@ -615,6 +618,7 @@
|
||||
"signin_open_browser": "Ouvrir dans le navigateur",
|
||||
"signin_too_new": "Cette instance utilise une API d'application plus récente que cette application. Mettez à jour l'application.",
|
||||
"signin_too_old": "Cette instance utilise une version plus ancienne de LLeMbas. Cette application nécessite LLeMbas 2.0 ou plus récent.",
|
||||
"subagents_named_only": "Ce modèle ne traite qu'une requête à la fois : les sous-agents ont besoin d'un autre modèle, sur un autre serveur, nommé dans le chat.",
|
||||
"suggest_check": "Relis",
|
||||
"suggest_check_line": "un texte : fautes et ton",
|
||||
"suggest_explain": "Explique",
|
||||
@@ -779,6 +783,7 @@
|
||||
"signin_open_browser": "Megnyitás a böngészőben",
|
||||
"signin_too_new": "Ez a példány újabb alkalmazás-API-t használ, mint ez az alkalmazás. Frissítse az alkalmazást.",
|
||||
"signin_too_old": "Ezen a példányon régebbi LLeMbas fut. Ehhez az alkalmazáshoz LLeMbas 2.0 vagy újabb kell.",
|
||||
"subagents_named_only": "Ez a modell egyszerre csak egy kérést szolgál ki: az alügynököknek másik modell kell, másik szerveren, a csevegésben megnevezve.",
|
||||
"suggest_check": "Ellenőrizz",
|
||||
"suggest_check_line": "egy szöveget: hibák és hangnem",
|
||||
"suggest_explain": "Magyarázd el,",
|
||||
@@ -942,6 +947,7 @@
|
||||
"signin_open_browser": "Apri nel browser",
|
||||
"signin_too_new": "Questa istanza usa un'API per l'app più recente di questa app. Aggiorna l'app.",
|
||||
"signin_too_old": "Questa istanza usa una versione precedente di LLeMbas. Questa app richiede LLeMbas 2.0 o successivo.",
|
||||
"subagents_named_only": "Questo modello serve una sola richiesta alla volta: i subagenti hanno bisogno di un altro modello, su un altro server, nominato nella chat.",
|
||||
"suggest_check": "Controlla",
|
||||
"suggest_check_line": "un testo: errori e tono",
|
||||
"suggest_explain": "Spiega",
|
||||
@@ -1105,6 +1111,7 @@
|
||||
"signin_open_browser": "Otwórz w przeglądarce",
|
||||
"signin_too_new": "Ta instancja używa nowszego API aplikacji niż ta aplikacja. Zaktualizuj aplikację.",
|
||||
"signin_too_old": "Ta instancja działa na starszym LLeMbas. Ta aplikacja wymaga LLeMbas 2.0 lub nowszego.",
|
||||
"subagents_named_only": "Ten model obsługuje tylko jedno żądanie naraz: subagenci potrzebują innego modelu, na innym serwerze, nazwanego w czacie.",
|
||||
"suggest_check": "Sprawdź",
|
||||
"suggest_check_line": "tekst pod kątem błędów i tonu",
|
||||
"suggest_explain": "Wyjaśnij",
|
||||
@@ -1268,6 +1275,7 @@
|
||||
"signin_open_browser": "Otvoriť v prehliadači",
|
||||
"signin_too_new": "Táto inštancia používa novšie API pre aplikácie než táto aplikácia. Aktualizujte aplikáciu.",
|
||||
"signin_too_old": "Táto inštancia beží na staršom LLeMbas. Táto aplikácia potrebuje LLeMbas 2.0 alebo novší.",
|
||||
"subagents_named_only": "Tento model obslúži len jednu požiadavku naraz: subagenti potrebujú iný model, na inom serveri, pomenovaný v chate.",
|
||||
"suggest_check": "Skontroluj",
|
||||
"suggest_check_line": "text, chyby a tón",
|
||||
"suggest_explain": "Vysvetli",
|
||||
|
||||
Reference in new issue
Block a user