Skip to content
Back to skills

Dual Role Agent Dispatch

ASecurity

Single agent entry point that dispatches between multiple roles (ask/answer/guess) based on turn type, combining heuristic and LLM-based strategies

  • 61 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
ai-agentspythongo

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill dual-role-agent-dispatch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dual Role Agent Dispatch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dual Role Agent Dispatch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-dual-role-agent-dispatch/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-dual-role-agent-dispatch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: llm-dual-role-agent-dispatch
description: Single agent entry point that dispatches between multiple roles (ask/answer/guess) based on turn type, combining heuristic and LLM-based strategies
---

# Dual-Role Agent Dispatch

## Overview

In multi-agent environments where one agent serves multiple roles (questioner, answerer, guesser), use a single dispatch function that routes to different strategies based on the turn type. This allows mixing heuristic logic (structured questions, keyword lookup) with LLM inference (open-ended answering) in one agent, and lazy-loads models only for roles that need them.

## Quick Start

```python
def agent_fn(obs, cfg):
    if obs.turnType == "ask":
        return ask_question(obs)
    elif obs.turnType == "answer":
        return answer_question(obs)
    elif obs.turnType == "guess":
        return make_guess(obs)

def ask_question(obs):
    # Heuristic: structured binary search questions
    return f"Is it a {CATEGORIES[state['cat_idx']]}?"

def answer_question(obs):
    # Quick check: keyword in question?
    if obs.keyword.lower() in obs.questions[-1].lower():
        return "yes"
    # Fall back to LLM
    return llm_yes_no(obs.questions[-1], obs.keyword)

def make_guess(obs):
    # Filter candidates by accumulated answers, pick best
    remaining = filter_candidates(obs)
    return remaining.iloc[0]['keyword'] if len(remaining) > 0 else "unknown"
```

## Workflow

1. Define a single `agent_fn(obs, cfg)` entry point
2. Branch on `obs.turnType` to route to role-specific logic
3. Use heuristic strategies where possible (cheaper, deterministic)
4. Fall back to LLM only when heuristic is insufficient
5. Lazy-load the model on first LLM call to save memory

## Key Decisions

- **Heuristic first**: structured questions and keyword matching don't need LLM inference
- **Lazy loading**: don't load the model until the answerer role is actually invoked
- **Shared state**: use module-level variables or a class to persist state across turns
- **Fallback**: always return a valid response — empty/None can crash the environment

## References

- [Starter Code for Llama 8B LLM - [LB 0.750+]](https://www.kaggle.com/code/cdeotte/starter-code-for-llama-8b-llm-lb-0-750)
- [llama3-8b- LLM20 Questions [LB 750]](https://www.kaggle.com/code/wouldyoujustfocus/llama3-8b-llm20-questions-lb-750)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…