Skip to content

Commit 521c37c

Browse files
author
Jonathan Rehem
committed
fix(guild): register capitalized subagent_type alias for all builtin agents
ConfigHandler.applyAgentConfig only registered each builtin agent under its lowercase config key and full display name (e.g. "ranger" and "Ranger (Specialist)"). When an LLM-driven agent capitalized the value (e.g. Task(subagent_type="Ranger")), OpenCode's case-sensitive agent lookup failed with "Unknown agent type", silently falling back to the generic "general" agent instead of the intended Guild specialist. Confirmed via a real Fighter execution session (SQLite-backed OpenCode session history): 3 consecutive "Ranger" delegation failures before the model gave up and routed all 6 plan tasks through "general". - config-handler.ts: register a third capitalized-first-letter alias key per agent, guarded against colliding with the display-name key. - bard/fighter prompt-composer.ts: harden delegation instructions with an explicit case-sensitivity warning and correct/incorrect example. Runtime interception (normalizing subagent_type case in plugin-adapter.ts's tool.execute.before hook) was considered and is tracked as deferred technical debt in .guild/plans/subagent-type-case-fix/state.md — blocked on an upstream OpenCode bug (anomalyco/opencode#31680 / PR #31693) where args mutations in that hook are currently discarded.
1 parent b554ec3 commit 521c37c

6 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎packages/guild/src/agents/bard/prompt-composer.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ describe("buildDelegationSection", () => {
147147
expect(section).toContain("Delegate aggressively")
148148
})
149149

150+
it("warns that subagent_type is case-sensitive for Ranger delegation", () => {
151+
const section = buildDelegationSection(new Set())
152+
expect(section).toContain('subagent_type="ranger"')
153+
expect(section).toContain("case-sensitive")
154+
})
155+
150156
it("mentions visible Weft review variants when configured", () => {
151157
const section = buildDelegationSection(new Set(), [
152158
{

‎packages/guild/src/agents/bard/prompt-composer.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function buildDelegationSection(disabled: Set<string>, reviewModelVariant
102102
}
103103
if (isAgentEnabled("ranger", disabled)) {
104104
lines.push(
105-
"- Use the Task tool to delegate to Ranger (subagent_type=\"Ranger (Specialist)\") for category-specific specialist work when the main need is domain expertise rather than planning or scoping",
105+
"- Use the Task tool to delegate to Ranger (subagent_type=\"ranger\") for category-specific specialist work when the main need is domain expertise rather than planning or scoping. subagent_type is case-sensitive — always lowercase (e.g. \"ranger\", not \"Ranger\").",
106106
)
107107
}
108108
if (isAgentEnabled("cleric", disabled)) {

‎packages/guild/src/agents/fighter/prompt-composer.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ describe("individual fighter section builders", () => {
229229
expect(section).toContain("ranger")
230230
})
231231

232+
it("warns that subagent_type is case-sensitive (both category and non-category branches)", () => {
233+
const noCategorySection = buildTapestryDelegationSection()
234+
expect(noCategorySection).toContain("case-sensitive")
235+
236+
const categorySection = buildTapestryDelegationSection(["frontend"])
237+
expect(categorySection).toContain("case-sensitive")
238+
})
239+
232240
it("buildTapestryDelegationSection contains delegation contract fields", () => {
233241
const section = buildTapestryDelegationSection()
234242
expect(section).toContain("What")

‎packages/guild/src/agents/fighter/prompt-composer.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ RULES:
179179
- Read .guild/runtime/sessions/{plan-name}.md before delegating — include relevant entries
180180
- Include context from completed tasks only when it directly affects the current task
181181
- Use ${subagentType}
182+
- subagent_type is case-sensitive — always lowercase (e.g. "ranger", never "Ranger"; "ranger-frontend", never "Ranger-Frontend")
182183
- Do NOT implement the work yourself — delegate everything to Ranger
183184
</Delegation>`
184185
}

‎packages/guild/src/managers/config-handler.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ describe("ConfigHandler", () => {
5757
expect(result.agents["rogue"]).toBeDefined()
5858
})
5959

60+
it("registers a capitalized-first-letter alias for every builtin agent (Task subagent_type case-mismatch fix)", async () => {
61+
const handler = new ConfigHandler({ pluginConfig: {} })
62+
const allBuiltins: Record<string, AgentConfig> = {
63+
bard: { model: "m" }, fighter: { model: "m" }, ranger: { model: "m" },
64+
wizard: { model: "m" }, rogue: { model: "m" }, warlock: { model: "m" },
65+
cleric: { model: "m" }, paladin: { model: "m" },
66+
}
67+
68+
const result = await handler.handle({
69+
pluginConfig: {},
70+
agents: allBuiltins,
71+
availableTools: [],
72+
})
73+
74+
for (const name of Object.keys(allBuiltins)) {
75+
const capitalized = name.charAt(0).toUpperCase() + name.slice(1)
76+
expect(result.agents[capitalized]).toBeDefined()
77+
expect(result.agents[capitalized]).toEqual(result.agents[name])
78+
}
79+
})
80+
6081
it("sets defaultAgent to bard display name", async () => {
6182
const handler = new ConfigHandler({ pluginConfig: {} })
6283

‎packages/guild/src/managers/config-handler.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ export class ConfigHandler {
104104
if (name !== displayName) {
105105
result[name] = merged
106106
}
107+
108+
const capitalizedAlias = name.charAt(0).toUpperCase() + name.slice(1)
109+
if (capitalizedAlias !== displayName && capitalizedAlias !== name && !result[capitalizedAlias]) {
110+
result[capitalizedAlias] = merged
111+
}
107112
}
108113

109114
return result

0 commit comments

Comments
 (0)