Skip to content

get_content_by_route throws JSON cycle error on deep content type composition #173

@andy-ub

Description

@andy-ub

Which component is this issue related to?

Umbraco.AI.Agent.Copilot

Which Umbraco AI version are you using? (Please write the exact version, example: 10.1.0)

1.0.0

Bug summary

get_content_by_route throws JSON cycle / max-depth error when serializing
deeply composed content types. The agent run aborts and the Copilot sidebar
chat bubble shows a raw System.Text.Json error wall.

Error message:
A possible object cycle was detected. This can either be due to a cycle or
if the object depth is larger than the maximum allowed depth of 64.
Path: $.Content.Properties.Value.Content.ContentType.PropertyTypes.ContentType.PropertyTypes... (repeats)

Suspected cause: the object graph passed to System.Text.Json contains the
recursive Content → Properties → Value → Content → ContentType → PropertyTypes
back-reference. Default JsonSerializerOptions max depth = 64, so any page
with deep type composition exhausts the depth budget.

Suggested fix: project to a flat DTO before serialization (preferred — keeps
the LLM payload small), or use ReferenceHandler.Preserve.

Specifics

No response

Steps to reproduce

  1. Set up Umbraco backoffice with the Copilot sidebar enabled.
  2. Configure any agent whose tool surface includes get_content_by_route
    (e.g. a Marketer Agent on the Umbraco.Engage.TestSite, Umbraco 17 + Engage 17, DeepSeek provider).
  3. Open the Copilot sidebar and send a prompt that nudges the LLM to fetch page content, for example:
    "which product pages are getting the most attention recently, and where should I focus my next campaign?"
  4. The LLM will run Engage analytics tools first (these succeed), then choose to call get_content_by_route for one or more product pages.
  5. When get_content_by_route runs against a page whose content type has deep property-type composition, the cycle error fires and the agent run aborts.
Image

Browser console at time of failure:

[run.controller.ts:288 Run error: Error: A possible object cycle was detected...
    at #r (uai-agent-client.ts:241:43)
    at Object.next (uai-agent-client.ts:157:39)](run.controller.ts:288 Run error: Error: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.Content.Properties.Value.Content.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType.PropertyTypes.ContentType)

Non-deterministic — same prompt sometimes does NOT trigger get_content_by_route at all, in which case the conversation completes cleanly. Repro requires the LLM to actually invoke the tool.

Expected result / actual result

No response

Dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions