Skip to content

ADFA-6268 | Add read_app_logs and read_ide_logs agent tools - #113

Merged
jatezzz merged 4 commits into
mainfrom
feat/ADFA-6268-ai-agent-read-log-tools
Oct 1, 2026
Merged

jatezzz merged 4 commits into
mainfrom
feat/ADFA-6268-ai-agent-read-log-tools

Conversation

@jatezzz

@jatezzz jatezzz commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR enables the AI agent to independently fetch and diagnose runtime crashes and IDE errors without requiring the user to manually copy and paste log lines.

  • Added read_app_logs and read_ide_logs read-only tools to the AI agent.
  • Implemented LogWindowCalculator to cap the output at 3,900 characters (AgentLoop.DEFAULT_TOOL_OUTPUT_CHAR_LIMIT - 100). The slice starts at the newer of the newest crash or the newest run of error lines; when it cannot reach the end, half the budget keeps the newest lines. A read with no error, or only errors, keeps the newest lines.
  • plugin.min_ide_version stays at 26.39. The log tools are registered only when the host has IdeLogService, so older hosts keep the agent chat working without them.
  • This allows the agent to diagnose runtime crashes and IDE errors independently, without requiring the user to copy log lines by hand.

Details

  • Neither tool requires user approval to execute.
  • Missing log services or empty logs return clear messages to the agent rather than generating errors.
  • The run_app success message tells the agent to call read_app_logs if the app crashes or misbehaves, only on hosts where the log tools are registered.
  • Repeating a successful log read does not end the run as complete, because logs change between calls. Batches that also build or write are not exempt.
  • Extensive unit tests were added for the log truncation budget, crash-anchored windowing, and tool handlers.

Demo

https://drive.google.com/file/d/1u-lB33uulRhBYw7N9-oAcjnyZVhOf8kD/view?usp=sharing

Ticket

ADFA-6268
Parent: ADFA-6266

Observation

All tools are registered in Executor.kt and BuiltInToolHandlers.kt.

…6268)

Read-only tools over IdeLogService, capped at 8000 chars and anchored on the first crash or error. run_app points the agent at read_app_logs; min_ide_version is now 26.40.
@jatezzz
jatezzz requested review from a team, Daniel-ADFA and itsaky-adfa September 29, 2026 22:03

@Daniel-ADFA Daniel-ADFA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at d85ceda.

CRITICAL

  • AndroidManifest.xml:41 - min_ide_version 26.40 predates IdeLogService; the agent chat fails on that host

IMPORTANT

  • LogWindowCalculator.kt:12 - AgentLoop keeps only the first 4000 chars of the 8000-char window
  • LogWindowCalculator.kt:25 - anchors on the oldest crash/error, not the newest
  • ReadLogsHandler.kt:8 - libs/plugin-api.jar and plugin-api-latest lack the log API, so AI-Core does not compile
  • ReadLogsHandler.kt:136 - a second consecutive read ends the run as completed

NITPICK - 1 inline, not listed

No prior review rounds. The repo has no written approve/request-changes rule (CLAUDE.md, plugin-review skill), so the default grading applied; two findings cite the plugin-review RUBRIC (6.1 compatibility, 6.3 build reproducibility).

Comment thread plugins/AI-Core/src/main/AndroidManifest.xml Outdated

@Daniel-ADFA Daniel-ADFA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes for the CRITICAL and four IMPORTANT findings in the review above: keep AI-Core working on 26.39/26.40 hosts without IdeLogService, refresh libs/ so it compiles, size the log window to the agent loop's 4000-char cap, anchor on the newest crash, and stop a repeated log read from ending the run.

- Keep min_ide_version 26.39; register log tools only when the host has IdeLogService
- Size the log window to AgentLoop's tool-output cap
- Anchor on the newest crash / newest error run instead of the oldest
- Don't treat a repeated log read as the run completing
- Share OutputWindow and the truncation marker between build and log handlers
@jatezzz
jatezzz requested a review from Daniel-ADFA September 30, 2026 17:13

@Daniel-ADFA Daniel-ADFA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review at 54b818b.

IMPORTANT

  • LogWindowCalculator.kt:24 - an earlier run's crash still wins the anchor
  • ReadLogsHandler.kt:139 - the empty-log text prescribes run_app when the log sender is off
  • RunAppHandler.kt:99 - the run_app hint names a tool 26.39/26.40 never register
  • ToolCallProgressGuard.kt:73 - any exempts batches that also write or build
  • LogWindowCalculator.kt:25 (existing thread) - min_level=error still anchors at line 0
  • ReadLogsHandler.kt:8 (existing thread) - libs/plugin-api.jar still lacks the log API

