Overview

I am not able to edit a code component. Getting the below response from the component agent

'The 'edit component' functionality is only available on component edit route.'

Model used: OpenAI gpt 4.1

Proposed resolution

User interface changes

Comments

akhil babu created an issue. See original summary.

akhil babu’s picture

This response is triggered from the following section of the component agent's prompt.

CRITICAL FLOW GATEKEEPER:
  - **TERMINAL EDIT CHECK:** If the user's request is an instruction to **modify, edit, change, or update** a component and the context variable `[canvas_ai:selected_component]` is null, this is a **TERMINAL FAILURE**.
    - You **MUST STOP** all further processing immediately.
    - Your **ONLY** response MUST be the exact string: **"The 'edit component' functionality is only available on component edit route."**
    - Do NOT add any extra text, explanation, apology, or tool output.
    - Do NOT proceed to any other flow or use any tool.

Within the prompt we are asking the agent to check if the variable `[canvas_ai:selected_component]` is null. But as [canvas_ai:selected_component] is a token, its value gets replaced before the prompt is sent to the agent. If the component name is 'hero_banner', then the instruction becomes

- **TERMINAL EDIT CHECK:** If the user's request is an instruction to **modify, edit, change, or update** a component and the context variable <em>hero_banner</em> is null, this is a **TERMINAL FAILURE**.
Which does't make sense.

We should leverage the [canvas_ai:get_verbose_context_for_orchestrator] token here. If user is editing a componnet, then the tokens value becomes
User is now in the code component editor, viewing a code component with id hero_banner

So within the instructions of we can add an instruction like

'Validate the component data before attempting an edit. Only proceed if the user is currently in the code component editor, and ensure you use the exact id from the component data.'

then at the end of the prompt we can add
##Component data
[canvas_ai:get_verbose_context_for_orchestrator]

akhil babu’s picture

Issue summary: View changes
rakhimandhania’s picture

Issue tags: +AI Innovation
rakhimandhania’s picture

Issue tags: +AI Page Generation
rakhimandhania’s picture

akhil babu’s picture

Status: Active » Closed (duplicate)
Related issues: +#3584136: Canvas AI - Not able to create the components

This should get fixed once #3584136: Canvas AI - Not able to create the components lands. So closing as duplicate

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.