Repository navigation
feat(agents): 会话列表按目录筛选与排序,回答消息数、子代理数、模型和整表计数(API-45 0 内补充) - #219
Conversation
There was a problem hiding this comment.
Devin Review found 2 potential issues.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| AND (json_array_length(?5) = 0 | ||
| OR EXISTS (SELECT 1 FROM json_each(?5) d | ||
| WHERE cwd = d.value | ||
| OR substr(cwd, 1, length(d.value) + 1) | ||
| IN (d.value || '/', d.value || char(92)))) |
There was a problem hiding this comment.
🟡 Missing sessions under Windows path aliases
cwdUnder drops Windows sessions when the filter spells the same directory with different casing or internal separators. The same comparison undercounts the filtered history.
Learn more
The desktop host passes workspace or project directories to Records::list. The cached cwd comes independently from the session parser and is stored as supplied by write_chunk. The SQL comparison accepts either separator only at the ancestor boundary, not inside the prefix, and compares the prefix case-sensitively. Core's platform layer already documents case-insensitive Windows comparisons and provides separator normalization in relative_path_contains and slash_separated.
Example: A session records C:\Work\App. Filtering by C:\work or C:/Work returns zero sessions and a total of zero even though both name its ancestor.
Recommended fix: Put platform-aware path normalization and containment in lithe-platform and use it for the shared list and count predicate with Platform::HOST. Preserve the original path for display and test both platform rules, equivalent Windows spellings, roots, and sibling prefixes.
Was this helpful? React with 👍 or 👎 to provide feedback.
| AND COALESCE(c.model, c.requested_model) IS NOT NULL | ||
| ORDER BY c.thread_id IS NOT NULL, c.started_at_ms DESC, c.call_key DESC | ||
| LIMIT 1"; |
There was a problem hiding this comment.
🟡 Session model taken from another call
When the latest main-thread call names no model, describe_activity can display an older call’s model or a subagent’s. The same lookup skips the latest call in subagent-only sessions when it names no model.
Learn more
The session list reports the response model or requested model of the latest main-thread call. The session records contract permits selecting a subagent's latest call only when there are no main-thread calls. Both model names are optional in CallRecord. Filtering out calls with neither name before sorting changes which call wins, rather than returning no model for the winning call.
Example: A main-thread call records model-a, then the next main-thread call records neither model name. Listing the session returns model-a instead of omitting the field. Without the older named main-thread call, a named subagent call can supply the value instead.
Recommended fix: Rank all calls, then read the winning call's COALESCE(model, requested_model) as an Option<String>. Flatten the optional row and optional model. Cover unnamed latest calls in both mixed-thread and subagent-only sessions.
Was this helpful? React with 👍 or 👎 to provide feedback.
…45 0 内补充) (#220) - 会话事件新增 configOptions(对齐 ACP session config options):最多 16 个设置,每个 1–128 个值,ID 与值唯一,currentValue 必须在列表里;每次报告替换上一次,空列表撤回 - 宿主命令 agents.setConfigOption 只接受用户请求,回合中也可调用,拒绝码 agents.unknownConfigOption、agents.unknownConfigValue、agents.backendUnavailable - 通知 lithe/host/agents/didSetConfigOption 交给插件后端,四种官方 SDK 新增会话处理器方法 - Go SDK 的宿主通知统一走 Agent 通知分发,去掉重复的方法列表 - 契约 README、fixture、API 总表、更新记录、Agent 功能页同步;#219 移到时间线
概述 / Summary
API-45(Agent)的一组
agents0 内补充,给桌面端 1lck/Lithe-IDEA#2492 的 Agent 会话历史页用。桌面端要按“工作区 / 项目 / 全部”过滤会话,按目录分组并显示每组数量,并在每行显示消息数、子代理数、模型和最后一条消息的预览:agentSessions.list新增cwdUnder(最多 64 个目录,会话目录就是其中之一或在它下面才保留),以及order(updated最近活动在前,默认;started最近开始在前)。counts: true时,回答多出total(筛选后的会话总数,不受offset/limit影响)、groups(按目录给出{cwd?, count, updatedAtMs?},最近活动在前,最多 500 组)和groupsTruncated。messageCount:会话自己文件里的可搜索片段数,子代理文件不计;lastMessageRange:最后一个片段的范围,桌面端按需用agentSessions.read读出预览,Core 不缓存正文;subagentCount:调用里不同threadID的个数;model:最近一次主线程调用的model,没有时用requestedModel;全是子代理调用时取最近一次调用的。不新增宿主方法、通知、错误码、权限、能力版本或 schema 版本。缓存库结构不变,不升
SCHEMA_VERSION。旧 Core 把三个新参数当未知字段拒绝,也不回答四个新字段,桌面端会显示不带这些信息的列表。宿主方法与通知 / Host methods and notifications
没有新增或修改插件宿主方法。下面这个是平台宿主命令,不是插件宿主方法,列出来方便评审:
agentSessions.listcwdUnder、order、counts;每个会话新增messageCount、subagentCount、model、lastMessageRange;counts时回答total、groups、groupsTruncated主要改动 / Changes
rust/crates/agent-sessions/src/store.rsSessionFilter加cwd_under和order(SessionOrder::Updated/Started)。selected_sessions!宏里的两个 CTE,sessions()和新的session_counts()共用。cwd = d OR substr(cwd, 1, length(d)+1) IN (d||'/', d||'\')。目录末尾的/、\先去掉,所以/w不会匹配/wx;/和C:\这样的根目录包含它下面的所有路径;超过 64 个目录时返回InvalidRequest。session_counts()回答SessionCounts {total, groups, groups_truncated},组数最多MAX_SESSION_GROUPS(500)。describe_activity()用三条有界查询,给当前页的每一行补上消息数和最后一个片段、子代理数、模型。每一行都单独查询,以避开打包的 SQLite 3.46 的一个问题:标量子查询的 ORDER BY 引用外层 CTE 的列时会报 no such column。rust/crates/agent-runtime/src/records.rs:list接受cwdUnder、order、counts,检查目录:最多 64 个,每个 1–4096 字节,不能含控制字符,不合格时用agents.invalidPayload拒绝。没有允许读取的 Agent 时,回答空列表和零计数。agent-sessions新增三个测试,覆盖:cwd的会话;thread和updated两个字段。agent-runtime新增一个测试,用插件后端走完同步、列表、计数,并用lastMessageRange读出消息;同时检查五种非法参数被拒绝。rust-core-api.md更新命令说明;protocol-changelog.md新增本 PR 的待合入条目,并把已合入的 feat(plugins): add workspace/setDirectoryTypes and workspace/setDirectoryMarks host API #215、feat(agents): API-45 Agent 能力 agents 0:原生 CLI 会话、会话记录与四种 SDK #216、feat(agents): 用量速度排行、会话分页读取、Agent 命令行工具安装和 IDE 连接的会话搜索(API-45 0 内补充) #217 移到时间线、填上合入日期。验证 / Verification
cargo test -p lithe-agent-sessions:45 个通过。cargo test -p lithe-agent-runtime:18 个通过。cargo clippy -p lithe-agent-sessions -p lithe-agent-runtime --all-targets -- -D warnings、cargo fmt --check:通过。node shared/plugins/scripts/verify-docs.mjs:通过。sdk-e2e.mjs,四种 SDK 不受影响。