Canvas AI: Chatbot generates page title and description without user request
## Summary
When a user opens a blank canvas page and sends a simple message like "Hi", the AI chatbot sometimes immediately generates a page title and description — even though the user did not ask for it. This is unexpected and confusing behaviour.
## Steps to reproduce
1. Open a canvas page that has no title and no description.
2. Open the AI chatbot panel.
3. Type "Hi" and send.
4. Observe that the chatbot may generate a page title and/or description without being prompted to do so.
## Root cause
`CanvasAiPageBuilderHelper::generateVerboseContextForOrchestrator()` in `modules/canvas_ai/src/CanvasAiPageBuilderHelper.php` builds the context string that gets sent to the AI alongside the user's message.
When a canvas page has no title (or title is `"Untitled page"`), the method appends:
```
Page title is empty. GENERATE THE TITLE FOR THE PAGE using canvas_title_generation_agent. This is a **CRITICAL** step to ensure that request is successful.
```
When a canvas page has no description, it appends:
```
Page description is empty. GENERATE THE DESCRIPTION FOR THE PAGE using canvas_metadata_generation_agent. This is a **CRITICAL** step to ensure that request is successful.
```
These imperative instructions were added as a workaround because Claude Sonnet 3.7 — the model used in tests at the time — was not reliably triggering the title and metadata agents without them. Claude Sonnet 3.7 has since been deprecated. Current models can infer this behaviour from the orchestrator's system prompt without these hard-coded overrides. The workaround now actively causes the problem described above.
The same strings appear in the user-message `content` fields of several test cases in `modules/canvas_ai/tests/modules/canvas_ai_agents_test/tests/test_canvas_ai_orchestrator_agent_test_group.yaml` — specifically tests 6, 7, 8, 10, 11, 12, and 14.
## What needs to change
**1. `modules/canvas_ai/src/CanvasAiPageBuilderHelper.php`**
Remove the imperative override text from the two branches in `generateVerboseContextForOrchestrator()`.
Empty-title branch:
```php
// Before
$base_message .= 'Page title is empty. GENERATE THE TITLE FOR THE PAGE using canvas_title_generation_agent. This is a **CRITICAL** step to ensure that request is successful. ';
// After
$base_message .= 'Page title is empty. ';
```
Empty-description branch:
```php
// Before
$base_message .= 'Page description is empty. GENERATE THE DESCRIPTION FOR THE PAGE using canvas_metadata_generation_agent. This is a **CRITICAL** step to ensure that request is successful.';
// After
$base_message .= 'Page description is empty.';
```
**2. `modules/canvas_ai/tests/modules/canvas_ai_agents_test/tests/test_canvas_ai_orchestrator_agent_test_group.yaml`**
Strip the same override strings from the `content` of each affected user message. For example, in test 6:
```
# Before
Page title is empty. GENERATE THE TITLE FOR THE PAGE using canvas_title_generation_agent. This is a **CRITICAL** step to ensure that request is successful. Page description is empty. GENERATE THE DESCRIPTION FOR THE PAGE using canvas_metadata_generation_agent. This is a **CRITICAL** step to ensure that request is successful.
# After
Page title is empty. Page description is empty.
```
Apply the same trim to every test case that contains either override string.
## How to run the tests
See `modules/canvas_ai/tests/modules/canvas_ai_agents_test/README.md`. Run the test group against `gpt-4.1`.
## Acceptance criteria
- [ ] The `GENERATE THE TITLE FOR THE PAGE...` and `GENERATE THE DESCRIPTION FOR THE PAGE...` strings are removed from `generateVerboseContextForOrchestrator()`.
- [ ] The same strings are removed from all affected user message inputs in the test YAML.
- [ ] Sending a vague message (e.g. "Hi") on a blank page does **not** trigger title or description generation.
- [ ] When the user requests page content on a page with an empty title or description, the orchestrator still calls the title and metadata agents.
- [ ] All tests in `test_canvas_ai_orchestrator_agent_test_group.yaml` pass when run as per the README against `gpt-4.1`.
---
_This issue was drafted with AI assistance as part of a local development workflow. The diagnosis, file paths, and line numbers were verified against the current codebase._
issue