Repository navigation
Filter agent-compose logs by event id (daemon-side) - #81
Merged
innomentats merged 5 commits intoSep 24, 2026
Merged
Conversation
Resolve an event-bus event id (evt_...) via the daemon event trace REST endpoint and replay the agent runs recorded against it, using the existing ListRuns scheduler_run_id filter. The flag accepts full event ids only, is mutually exclusive with --run, --sandbox, and positional targets, composes with --agent (resolved to the canonical agent name before narrowing), and reports events without runs on stderr (empty runs array with --json).
Sync the proto snapshot pinned to agent-compose@99bd5586 which adds ListRunsRequest.event_id, and drop the client-side trace resolution, run filtering and merge logic from logs --event. The command now sends one ListRuns call with the event id and the daemon resolves the event scope (event itself, descendants, correlation siblings) and its runs. - regenerate gen/ for the new event_id field (field 13) - rewrite logs_event.go: single paged ListRuns (limit 200, offset until total), keep evt_ validation, selector mutual exclusion, agent reference resolution, empty-result notices and NDJSON output - replay order: sort by started_at as time.Time with daemon order as tie-breaker (the previous iteration replayed delivery order; sorting by RFC3339Nano string key would misorder mixed fraction precision) - rewrite tests: assert event_id/agent passthrough, not-found maps to exit 5, paging loop, oldest-first replay; server helper takes the outer handler value so embedded stub overrides dispatch
yorkew-east8
force-pushed
the
feat/cli-logs-event-id-filter
branch
from
September 22, 2026 05:21
9438108 to
ce1d68d
Compare
yorkew-east8
marked this pull request as ready for review
September 22, 2026 07:31
Author
|
@monkeyscan 评审下这个 PR |
处理失败,请稍后重试。 |
Author
|
@monkeyscan 评审下这个 PR |
处理失败,请稍后重试。 |
Sync the proto snapshot pinned to agent-compose@85ba5a41 which adds ListRunsResponse.event_scope_truncated, and warn on stderr when the daemon reports that the event scope hit its 1000-event cap, so runs recorded only against events beyond the cap are missing from the output. The warning prints in both text and JSON mode.
Author
|
@monkeyscan 评审下这个 PR |
|
PR Title: Filter agent-compose logs by event id (daemon-side... Commit: 整体评估本次变更给 agentcompose 的 logs 命令新增了 --event,按事件 id 在 daemon 侧过滤并回放关联 run 的日志,包含新实现文件、配套测试,以及协议快照与生成代码的同步(协议里还夹带了一个与本功能无关的枚举新增)。分页、排序、not_found 映射与截断告警等核心逻辑都有针对性测试覆盖,整体方向一致,可在小幅修正后合并。 总结整体实现可用、方向正确,主要风险集中在机器可读输出契约与对服务端版本的耦合。最需要修的是 logs --event --json 在空结果时输出 {"runs":[]} 对象、有结果时却输出 NDJSON 记录,解析方无法用统一逻辑处理,应统一为单一契约;其次是该特性依赖尚未发布的 daemon 字段(README 标注 pending v2609.3.1+),旧 daemon 会静默忽略 event_id 并返回整个项目的 run,需补充能力/版本校验或明确最低版本要求。 Findings (1)
Prompt To Fix All With AI |
--json is a record stream (followOneRun NDJSON records); an empty result now writes no records, matching logs --json with no targets, instead of switching to a wrapper object that scripts would have to parse differently from the non-empty case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agent-compose logs --event <evt-id>now delegates event→run resolution to the daemon. The CLI sends oneListRunscall carrying the newevent_idfield and replays the returned runs; it no longer fetches the event trace, resolves scheduler runs, or merges run lists locally.Depends on chaitin/agent-compose#712 (adds
ListRunsRequest.event_id, daemon-side event scope filtering, and theListRunsResponse.event_scope_truncatedflag). The vendored proto snapshot inproducts/agentcompose/proto/SOURCEis pinned to agent-compose@85ba5a4185e907c1306beb588d3800e570a610b0; after #712 merges we can re-pin to the merge commit and the generated code should be byte-identical.Changes
SOURCEpin + sha256 updated;gen/regenerated viatask agent-compose:proto:sync+task agent-compose:proto:generate(newevent_idfield 13 onListRunsRequest, newevent_scope_truncatedfield 3 onListRunsResponse). Generated code is committed per repo convention; CI does not regenerate.logs_event.gorewritten: single pagedListRuns{ProjectId, AgentName, EventId, Limit:200}loop advancing offset untiltotalis reached. Deleted the client-side trace REST calls,resolveEventLogSchedulerRunIDs,resolveEventLogRuns, andeventLogReplayRuns. Kept:evt_prefix validation (fast fail), selector mutual exclusion (--run/--sandbox/positional vs--event),resolveAgentreference normalization (a CLI concern, not run filtering), empty-result stderr notice (text) /{"runs":[]}(JSON), and per-run--followreplay.event_scope_truncated(event scope hit its 1000-event cap), the CLI prints a warning on stderr in both text and JSON mode, exit code unchanged.started_atastime.Time(daemon order kept as tie-breaker). The previous RFC3339Nano string key misordered mixed fraction precision (.1Zvs.15Z).event_id/AgentNamepassthrough, unknown event maps tonot_found(exit 5), paging loop over a 200+1 stub, oldest-first replay, JSON NDJSON output, empty notices, and the truncation warning. The test server helper now accepts the outer handler value so embedded-stub overrides dispatch correctly.User-visible behavior
Unchanged from the previous iteration of this PR: full
evt_id required, mutually exclusive selectors,--agentnarrowing,--followsnapshot semantics, empty-result notice with exit 0, JSON output shape. Unknown event ids now surface asnot_found(exit 5) from the daemon instead of a client-side message. Truncated event scopes surface as a stderr warning with exit 0.One intentional difference from the built-in CLI (chaitin/agent-compose#712): chaitin-cli maps
CodeNotFoundto exit code 5 per its own error vocabulary, while agent-compose's CLI uses exit 2 (usage) for the same condition.Backward compatibility
proto3 unknown fields are ignored by older daemons: a new CLI against an old daemon sends
event_idthat is silently dropped, and the daemon returns unfiltered runs. Daemon and CLI must be upgraded together; called out in #712 as well.Verification
task fmt:check,task lint,task build,task test— all pass (includingproducts/agentcomposepackage suite).go vetclean.mainin this repo are unrelated (tzdata/LLM-config environment tests) and were confirmed in the earlier draft iteration.