Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
724e14b
test(logs): pin how each log-tail reader behaves today
jussielo-amd Nov 5, 2026
e4f3495
fix(logs): read every log tail through one bounded, lossy routine
jussielo-amd Nov 5, 2026
1827423
test(logs): cover a log with an invalid byte in the logs scenarios
jussielo-amd Nov 5, 2026
375f6bc
fix(logs): keep a UTF-8 tail read inside its size snapshot and skip a…
jussielo-amd Nov 6, 2026
93853a0
fix(logs): do not report a log that has content as empty or without o…
jussielo-amd Nov 6, 2026
8ffe3e8
fix(mcp): tell an empty service log from one whose newest line exceed…
jussielo-amd Nov 6, 2026
92bd633
style(core): keep the first doc paragraph of the log tail summaries s…
jussielo-amd Nov 6, 2026
1ae7c6d
docs(testing): describe the log view scenarios and the shared tail ro…
jussielo-amd Nov 9, 2026
ca4e361
fix(logs): do not report a log with an oversized line as absent in th…
jussielo-amd Nov 9, 2026
8840d0e
fix(logs): measure a log again when it shrinks between the size and t…
jussielo-amd Nov 9, 2026
aaa6670
refactor(logs): name the follow cursor apart from the bounded-read re…
jussielo-amd Nov 9, 2026
ab0695b
test(logs): build the shrinking-source fixture without format in an i…
jussielo-amd Nov 9, 2026
840d0d0
fix(mcp): report the lines the service_logs tool returned, not the nu…
jussielo-amd Nov 9, 2026
492d9f9
docs(core): say the UTF-16 sniff needs half of the odd bytes to be zero
jussielo-amd Nov 9, 2026
1816fab
docs(manual-testing): describe how the log views tell an empty log fr…
jussielo-amd Nov 9, 2026
2dbf9db
docs(manual-testing): check each log view against the files it reads
jussielo-amd Nov 9, 2026
6bcb77a
Merge origin/main into split-log-tail-routine
jussielo-amd Nov 9, 2026
97f0d48
fix(rocm): reach the startup-failure helper from the log-tail tests o…
jussielo-amd Nov 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 56 additions & 8 deletions apps/rocm/src/chat/mcp_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::managed_service_status::{load_managed_services, managed_service_is_li
use crate::rocm_argv::{chat_cli_arg_value, chat_cli_has_flag};
use crate::runtimes_cmd::render_runtimes_text;
use crate::services_text::{
read_tail_lines, render_logs_browser_text, render_logs_text, render_service_logs_text,
read_log_tail, render_logs_browser_text, render_logs_text, render_service_logs_text,
render_services_text,
};
use crate::tool_policy::{
Expand Down Expand Up @@ -213,16 +213,15 @@ pub(crate) fn run_internal_mcp_call(
.into_iter()
.find(|service| service.service_id == service_id)
.with_context(|| format!("managed service `{service_id}` not found"))?;
let tail = read_tail_lines(&record.log_path, lines, "service log")?.join("\n");
let log_tail = read_log_tail(&record.log_path, lines, "service log")?;
Ok(internal_mcp_tool_success(
format!(
"Read the last {} line(s) from service `{}`.",
lines, record.service_id
),
rocm_core::service_log_tool_summary(&record.service_id, &log_tail),
serde_json::json!({
"service": record,
"lines": lines,
"tail": tail,
"lines": log_tail.lines.len(),
"lines_requested": lines,
"newest_line_exceeds_read_bound": log_tail.newest_line_exceeds_the_read_bound(),
"tail": log_tail.lines.join("\n"),
}),
))
}
Expand Down Expand Up @@ -867,6 +866,55 @@ mod tests {
use std::fs;
use std::net::TcpListener;

/// The structured reply of the CLI's own `service_logs` tool for a service
/// whose log holds `log`, asking for `lines` lines.
fn service_logs_structured(label: &str, log: &[u8], lines: u64) -> serde_json::Value {
let (root, paths) = test_paths(label);
paths.ensure().expect("paths");
let record = ManagedServiceRecord::new(
&paths,
"svc-tail-count",
"llamacpp",
"a-model",
"a-model",
"127.0.0.1",
18080,
"managed",
std::process::id(),
None,
None,
None,
);
record.write().expect("record");
fs::write(&record.log_path, log).expect("log");
let reply = run_internal_mcp_call(
&paths,
"service_logs",
serde_json::json!({ "service_id": "svc-tail-count", "lines": lines }),
false,
)
.expect("service_logs ok");
let _ = fs::remove_dir_all(root);
reply["structuredContent"].clone()
}

#[test]
fn service_logs_report_the_lines_returned_and_the_lines_asked_for_apart() {
// Asking for 50 lines of a four-line log returns four.
let content = service_logs_structured("service-logs-count", b"a\nb\nc\nd\n", 50);
assert_eq!(content["lines"], 4, "{content}");
assert_eq!(content["lines_requested"], 50, "{content}");
assert_eq!(content["tail"], "a\nb\nc\nd", "{content}");
// A log with more lines than asked for returns exactly what was asked.
let content = service_logs_structured("service-logs-count-cut", b"a\nb\nc\nd\n", 2);
assert_eq!(content["lines"], 2, "{content}");
assert_eq!(content["lines_requested"], 2, "{content}");
// An empty log returned none, whatever was asked for.
let content = service_logs_structured("service-logs-count-empty", b"", 50);
assert_eq!(content["lines"], 0, "{content}");
assert_eq!(content["lines_requested"], 50, "{content}");
}

#[test]
fn mcp_tool_result_text_joins_text_content_items() {
let value = serde_json::json!({
Expand Down
Loading
Loading