fix(voice): leave aliases a layer id already spells out of the alias hint

The set_layer_visibility layerId hint listed aliases such as "dams" for
local-dams and "weather radar" for weather-radar, which the id in the
enum already says. Leaving those out, and a layer with no other alias,
cuts the Realtime prompt from 52,000 to 51,695 characters. Aliases the id
does not spell (aqhi, hurricanes, clouds) stay, and the runner still
accepts every alias. Refs #1363.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
quanticsoul4772andClaude Opus 5.5 committed 2026-10-28 20:11:55 -07:00
1 parent f2c6ff082d
commit 45ae1095da
4 files changed
+38 -7

No files matched your search

+3 -2
View File
@@ -1055,10 +1055,11 @@ test('the voice TOOL SCHEMA matches the pinned contract — the mission mapping
// Panel adds timeout and named voice/provider targets; consolidated guidance
// preserves the mission mapping and globe-rotation arguments.
// S2 GhostMaps extends the generated layer enums; both feature contracts remain.
assert.equal(block.length, 31206, 'serialized tool schema length drifted');
// The layer alias hint leaves out aliases the layer id already spells.
assert.equal(block.length, 30901, 'serialized tool schema length drifted');
assert.equal(
crypto.createHash('sha256').update(block).digest('hex'),
'f772df95404494bf492e02fde1beabffdfe61986940bffd0cf9ad5a38d768746',
'9e1bd8fde648953c47718ba248758415a95c1484b0da6369df6b89b0505c0de2',
'the first-run missions must ride EXISTING tools: no schema edit, no cache bust',
);
const instructions = fs.readFileSync(
+2 -1
View File
@@ -45,7 +45,8 @@ test('the complete Realtime tool payload pins the manifest-generated layer relea
// S2 GhostMaps extends the generated layer enums.
// Panel adds named voice targets and timeout; shared Panel/Cockpit guidance
// is consolidated without changing either feature's arguments.
'9ee82c4214499280c208c93751b19d7b724c81b7727a2d0c6dab0184749fbe15',
// The layer alias hint leaves out aliases the layer id already spells.
'188e9eaaee1d5c21fc88493ba244569f4af9cfba61bb240c52ecd32b49b18caa',
);
});
+15 -4
View File
@@ -529,18 +529,29 @@ const SELF_EVIDENT_IDS = new Set([
's2-ghostmaps',
]);
/** Lower case with spaces and hyphens removed: "Data centers" → "datacenters". */
const spelled = (text) => text.toLowerCase().replace(/[\s-]+/g, '');
/**
* Compact model-facing alias hint: "alias/alias→id; …" for toggleable layers
* whose id is not already the spoken word. At most two aliases per layer keep
* the tool JSON small; the runner accepts the full alias list.
* the tool JSON small; the runner accepts the full alias list. An alias the id
* already spells ("dams"→local-dams, "weather radar"→weather-radar) is left
* out, and so is a layer with no other alias.
* @returns {string} One line for the layerId description.
*/
export function voiceLayerAliasHint() {
return VOICE_LAYER_MANIFEST.filter(
(entry) =>
entry.toggle && entry.aliases.length && !SELF_EVIDENT_IDS.has(entry.id),
(entry) => entry.toggle && !SELF_EVIDENT_IDS.has(entry.id),
)
.map((entry) => `${entry.aliases.slice(0, 2).join('/')}→${entry.id}`)
.map((entry) => ({
id: entry.id,
aliases: entry.aliases
.slice(0, 2)
.filter((alias) => !spelled(entry.id).includes(spelled(alias))),
}))
.filter((entry) => entry.aliases.length)
.map((entry) => `${entry.aliases.join('/')}→${entry.id}`)
.join(';');
}
+18
View File
@@ -9,6 +9,7 @@ import {
VOICE_TOGGLE_LAYER_IDS,
VOICE_CONTEXT_LAYER_IDS,
VOICE_QUERY_LAYER_IDS,
voiceLayerAliasHint,
voiceLayerAliasMap,
} from './layerManifest.js';
@@ -78,6 +79,23 @@ test('tool enums are generated from the manifest', () => {
assert.ok(panels.includes('weather-panel') && panels.includes('recent-imagery-panel'));
});
test('the alias hint leaves out names the layer id already spells', () => {
const hint = voiceLayerAliasHint();
const entries = hint.split(';').map((entry) => entry.split('→'));
const flat = (text) => text.toLowerCase().replace(/[\s-]+/g, '');
for (const [aliases, id] of entries) {
for (const alias of aliases.split('/')) {
assert.ok(!flat(id).includes(flat(alias)), `"${alias}" is already spelled by ${id}`);
}
}
const ids = entries.map(([, id]) => id);
assert.ok(!ids.includes('local-dams'), 'a layer left with no alias gets no entry');
assert.ok(!ids.includes('weather-radar'));
assert.match(hint, /(^|;)aqhi→air-quality(;|$)/, 'an alias the id does not spell stays');
assert.match(hint, /(^|;)hurricanes→weather-cyclones(;|$)/);
assert.match(hint, /(^|;)fires\/wildfires→local-firms(;|$)/);
});
test('spoken aliases resolve to real layers, keep every legacy phrase and never collide', () => {
const aliases = voiceLayerAliasMap();
for (const id of aliases.values()) assert.ok(manifestIds.includes(id), id);