MINOR

  • ToolCallProgressGuard.kt:122 - maxConsecutiveRepeats KDoc no longer matches
  • ReadLogsHandler.kt:136 (existing thread) - the live-read exemption misses mis-named calls (plausible)
  • PR description (below) - states the old floor, cap and anchor

Previous round, checked against the code at 54b818b:

  • CRITICAL AndroidManifest.xml:41 - fixed: floor 26.39, LogToolHandlers built only when Class.forName finds IdeLogService.
  • IMPORTANT LogWindowCalculator.kt:12 - fixed: MAX_OUTPUT_CHARS is DEFAULT_TOOL_OUTPUT_CHAR_LIMIT - 100.
  • IMPORTANT LogWindowCalculator.kt:25 - partly fixed; reopened for min_level=error.
  • IMPORTANT ReadLogsHandler.kt:8 - not fixed yet (plan agreed); reopened.
  • IMPORTANT ReadLogsHandler.kt:136 - fixed for exact names; the remainder reopened as MINOR.
  • NITPICK LogWindowCalculator.kt:14 - fixed: OutputWindow.kt.

Findings without a diff anchor:

MINOR: The PR description still says the output is capped at 8,000 characters, that the slice anchors at the first crash or error, and that plugin.min_ide_version is bumped to 26.40. The code now caps at 3,900, anchors on the newest, and keeps 26.39. QA testing against the description will check the wrong limits and the wrong compatibility floor. Update those three lines.

Heads-up: #114 removes AgentLoop.DEFAULT_TOOL_OUTPUT_CHAR_LIMIT (the cap moves to ToolResultsPrompt.DEFAULT_CHAR_LIMIT), so whichever of the two merges second needs a one-line change in LogWindowCalculator.

The repo has no written approve/request-changes rule (CLAUDE.md, plugin-review skill), so the default grading applied.

@Daniel-ADFA Daniel-ADFA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes for the IMPORTANT findings in the re-review above: anchor on the newest run (an earlier crash still wins, and min_level=error still anchors at line 0), add the run_app hint only when the log tools are registered, exempt only batches that are all live reads, word the empty-log text without prescribing run_app, and refresh libs/ so AI-Core compiles.

Anchor on the newer of crash/error run, tail all-ERROR reads, exempt only all-log-read batches, gate the run_app hint.

Refs: ADFA-6268
@jatezzz
jatezzz requested a review from Daniel-ADFA October 1, 2026 14:10

@Daniel-ADFA Daniel-ADFA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving, with one condition before merge: the libs refresh in the existing ReadLogsHandler.kt:8 thread, which I've reopened. The two new comments don't block.

IMPORTANT

  • ReadLogsHandler.kt:8 (existing thread, reopened) - libs/plugin-api.jar still has no log API

MINOR

  • LogWindowCalculator.kt:27 - a later ERROR line drops the crash even when both fit

NITPICK - 1 inline, not listed

Round 2 re-check at 61bb72c:

  • Batch exemption: fixed, calls.all at ToolCallProgressGuard.kt:74.
  • Earlier crash winning the anchor: fixed, the newer anchor wins (LogWindowCalculator.kt:24-27). The new MINOR is its flip side, and its fix keeps this.
  • Empty-log text: fixed, ReadLogsHandler.kt:139 no longer mentions run_app.
  • run_app hint on old hosts: fixed, gated on hasLogTools from hostHasLogApi() (BuiltInToolHandlers.kt:33).
  • maxConsecutiveRepeats KDoc: fixed, ToolCallProgressGuard.kt:10.
  • All-ERROR read keeping the oldest lines: fixed, newestErrorRunStart returns null and the window falls back to tail (LogWindowCalculator.kt:103).
  • libs refresh: still open, see the thread.
  • Name normalization in the exemption: not fixed; the reason given (native tool calls return the declared names) holds for a MINOR, so not re-raised.

The addons CLAUDE.md has no written approve/request-changes rule.

@jatezzz
jatezzz merged commit 7143e29 into main Oct 1, 2026
1 check passed
@jatezzz
jatezzz deleted the feat/ADFA-6268-ai-agent-read-log-tools branch October 1, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants