<language_directive>
IMPORTANT LANGUAGE INSTRUCTION: Return the final JSON fields in the same language as the first user message unless the message itself clearly requests another language.
</language_directive>

<task>
Return one JSON object for conversation title optimization after the first accepted user message.
The response MUST follow UTF-8 without BOM semantics. Do not emit hidden characters before the opening `{`.
</task>

<input>
<current_title>{{ currentTitle }}</current_title>
<first_user_message>
{{{ firstUserMessage }}}
</first_user_message>
{{#if dungeonSettings}}
<dungeon_settings>
<script_key>{{ dungeonSettings.ScriptKey }}</script_key>
<selected_hero_id>{{ dungeonSettings.SelectedHeroId }}</selected_hero_id>
<captain_hero_id>{{ dungeonSettings.CaptainHeroId }}</captain_hero_id>
<roster_id>{{ dungeonSettings.RosterId }}</roster_id>
{{#if dungeonSettings.ExtensionFields}}
<extension_fields>
{{#each dungeonSettings.ExtensionFields}}
<field key="{{ @key }}">{{ this }}</field>
{{/each}}
</extension_fields>
{{/if}}
</dungeon_settings>
{{/if}}
</input>

<requirements>
- Generate a concise, specific conversation title derived from the user's request.
- Prefer the user's concrete problem, feature, incident, or artifact over generic words like "chat", "new session", or "conversation".
- Keep the title readable in a session list.
- Use the same language as the first user message unless the message explicitly asks for another language.
- Avoid quotation marks, markdown, emojis, numbering, trailing punctuation, and boilerplate prefixes.
- Keep it short: usually within 12 English words or an equivalent concise length.
- If the first message does not provide enough signal for a better title, return an empty string.
</requirements>

<output_contract>
Return JSON only. No markdown fence. No commentary.
The first emitted character must be `{`.
JSON shape:
{
  "optimizedTitle": "string",
  "dungeonSettings": {
    "scriptKey": "optional string",
    "selectedHeroId": "optional string",
    "captainHeroId": "optional string",
    "rosterId": "optional string",
    "extensionFields": {
      "futureKey": "optional string"
    }
  }
}

- `optimizedTitle` is required, but MAY be an empty string when the first message is too vague.
- `dungeonSettings` is optional; when present, echo or lightly normalize the provided fields.
- Preserve partial `dungeonSettings` objects when useful instead of failing the whole response.
</output_contract>
