fix(commands): limit journal_logs output to specified number of lines using head instead of --lines#313
fix(commands): limit journal_logs output to specified number of lines using head instead of --lines#313umglurf wants to merge 2 commits intorhel-lightspeed:mainfrom
Conversation
- Adjust parameterization to include expected line counts and updated command args - Update assertions to match new journalctl invocation with head -n for line limits
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
Thanks for trying linux-mcp-server out and contributing!! Digging into this - before systemd/systemd#26669 (system 254 I think, RHEL 8 is 252, RHEL 9 257) behaved pretty badly with
The current behavior where I'd think about two things:
But I don't think I'd want to go with the approach here - always providing the first N lines (for any filters or no filters) is surprising, and probably not as useful as getting the last N lines. Can you share (at a high level) what prompt you used and what the model was trying to do so that we can better understand the use case? |
I think that would be very useful. The description for the line parameter just says
I was asking the the agent to find out why a given service had stopped around a given time the day before. It then correctly sent the correct since parameter set to the start time of the incident, but because the lines parameter is mandatory and behaves the way it does, it consistently was only able to get recent logs, and not from the time of the issue. With the current behavior, an agent can only retrieve historical logs by retrieving potentially thousands of lines, which would fill up the context window, unless run in some code as tool environment with access to filtering the output through code before returning to the agent. |
Journalctl with
--linescombined with other filters such as--sincefilters lines first, then applies filtering logic, ref systemd/systemd#26669This makes the journalctl tool not work as intended, as the agent is not able to query logs from a given time.
This PR replaces
--lineswith using head, making it possible to query logs from a given timestamp.