Skip to content

Point ability descriptions at the Query Loop for related posts - #147

Closed
fabiankaegy wants to merge 2 commits into
feature/abilitiesfrom
feature/abilities-agent-guidance
Closed

fabiankaegy wants to merge 2 commits into
feature/abilitiesfrom
feature/abilities-agent-guidance

Conversation

@fabiankaegy

@fabiankaegy fabiankaegy commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Description

Stacked on #142.

content-connect/get-related-items returns related IDs. An agent asked to "add related articles" calls it, gets IDs, and pastes them into a post picker. That list goes stale as soon as the relationship changes, and nothing in the ability descriptions suggests a better route.

The ability descriptions are the one thing every MCP client reads, so this PR changes them:

  • The category description says the abilities read relationship data and that related posts on the site come from a Query Loop (core/query) filtered by the relationship.
  • get-related-items says it's for inspecting a relationship, not building content, and why a copied list goes stale.
  • get-post-relationships gets the same pointer, since context: embed also returns related IDs.
  • rel_name in both output schemas now says it's the name used in a relationship query.

Only descriptions change. #148 adds an ability that returns the Query Loop markup and updates these descriptions to name it.

How to test

  1. GET /wp-json/wp-abilities/v1/abilities?category=content-connect shows the new descriptions.
  2. npm run test:php passes.

Changelog Entry

None. This refines the unreleased abilities from #142.

…ated posts

The read-only abilities return related IDs, which agents tend to paste
into a hand-picked list. The descriptions now say to use a Query Loop
filtered by the relationship for display, and rel_name is described as
the relationship query name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread includes/Abilities.php Outdated
array(
'label' => __( 'Content Connect', 'wp-content-connect' ),
'description' => __( 'Post-to-post and post-to-user relationships.', 'wp-content-connect' ),
'description' => __( 'Post-to-post and post-to-user relationships. These abilities read relationship data. To display related posts on the site, use a Query Loop (core/query) block filtered by the relationship, which stays in sync when relationships change.', 'wp-content-connect' ),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The guidance reads as if it covers every relationship, but the Query Loop extension only builds related_to_post filters, and only lists relationships whose post_type includes the loop's post type. Post-to-user relationships get no UI.

"Stays in sync" also overpromises: the block stores a fixed related_to_post (the sourcePost or the post being edited). In a single template or a synced pattern, every post shows the same list. And loops with inherit: true never hit query_loop_block_query_vars, so the filter is ignored there.

Suggested change
'description' => __( 'Post-to-post and post-to-user relationships. These abilities read relationship data. To display related posts on the site, use a Query Loop (core/query) block filtered by the relationship, which stays in sync when relationships change.', 'wp-content-connect' ),
'description' => __( 'Post-to-post and post-to-user relationships. These abilities read relationship data. To display posts related to a specific post, use a Query Loop (core/query) block with the relationship filter set (showRelated, relationshipKey, sourcePost) and inherit set to false; the list updates when that post\'s relationships change. Query Loop filtering supports post-to-post relationships only.', 'wp-content-connect' ),

Comment thread includes/Abilities.php Outdated
array(
'label' => __( 'Get Post Relationships', 'wp-content-connect' ),
'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one.', 'wp-content-connect' ),
'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one. To display related posts on the site, use a Query Loop (core/query) block filtered by the relationship instead of copying the related IDs into content.', 'wp-content-connect' ),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The category description already carries the Query Loop guidance. Repeating it in three strings with different wording means three strings to translate and three places to fix next time. Suggest a short pointer here.

Suggested change
'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one. To display related posts on the site, use a Query Loop (core/query) block filtered by the relationship instead of copying the related IDs into content.', 'wp-content-connect' ),
'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one. Read-only; see the category description for displaying related posts.', 'wp-content-connect' ),

Comment thread includes/Abilities.php Outdated
array(
'label' => __( 'Get Related Items', 'wp-content-connect' ),
'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering.', 'wp-content-connect' ),
'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering. Use it to inspect a relationship, not to build content: to display related posts on the site, use a Query Loop (core/query) block filtered by the relationship. A Query Loop updates when relationships change; IDs copied into a hand-picked list do not.', 'wp-content-connect' ),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This ability returns posts or users, but the guidance only covers posts. For a post-to-user relationship, "not to build content" leaves the agent with no working option, since the Query Loop cannot list users. Scoping it to posts fixes that.

Suggested change
'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering. Use it to inspect a relationship, not to build content: to display related posts on the site, use a Query Loop (core/query) block filtered by the relationship. A Query Loop updates when relationships change; IDs copied into a hand-picked list do not.', 'wp-content-connect' ),
'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering. Use it to inspect a relationship. To display related posts on the site, prefer a Query Loop (core/query) block filtered by the relationship over copying these IDs into content, since a copied list goes stale when the relationship changes.', 'wp-content-connect' ),

Comment thread includes/Abilities.php Outdated
'rel_key' => array( 'type' => 'string' ),
'rel_type' => array( 'type' => 'string' ),
'rel_name' => array( 'type' => 'string' ),
'rel_name' => array(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two problems with the hint:

  1. A segment with only name fails RelationshipQuery::is_valid_segment(), which also requires related_to_post or related_to_user. An agent building [{"name": rel_name}] gets no WHERE clause and the loop returns every post.
  2. rel_name is only unique per post-type pair. The block editor selects by relationshipKey, which matches rel_key. An agent passing rel_name there falls back to relationships[0].
Suggested change
'rel_name' => array(
'rel_name' => array(
'type' => 'string',
'description' => __( 'The relationship name. In a relationship query segment it is `name`, paired with `related_to_post` or `related_to_user`. Not unique across post types; use rel_key to identify a relationship.', 'wp-content-connect' ),
),

The same entry is duplicated in get_relationship_definition_schema() and get_post_relationship_schema(). Suggestion: move into a shared helper, the way get_relationship_side_schema() handles the side fields.

Category description names the filter attributes, needs inherit false,
and says Query Loop filtering is post-to-post only. Other ability
descriptions point back to it. rel_name schema moves to a shared helper
and says it pairs with related_to_post/related_to_user and is not unique
across post types. CHANGELOG credits #147.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

s3rgiosan added a commit that referenced this pull request Dec 3, 2026
Category description names Query Loop filter attributes (showRelated,
relationshipKey, sourcePost), needs inherit false, post-to-post only.
get-post-relationships and get-related-items point to it. rel_name
schema moves to shared helper: pairs with related_to_post or
related_to_user, not unique across post types, use rel_key.

Co-authored-by: Sérgio Santos <me@s3rgiosan.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@s3rgiosan s3rgiosan closed this Dec 3, 2026
@s3rgiosan s3rgiosan reopened this Dec 3, 2026
@s3rgiosan

Copy link
Copy Markdown
Member

This change is on feature/abilities as 3114f93. It is a squash of 439e1f4 and 21626a2.

21626a2 applies the suggestions from my review. The changelog credits you for this change.

GitHub did not let me merge this PR. A stacked PR merges only through the async merge API, and that operation also merges the downstack PRs. Here, it would also merge #142 into develop.

#148 now has conflicts with its base. It needs a rebase onto feature/abilities.

@s3rgiosan s3rgiosan closed this Dec 3, 2026
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.

3 participants