Skip to content

Add changes to get full content of Serial Console log#4507

Open
lubaihua33 wants to merge 1 commit into
mainfrom
baihua/ai_0526
Open

Add changes to get full content of Serial Console log#4507
lubaihua33 wants to merge 1 commit into
mainfrom
baihua/ai_0526

Conversation

@lubaihua33
Copy link
Copy Markdown
Collaborator

@lubaihua33 lubaihua33 commented Jun 1, 2026

Description

This PR improves the log analysis agent’s ability to read large/verbose logs more completely and reliably.

  1. Add get_file_stats and read_text_file_tail so the agent can inspect both head and tail (root cause is often near EOF).
  2. Enhance read_text_file to return structured metadata (effective ranges, truncation, duplicate-collapse stats) to make tool limits observable.
  3. Collapse long runs of consecutive duplicate lines to reduce noise in serial console logs.
  4. Fix search match line numbers to be 1-based and add pagination support to search_files (match_offset + max_matches) to continue scanning beyond per-call caps.
  5. Update the log-search prompt to explicitly use head+tail and iterate pagination when has_more is true.

Related Issue

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation update

Checklist

  • Description is filled in above
  • No credentials, secrets, or internal details are included
  • Peer review requested (if not, add required peer reviewers after raising PR)
  • Tests executed and results posted below

Test Validation

python -m lisa.ai.log_agent eval

2026-05-29 02:39:40.205[INFO] === SUMMARY ===
2026-05-29 02:39:40.205[INFO] Test case 0 Similarity: 0.597978
2026-05-29 02:39:40.205[INFO] Test case 1 Similarity: 0.555844
2026-05-29 02:39:40.220[INFO] Test case 2 Similarity: 0.739928
2026-05-29 02:39:40.220[INFO] Test case 3 Similarity: 0.609710
2026-05-29 02:39:40.223[INFO] Test case 4 Similarity: 0.642781
2026-05-29 02:39:40.226[INFO] Test case 5 Similarity: 0.345781
2026-05-29 02:39:40.227[INFO] Test case 6 Similarity: 0.593808
2026-05-29 02:39:40.228[INFO] Test case 7 Similarity: 0.756404
2026-05-29 02:39:40.230[INFO] Test case 8 Similarity: 0.759833
2026-05-29 02:39:40.231[INFO] Test case 9 Similarity: 0.638409
2026-05-29 02:39:40.233[INFO] Test case 10 Similarity: 0.691454
2026-05-29 02:39:40.234[INFO] Test case 11 Similarity: 0.548641
2026-05-29 02:39:40.235[INFO] Test case 12 Similarity: 0.751358
2026-05-29 02:39:40.236[INFO] Test case 13 Similarity: 0.751052
2026-05-29 02:39:40.236[INFO] Test case 14 Similarity: 0.767606
2026-05-29 02:39:40.239[INFO] Test case 0 Processing time(s): 119.60
2026-05-29 02:39:40.240[INFO] Test case 1 Processing time(s): 181.19
2026-05-29 02:39:40.242[INFO] Test case 2 Processing time(s): 87.18
2026-05-29 02:39:40.243[INFO] Test case 3 Processing time(s): 86.51
2026-05-29 02:39:40.244[INFO] Test case 4 Processing time(s): 85.82
2026-05-29 02:39:40.246[INFO] Test case 5 Processing time(s): 132.73
2026-05-29 02:39:40.246[INFO] Test case 6 Processing time(s): 107.57
2026-05-29 02:39:40.248[INFO] Test case 7 Processing time(s): 111.86
2026-05-29 02:39:40.249[INFO] Test case 8 Processing time(s): 120.91
2026-05-29 02:39:40.250[INFO] Test case 9 Processing time(s): 99.04
2026-05-29 02:39:40.251[INFO] Test case 10 Processing time(s): 88.12
2026-05-29 02:39:40.252[INFO] Test case 11 Processing time(s): 109.14
2026-05-29 02:39:40.252[INFO] Test case 12 Processing time(s): 109.13
2026-05-29 02:39:40.253[INFO] Test case 13 Processing time(s): 112.52
2026-05-29 02:39:40.253[INFO] Test case 14 Processing time(s): 139.12
2026-05-29 02:39:40.254[INFO] Processing times - Average: 112.70s, Min: 85.82s, Max: 181.19s, Total: 1690.45s
2026-05-29 02:39:40.255[INFO] General deployment name: gpt-4.1, Software deployment name: gpt-5.2
2026-05-29 02:39:40.256[INFO] Average similarity: 0.650039, Best: 0.767606, Worst: 0.345781, Total test cases: 15

