Skip to content

rewrite-list: always return a sample of rules, not just the count #113

Description

@pluginslab

Problem

"List Rewrite Rules" returns only "Found 272 rewrite rules" with no actual rules shown.

Reported by @wpbullet in #56.

Root cause

The PHP backend has a show_details parameter that defaults to false. Without it, only rules_count and permalink_structure are returned — no actual rule patterns. The LLM never passes show_details: true because the system prompt only shows the tool description, not input parameters.

Verified via Ollama round-trip test:

  • LLM sends: {"action": "tool_call", "tool": "wp-agentic-admin/rewrite-list", "args": {}}
  • PHP returns: { rules_count: 272, permalink_structure: "/%postname%/" } (no rules)
  • LLM answers: "Found 272 rewrite rules with permalink structure /%postname%/."

Proposed fix

Remove the show_details flag and always return a useful sample of rules. With 272 rules and a 2000-char tool result truncation limit, returning all rules would overflow. Instead:

  1. Always include top ~20 rules grouped by pattern type (post, page, category, tag, feed, sitemap, etc.)
  2. Include a category summary — e.g., "45 post rules, 12 category rules, 8 feed rules..."
  3. Remove the show_details parameter — it adds complexity the LLM can't use
// Always return a sample of rules grouped by type
$result['rule_sample'] = array_slice( $rules_array, 0, 20 );
$result['rule_categories'] = $categorized_counts; // e.g., ['post' => 45, 'page' => 12, ...]

Files to modify

  • includes/abilities/rewrite-list.php — remove show_details, always return sample + categories

Refs

Closes #56

Activity

  1. added a commit that references this issue on Mar 21, 2026
    4bcc3a5
  2. pluginslab commented on Mar 22, 2026

    @pluginslab
    OwnerAuthor

    Closed by PR #159 — categorized rules with balanced sampling

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions