Allow packages to format their property values for the AI content tools

Open
#809 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Start by reading the existing IAIPropertyValueHandler pattern, ContentToolHelpers, and PropertyValueFormatter in the v17/main source. Trace how properties are read with culture and how built-in formatting is selected, then assess the proposed formatter registration and fallback behavior. Done means packages can register a formatter by editor schema alias and the built-in rules remain the fallback; the issue does not name specific files or tests.

Written by the indexing model from the issue text.

Description

enhancement state/ready

Problem

The content tools (get_umbraco_content and others built on ContentToolHelpers) pass every property through PropertyValueFormatter. That class is internal and has rules only for core editors:

  • rich text and Markdown are stripped to plain text;
  • media and content pickers are reduced to name and URL;
  • blocks are recursed;
  • strings are truncated.

Every other editor's converted value goes to the model unchanged.

For a package editor whose value converter builds a rich model, that has three effects:

  1. Large tool output. Our editor stores a small selection (about 200 bytes of JSON). Its converter turns that into the full content the front end renders, 9–34 KB per property. The model receives all of it on every page read: about 80 KB for one test page with five such properties, while a summary of a few hundred bytes would do.
  2. No access to the stored value. To edit the property, the model needs the stored value, but it only ever sees the converted one. We worked around this with our own tool that reads the stored value.
  3. The culture doesn't reach the converter. The property is read with GetValue(culture), but a converter that picks its output language from IVariationContextAccessor still sees the request's culture. On a culture-variant page the model gets the default language.

Proposal

An extension point that follows the existing IAIPropertyValueHandler pattern:

public interface IAIPropertyValueFormatter : IDiscoverable
{
    string ForPropertyEditorSchemaAlias { get; }

    // Return what the model should see for this property; null falls back to the built-in rules.
    object? Format(IPublishedProperty property, string? culture);
}

Registered through builder.AIPropertyValueFormatters() and discovered automatically, with the built-in rules as the fallback. A package could then give the model a compact, culture-aware summary of its value instead of the full model.

Setting the variation context to the requested culture while formatting would also solve point 3 for every converter, independently of this proposal.

Environment: Umbraco 17.6.2, Umbraco.AI 17.8.2 (confirmed against the v17/main source).

Dominant language
C#
Stars
36
Forks
29
Avg merge
4h 54m
Merged PRs (30d)
105

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 umbraco/Umbraco.AI

All issues in umbraco/Umbraco.AI

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.