Improve deployment list and logs CLI#126
Conversation
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds a new ChangesDeployments logs feature
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as runDeploymentLogs
participant API as API Server
participant Output
User->>CLI: agentworkforce deployments logs [selector]
CLI->>CLI: Parse args (selector, path, tail, json, etc.)
CLI->>API: Resolve workspace/token context
Note over CLI,API: Optional: resolve agent selector
alt Selector provided
CLI->>API: Fetch deployments list
CLI->>CLI: Match selector against agent IDs/names/slugs
end
alt --path specified
CLI->>API: Read specific log file
else --path not specified
CLI->>API: List workspace log paths
end
CLI->>CLI: Accumulate entries up to tail limit
alt --json flag
CLI->>Output: Emit {entries} JSON
else text output
CLI->>Output: Emit formatted log lines
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| const entries: LogEntry[] = []; | ||
| for (const path of paths.slice(0, 14)) { | ||
| entries.push(...await fetchLogEntries({ | ||
| cloudUrl, | ||
| workspace, | ||
| token, | ||
| path, | ||
| agentId: agent.agentId | ||
| })); | ||
| if (entries.length >= opts.tail) break; | ||
| } | ||
| writeLogOutput(entries.slice(-opts.tail), opts); |
There was a problem hiding this comment.
🔴 --tail returns entries from oldest files instead of newest due to reversed accumulation order
fetchLogPaths sorts paths in descending order (newest first) at list-command.ts:377. The loop at lines 158-167 iterates newest-first and uses entries.push(...), placing entries from the newest log file at the beginning of the array and entries from progressively older files at the end. Then entries.slice(-opts.tail) takes the last N entries, which come from the oldest processed files — exactly the opposite of what --tail should return.
Concrete example
Given two log files sorted descending: ["2026-05-19.jsonl", "2026-05-18.jsonl"]
- After processing
2026-05-19.jsonl:entries = [A(13:00), B(14:00), C(15:00)] - After processing
2026-05-18.jsonl:entries = [A(13:00), B(14:00), C(15:00), D(10:00_prev_day), E(11:00_prev_day)] entries.slice(-3)→[C(15:00), D(10:00_prev_day), E(11:00_prev_day)]— mixes days and includes older entries- Expected:
[A(13:00), B(14:00), C(15:00)]— the 3 most recent entries
| const entries: LogEntry[] = []; | |
| for (const path of paths.slice(0, 14)) { | |
| entries.push(...await fetchLogEntries({ | |
| cloudUrl, | |
| workspace, | |
| token, | |
| path, | |
| agentId: agent.agentId | |
| })); | |
| if (entries.length >= opts.tail) break; | |
| } | |
| writeLogOutput(entries.slice(-opts.tail), opts); | |
| const entries: LogEntry[] = []; | |
| for (const path of paths.slice(0, 14)) { | |
| const fileEntries = await fetchLogEntries({ | |
| cloudUrl, | |
| workspace, | |
| token, | |
| path, | |
| agentId: agent.agentId | |
| }); | |
| entries.unshift(...fileEntries); | |
| if (entries.length >= opts.tail) break; | |
| } | |
| writeLogOutput(entries.slice(-opts.tail), opts); |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Fixed in 08fe520. The command now keeps fetched files as newest-first chunks, rebuilds chronological order across chunks before applying tail, and has a regression test for the multi-file case.
Summary
agentworkforce deployments list, with compact agent IDs moved to the endagentworkforce deployments logs [agent-name-or-id]for structured cloud log lookupValidation
corepack pnpm --filter @agentworkforce/cli testCompanion cloud PR: https://github.com/AgentWorkforce/cloud/pull/747