Skip to content

feat(agent): depth-aware delegation + StartAgentParams refactor#87

Merged
yishuiliunian merged 2 commits intomainfrom
feat/agent-depth-awareness
Apr 6, 2026
Merged

feat(agent): depth-aware delegation + StartAgentParams refactor#87
yishuiliunian merged 2 commits intomainfrom
feat/agent-depth-awareness

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Propagate agent depth through full IPC chain (SpawnParams → Hub → StartAgentParams → AgentShared → PromptContext) so each agent sees its nesting level as {{ agent_depth }} in the system prompt
  • Add Delegation Depth section to agent-guidelines.md — deeper agents naturally prefer direct tool use, reducing cascading spawns (previously 129 agents from one task)
  • Refactor AgentClient::start_agent() from 10 positional parameters to StartAgentParams struct
  • Remove max_depth hard limit — depth is informational context, not a gate
  • Deduplicate concurrency guidance: centralized in agent-guidelines.md, removed from explore/plan/default-subagent prompts

Changes

  • crates/loopal-agent-client/StartAgentParams struct, start_agent(&self, p: &StartAgentParams)
  • crates/loopal-agent/SpawnParams.depth, AgentShared removes max_depth
  • crates/loopal-agent-hub/ — dispatch + spawn_manager pass depth through
  • crates/loopal-agent-server/StartParams.depth, agent_setup wires depth into prompt
  • crates/loopal-prompt/PromptContext.agent_depth
  • crates/loopal-context/build_system_prompt() accepts agent_depth
  • crates/loopal-prompt-system/prompts/ — agent-guidelines.md, explore.md, plan.md, default-subagent.md

Test plan

  • CI passes (build + clippy + test, all 50 tests)

…ruct params (#86)

Sub-agents had no awareness of their position in the delegation chain,
leading to cascading spawns (129 agents from a single task). This change:

- Propagates `depth` through the full IPC chain so each agent knows how
  deep it is (rendered as `{{ agent_depth }}` in system prompt)
- Removes the hard `max_depth` limit — depth is informational, not a gate
- Adds Delegation Depth guidance in agent-guidelines.md so deeper agents
  naturally prefer direct tool use over further delegation
- Refactors `start_agent()` from 10 positional params to `StartAgentParams`
- Removes redundant concurrency guidance from agent-type prompts (explore,
  plan, default-subagent) — centralized in agent-guidelines.md
@yishuiliunian yishuiliunian merged commit 8b5eab1 into main Apr 6, 2026
3 checks passed
@yishuiliunian yishuiliunian deleted the feat/agent-depth-awareness branch April 6, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant