refactor: agent-driven handover, drop gateway-side classifier - #1
Conversation
Removes the LLM classifier and phrase trigger paths from the pre_gateway_dispatch hook. Activation is now exclusively the trigger_handover tool's responsibility, called by the main agent with full conversation context. The plugin's pre-dispatch hook retains silent ingest for active-handover sessions and listens for the owner /takeback command. Motivation: - LLM classifier added one aux-LLM call per non-phrase DM, blind to conversation context. The main agent's normal turn already has full context; classifying twice was wasteful. - Phrase triggers were unreliable across the multi-language deployments these profiles serve (zh / ms / en mixed). Removed: LLMClassifierConfig, HandoverTriggers, llm_classifier_says_handover, _extract_completion_text, matches_phrases, the phrase + classifier branches in rules/handover.py, related tests, and dead config.example / README references. plugin.yaml bumped to 0.2.0. Kept: trigger_handover tool (state.activate path unchanged), state.py, rules/listen_only.py, notify.py, /takeback exit handling.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
WalkthroughThe handover mechanism is refactored to shift activation responsibility from the gateway to the agent. Gateway-side phrase matching and LLM classifier triggers are removed entirely. Activation now occurs exclusively through the agent-callable Changes
Sequence Diagram(s)sequenceDiagram
participant Agent
participant Gateway as Gateway<br/>(handover rule)
participant State as State<br/>(handovers)
participant Owner
participant Customer
rect rgba(200, 150, 100, 0.5)
Note over Agent,State: Activation (Agent-Driven)
Agent->>State: trigger_handover(chat_id)
State->>State: Set handover active
end
rect rgba(100, 150, 200, 0.5)
Note over Gateway,Owner: Gateway Enforcement
Customer->>Gateway: Send message
Gateway->>State: Check is_active()?
State-->>Gateway: true
Gateway->>Gateway: Silent ingest<br/>(no transcript to chat)
Gateway->>Owner: Notify owner
Owner->>Customer: Send /takeback
Owner->>Gateway: /takeback command
Gateway->>State: Deactivate handover
Gateway-->>Customer: handover_exit
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~40 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Consolidates handover activation onto the agent-callable
trigger_handovertool and removes the gateway's own pre-dispatch classification paths (phrase match + auxiliary LLM classifier). The pre-dispatch hook now only enforces an already active handover (silent ingest + owner/takeback) and the listen-only flow.Motivation
AGENTS.md, not in plugin config.Removed
LLMClassifierConfig,HandoverTriggersconfig dataclassesllm_classifier_says_handover+_extract_completion_textmatches_phrasesrules/handover.pyconfig.example.yaml/README.md/after-install.mdreferences totriggers:/phrases/llm_classifierKept
trigger_handovertool (thestate.handovers.activatepath is unchanged)state.py,notify.py,transcript_utils.pyrules/listen_only.py(untouched)/takebackexit handling inrules/handover.pyVersion bump
plugin.yaml:0.1.0→0.2.0. (Not bumpingpyproject.toml; no version pinned there.)Consumer impact
Path-installed / symlinked profiles need a gateway restart to pick up the new code:
Profiles are not required to change
config.yaml; any leftovertriggers:block underplugins.gateway-policy.handoveris silently ignored by the new loader.Test plan
pytest -xpasses (22/22)hermes gateway restart -p basketball-jersey-demo, tail gateway logs, confirmgateway-policy loaded: ... handover=True, tool=Trueand no errors.Summary by CodeRabbit
Breaking Changes
trigger_handovertool; gateway-side phrase and LLM classifier triggers have been removed.Configuration Updates
notify_on_activateandnotify_on_exittemplates with updated placeholders.Chores