Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

error-log-read: fails to summarize when debug.log has many entries

Open
#107 1 comment 0 reactions 1 assignee View on GitHub

@janvogt is already working on this.

Since Mar 21, 2026.

Assessment

This issue has not been assessed yet.

Description

bug
Problem

When WP_DEBUG is enabled and debug.log contains entries, the agent returns "I had trouble understanding how to help" instead of showing the log contents.

Reported by @wpbullet in #92.

What works
  • Selection: Tool selection now routes correctly (fixed in PR #102, test passes)
  • PHP backend: Code is solid — reads last N lines via SplFileObject, handles all edge cases (missing file, debug disabled, empty log)
  • Small results: When debug.log is empty or debug is disabled, the ability works (small JSON response)
Root cause

The failure happens on the second LLM iteration — after the tool executes and returns data. With a populated debug.log, the tool returns up to 50 lines of PHP errors. Even after truncation to 2000 chars (maxToolResultLength), the combined context of:

  • System prompt (~800 tokens with 31 tools listed)
  • User message
  • First LLM response (tool_call JSON)
  • Tool result (2000 chars of error log entries)
  • JSON format reminder suffix

…likely exceeds the 4096-token context window of Qwen 3 1.7B, causing the model to produce malformed output that fails JSON parsing → triggers the "I had trouble understanding" fallback (line 273 of react-agent.js).

Proposed fixes
A. Use interpretResult to pre-summarize before sending to LLM

The interpretResult function already exists in the JS ability and produces a concise summary like "Found 50 error entries (out of 150 total lines)." Instead of sending the raw truncated JSON to the LLM, use interpretResult to compress the result before the second iteration. This would drastically reduce token usage.

This is potentially a general improvement for all abilities — using interpretResult as a pre-filter for the LLM's tool result message, especially on the 1.7B model with its tight context window.

B. Reduce default line count for 1.7B context

The PHP backend defaults to 50 lines. For a 4096-token model, even 10 lines of verbose PHP errors can be too much after truncation. Consider:

  • Reducing the default to 20 lines
  • Or dynamically adjusting based on the model's context size
C. Smarter truncation in the tool result

Instead of blindly truncating at 2000 chars (which may cut mid-entry), truncate at entry boundaries and include a count: "Showing 5 of 50 entries: [entry1], [entry2], ..."

Files involved
  • src/extensions/services/react-agent.js — buildToolResultMessage() (line 774), maxToolResultLength config
  • src/extensions/abilities/error-log-read.js — interpretResult() already exists
  • includes/abilities/error-log-read.php — default line count
Scenarios from #92
Scenario Expected Actual
No WP_DEBUG, no debug.log "No debug.log found" "I had trouble understanding" (selection fail, now fixed)
No WP_DEBUG, empty debug.log Debug disabled message Works correctly
WP_DEBUG on, populated debug.log Show error entries "I had trouble understanding" (context overflow)
Refs

Refs #92 (selection part fixed in PR #102, this covers the result processing)

Dominant language
JavaScript
Stars
28
Forks
6
Avg merge
9h 16m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pluginslab/wp-agentic-admin

All issues in pluginslab/wp-agentic-admin

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.