Skip to content

feat: agent-type-aware system prompt with fragment selection#73

Merged
yishuiliunian merged 1 commit intomainfrom
worktree-glittery-wiggling-pine
Apr 4, 2026
Merged

feat: agent-type-aware system prompt with fragment selection#73
yishuiliunian merged 1 commit intomainfrom
worktree-glittery-wiggling-pine

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Thread agent_type through the full IPC spawn pipeline so sub-agent prompts use the correct fragment (explore/plan/default)
  • Remove redundant tool schema duplication from system prompt (~3-5K token savings per turn)
  • Reorder prompt assembly to identity-first for stronger LLM attention on core behavioral rules
  • Enhance agent prompt quality with structured constraints, search strategies, and output formats

Changes

  • loopal-prompt: Add Condition::Agent variant, is_subagent() derived method, registry fallback/exclusion logic
  • loopal-context: Remove tool schema section, add agent_type param to build_system_prompt
  • IPC pipeline (6 crates): Thread agent_type from AgentTool → SpawnParams → Hub → AgentClient → AgentServer → PromptContext
  • Agent prompts: Rewrite explore.md (search strategy + READ-ONLY constraints), plan.md (read-before-design rules + output format), default-subagent.md (behavioral rules)
  • Dead code removal: build_agent_prompt() + default_agent_prompt() superseded by fragment selection

Test plan

  • CI passes (clippy + rustfmt + 48 tests)
  • New unit tests: parse_agent_condition, fragments_come_before_instructions, 3 registry agent selection tests
  • New integration tests: explore_subagent_full_prompt, plan_subagent_gets_plan_fragment, general_subagent_gets_default_fragment, root_agent_excludes_agent_fragments, agent_fragments_have_correct_conditions

…pt quality improvements

Sub-agent prompts were crippled: agent_type never reached PromptContext,
so agent-specific fragments (explore, plan) never matched. Tool schemas
were also duplicated in both the system prompt and the API tools parameter.

Changes:
- Thread agent_type through the full IPC spawn pipeline (6 crates)
- Add Condition::Agent variant so fragments can target specific agent types
- Registry excludes Agents category for root agent; falls back to default
  fragment for unknown types; uses specific fragment when matched
- Remove redundant tool schema section from system prompt (saves ~3-5K tokens)
- Reorder assembly: fragments (identity-first) → instructions → skills → memory
- Enhance explore/plan/default-subagent prompt content with behavioral
  constraints, search strategies, and structured output formats
- Remove dead build_agent_prompt() superseded by fragment selection
- Derive is_subagent() from agent_type.is_some() instead of separate field
@yishuiliunian yishuiliunian force-pushed the worktree-glittery-wiggling-pine branch from c32227c to 83a10ad Compare April 4, 2026 03:03
@yishuiliunian yishuiliunian merged commit f6a1180 into main Apr 4, 2026
3 checks passed
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