Investigate: no auto delegation to the crew #99
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_shrimp#99
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Investigation: no auto delegation to the crew
Summary
The delegation machinery itself is healthy.
delegate_task,delegate_parallel,ask_agent, andrun_crewall resolve targets and dispatch sub-agents correctly. The reason the main agent never auto-delegates to installed crew specialists is a discovery gap: the agent is instructed to delegate to a named crew member, but at runtime it has no way to learn which crew members exist.Root cause
The base system prompt (
crates/hero_shrimp_engine/src/prompts/agent_minimal_base.md, the "Routing multi-step work to specialised crew agents" section) tells the agent to dispatch via:and explicitly references
agent.list("e.g. local-git-implementer, forgejo-tester").But
agent.listis only a server-side JSON-RPC method (crates/hero_shrimp_server/src/rpc/methods/agent.rs:16). It is not a tool in the engine's LLM tool catalog. The model cannot call it. The catalog exposesdelegate_task,delegate_parallel,ask_agent, andrun_crewonly - none of which lists the installed crew.No prompt context provider injects the crew roster either. The default
PromptContextEngine(crates/hero_shrimp_engine/src/agent_core/agent/agent_options.rs:560-574) registers eleven providers (reality, operator-guidance, active-jobs, work-scope, dream-insight, autonomy-lessons, playbook, memory, project-rules, repo-context, persona). None of them surfaces the loaded agent profiles.Net effect: the agent is told to "delegate to an agent from
agent.list" but never sees that list. It therefore either does the work itself (no delegation) or guesses a name that does not resolve, in which casedelegate_taskreturnsunknown agent(delegation_ops.rs:57-67). Either way: no auto delegation to the crew.What already works (not the bug)
delegate_taskresolvesagent: "<name>"->runtime.agent_profile(name)and applies the profile's prompt, tool allowlist, and model override.ask_agentresolves a target via the durable registrydb.list_agents()with idle-aware load balancing.run_crewruns the fixed Researcher -> Planner -> Executor -> Critic pipeline.model:values (commit15c06f4d).Proposed fix
Add a
CrewRosterProviderprompt context provider that injects the installed crew into the system prompt, gated so it is a no-op when there is no crew:RuntimeContext::global().agent_profiles().delegate_taskis present in the active tool slice and at least one crew profile is installed.extends, description) plus a one-line reminder to dispatch viadelegate_task { agent: "<name>" }.Nonewhen no crew is installed, so single-agent behaviour is unchanged.PromptContextEngine::default().This closes the discovery gap so the routing guidance in
agent_minimal_base.mdbecomes actionable, and replaces the danglingagent.listreference with a roster the model can actually see.Fix implemented: crew roster now injected into the system prompt
Closed the discovery gap identified in the investigation above. The agent now sees the installed crew at runtime, so the delegation guidance in
agent_minimal_base.mdis actionable and auto delegation can actually happen.Changes
crates/hero_shrimp_engine/src/agent_core/agent/context_providers.rsCrewRosterProviderprompt context provider. It discovers installed specialists from the loaded profile store (RuntimeContext::global().agent_profiles()— the same setdelegate_task { agent: <name> }resolves against) and injects an[installed crew]section listing each specialist by exact dispatch name, role, and description, with a one-line instruction to delegate viadelegate_task.build_crew_roster_body(has_delegate_task, entries)so the no-op guarantees are unit tested.delegate_taskis not in the active tool slice, or when no crew is installed — single-agent setups are unchanged.crates/hero_shrimp_engine/src/agent_core/agent/agent_options.rsCrewRosterProviderinPromptContextEngine::default()(priority 22, right after persona) and added it to the provider import list.Tests
Added a
crew_roster_testsmodule covering the behaviour:no_section_when_delegate_task_unavailable— no roster when the agent cannot delegate.no_section_when_no_crew_installed— no roster when nothing is installed (single-agent unchanged).lists_each_specialist_with_delegate_instruction— every installed specialist is listed by exact name + role, with thedelegate_taskinstruction.Test results
crew_roster_tests).cargo build -p hero_shrimp_engine: clean.Notes
delegate_task,delegate_parallel,ask_agent,run_crew) was already correct and is unchanged.agent.listreference in the prompt is now backed by a roster the model can actually see. A follow-up could also exposeagent.listas a first-class LLM tool for on-demand lookups, but injecting the roster directly is the lower-friction fix and covers the reported behaviour.Opened PR #110 with the fix (branch
int_delegate_crew->integration, not merged): #110Root causes addressed: the orchestrator could not see the installed crew (dead
agent.listreference, no roster injected), anddelegate_tasksub-agents never wrote to the crew mailbox so delegated work was invisible in the per-member chat threads. The PR injects the crew roster into both the chat and autonomy prompts and bridges delegations into the crew mailbox.