Copilot AI review requested due to automatic review settings June 1, 2026 01:24
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

🤖 AI Test Selection

No test cases were selected for this PR.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the LISA AI log analysis workflow to handle large/verbose logs (notably serial_console.log) more reliably by adding file inspection tools, paging support for search, and output de-noising/metadata so the agent can reason about truncation and coverage.

Changes:

  • Added get_file_stats and read_text_file_tail, and registered them as agent tools to enable head/tail review.
  • Enhanced read_text_file to return structured metadata and to collapse long runs of consecutive duplicate lines.
  • Fixed search_files match line numbering to be 1-based and added pagination (match_offset/max_matches + pagination.has_more).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
pyproject.toml Updates dependency constraints and adds github-copilot-sdk to the ai optional dependency set.
lisa/ai/prompts/default/log_search.txt Updates the agent prompt to explicitly use head+tail reads and to paginate search_files results.
lisa/ai/default_flow.py Implements new file tools (stats, tail), adds pagination to search_files, and adds duplicate-line collapsing + richer metadata to reads.

Comment thread lisa/ai/default_flow.py
Comment on lines 407 to 409
traceback_start = max(1, start_line_offset)
bounded_line_count = min(line_count, MAX_READ_LINE_COUNT)
traceback_end = traceback_start + bounded_line_count - 1
Comment thread lisa/ai/default_flow.py
Comment on lines +440 to +443
"effective_start_line": traceback_start,
"requested_line_count": line_count,
"effective_line_count": bounded_line_count,
"effective_end_line": traceback_end,
Comment thread lisa/ai/default_flow.py
Comment on lines +494 to +496
start_line = collapsed_lines[0][0]
end_line = collapsed_lines[-1][0]
content = "\n".join(f"({i}): {t}" for i, t in collapsed_lines)
Comment thread lisa/ai/default_flow.py
Comment on lines 264 to 270
file_extensions: Required file extension filter. Can be a single extension
(e.g., '.log') or multiple comma-separated extensions
max_matches: Maximum number of matches to return in this call (page size).
The actual returned size is capped for safety.
match_offset: Number of matches to skip (for pagination). 0-based.
(e.g., '.log,.txt,.out').

Comment thread lisa/ai/default_flow.py
Comment on lines 407 to 409
traceback_start = max(1, start_line_offset)
bounded_line_count = min(line_count, MAX_READ_LINE_COUNT)
traceback_end = traceback_start + bounded_line_count - 1
Comment thread lisa/ai/default_flow.py
Comment on lines +440 to +443
"effective_start_line": traceback_start,
"requested_line_count": line_count,
"effective_line_count": bounded_line_count,
"effective_end_line": traceback_end,
Comment thread lisa/ai/default_flow.py
Comment on lines +494 to +496
start_line = collapsed_lines[0][0]
end_line = collapsed_lines[-1][0]
content = "\n".join(f"({i}): {t}" for i, t in collapsed_lines)
Comment thread lisa/ai/default_flow.py
Comment on lines 264 to 270
file_extensions: Required file extension filter. Can be a single extension
(e.g., '.log') or multiple comma-separated extensions
max_matches: Maximum number of matches to return in this call (page size).
The actual returned size is capped for safety.
match_offset: Number of matches to skip (for pagination). 0-based.
(e.g., '.log,.txt,.out').

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

🤖 AI Test Selection

No test cases were selected for this PR.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

🤖 AI Test Selection

No test cases were selected for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants