Fix(cli): detect resolve intent and report intent_source#1006
Fix(cli): detect resolve intent and report intent_source#1006AdityaPainuli wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe resolve CLI now detects intent from task text when ChangesResolve intent selection
Sequence Diagram(s)sequenceDiagram
participant User
participant ResolveCommand
participant IntentDetector
participant ResolveRequest
participant ResponseEnvelope
User->>ResolveCommand: run resolve with task
ResolveCommand->>IntentDetector: detect intent when --intent is omitted
IntentDetector-->>ResolveCommand: intent or no match
ResolveCommand->>ResolveRequest: set intent and intent_source metadata
ResolveRequest-->>ResponseEnvelope: provide resolve metadata
ResponseEnvelope-->>User: display intent and source
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@potpie/context-engine/domain/agent_context_port.py`:
- Around line 187-281: Add a consistency assertion adjacent to _INTENT_KEYWORDS
and _INTENT_DETECTION_PRIORITY that compares their intent-key sets and fails
clearly when either structure contains an intent missing from the other. Keep
_INTENT_MATCHERS construction unchanged, and ensure the guard runs before it
accesses _INTENT_MATCHERS[intent].
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4eeee886-7b71-45a9-8b96-35e036a63d0e
📒 Files selected for processing (4)
potpie/context-engine/adapters/inbound/cli/commands/query.pypotpie/context-engine/domain/agent_context_port.pypotpie/context-engine/tests/unit/test_agent_context_port.pypotpie/context-engine/tests/unit/test_cli_resolve_intent.py
| """ | ||
| if not task or not task.strip(): | ||
| return None | ||
| for intent in _INTENT_DETECTION_PRIORITY: |
There was a problem hiding this comment.
Nice work! I noticed there's good coverage for representative mappings and the fallback behavior, but I couldn't find a regression test for a task matching multiple intents.
Since detect_context_intent() relies on _INTENT_DETECTION_PRIORITY to resolve ties, would it make sense to add a regression test for a multi-match phrase? That would help ensure the documented priority order remains stable over time.
There was a problem hiding this comment.
Good catch, added. It pins four multi-match phrases ( security > debugging > operations > review > feature), and each case also guards-asserts the lower-priority intents genuinely match the phrase, so a future keyword change can't silently reduce the test to a single-match.
There was a problem hiding this comment.
Thanks for adding it! I like the extra guard assertions—they make the priority behavior much clearer and help ensure the test stays meaningful over time.
Closes #996
Problem
potpie resolve "<task>"without--intentsilently hardcodesintent=featureand prints it as if it was detected. No detection ever runs, so debugging and recent-change tasks get the feature retrieval shape (notimelinefamily), and the output misleads users into thinking the intent was classified.What changed
detect_context_intent(task)indomain/agent_context_port.py: a deterministic, dependency-free keyword/phrase matcher (case-insensitive, word-boundary) seeded from the trigger language in each recipe's"when"field. Multi-match ties break via a documented priority order. ReturnsNonewhen nothing matches, favoring no guess over a wrong guess, mirroring theontology_classifierdiscipline.resolve:--intentdefault changed from"feature"toNone. Effective intent now resolves explicit → detected → default (unknown), following the(value, resolved_via)pattern fromresolve_pot_id/resolve_pot_scope.ResolveRequest.metadata→AgentEnvelope.metadatapassthrough asintent_source(explicit|detected|default). No downstream signature changes.intent_sourcekey, the human header showsintent=<x> (source=<...>).Vocabulary, recipes,
normalize_context_intent,DEFAULT_INTENT_INCLUDES, and the MCP/HTTP surfaces are untouched. Correct detection routes recent-change/debugging tasks to timeline-bearing includes automatically via the existing intent→includes mapping.Behavior
resolve "webhook throwing a 500 error"intent=featureintent=debugging (source=detected)resolve "what changed recently in auth?"intent=feature, zero timeline itemsintent=review (source=detected), timeline includedresolve "xyz"(no match)intent=featureintent=unknown (source=default)resolve "..." --intent docsintent=docsintent=docs (source=explicit)Testing
None, word-boundary anti-false-match ("latest" must not triggertest), CLI precedence, andintent_sourcein both output formats.ruff checkandruff formatclean (repo pre-commit config, v0.14.3).