feat(protocol): QuestionerAgent Slice 4 — intent, profile, negotiation presets#830
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the remaining QuestionerAgent presets (intent, profile, negotiation) and wires “fire-and-forget” enqueue hooks into the intent/profile/negotiation graphs via injected questionerEnqueue, so background question generation can be triggered when QUESTIONER_ENABLED is on.
Changes:
- Implemented
intent,profile, andnegotiationpresets (system prompts + context builders) and updated preset/unit tests accordingly. - Expanded the enqueue payload type to cover all modes and updated backend MCP composition to pass
questionerEnqueueinto the relevant protocol graphs. - Added protocol-graph attachment points to enqueue question generation after intent creation, after profile save when gaps exist, and after stalled/capped negotiations; updated docs and bumped protocol version.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/protocol/src/questioner/tests/questioner.presets.spec.ts | Adds coverage asserting the new presets exist and their prompt builders include key context fields. |
| packages/protocol/src/questioner/tests/questioner.agent.spec.ts | Replaces “unimplemented mode” test with parameterized coverage for all four modes. |
| packages/protocol/src/questioner/questioner.types.ts | Widens QuestionerEnqueuePayload to QuestionerInput for all modes. |
| packages/protocol/src/questioner/questioner.presets.ts | Implements intent/profile/negotiation presets and their buildPrompt helpers. |
| packages/protocol/src/profile/profile.graph.ts | Enqueues profile gap questions after saving profile (when gaps detected). |
| packages/protocol/src/negotiation/negotiation.graph.ts | Enqueues negotiation follow-up questions when negotiations stall/cap without acceptance. |
| packages/protocol/src/intent/intent.graph.ts | Enqueues intent follow-up questions after creating an intent. |
| backend/src/controllers/mcp.controller.ts | Injects questionerEnqueue into intent/profile/negotiation graph factories; removes unnecessary cast when enqueuing. |
| packages/protocol/package.json | Bumps @indexnetwork/protocol version to 1.10.0. |
| docs/design/protocol-deep-dive.md | Updates deep-dive to reflect implemented presets + new attachment points. |
| docs/superpowers/plans/2026-05-24-questioner-agent-slice4-presets.md | Removes the completed implementation plan document. |
Implements the fourth and final QuestionerAgent preset. The negotiation preset generates questions to help users unblock stalled or capped negotiations, using three strategies: refine_intent, surface_missing_detail, and reflective_summary. Removes the now-obsolete "throws for unimplemented mode" test since all four modes are implemented.
…undefined
When questionerEnqueue is undefined (QUESTIONER_ENABLED=false), the
optional-chain pattern `this.questionerEnqueue?.({...}).catch(...)` returns
undefined from the ?. operator, then calls .catch() on undefined — a
TypeError at runtime. Switch to explicit if-guards, matching the pattern
already used in negotiation.graph.ts. Also regenerate bun.lock to reflect
protocol 1.10.0.
…state Parse state.userProfile via the existing parseProfile() helper and map identity/attributes into IntentContext.userProfile instead of passing an empty object. Ensures the intent preset can reference known profile fields when generating clarifying questions.
fa1b68d to
ee2a0b0
Compare
…tions Explicit reject is a clear outcome, not a stall — generating "stalled negotiation" questions for it is misleading. Add `lastTurn?.action !== 'reject'` guard so only true stall scenarios (turn cap, timeout, implicit stall) trigger question generation.
Profile graph pushes "current work" but the preset test used "current project". Align the test to match the actual enqueue payload.
…ted) All four QuestionMode variants have preset implementations now, so Partial<Record<…>> is unnecessarily weak. Using Record<…> ensures a compile error if a new mode is added without a corresponding preset.
…errors When init or the first turn errors, state.lastTurn is undefined and turnCount is 0. The enqueue guard previously passed in this case, producing an empty keyTake and misclassified stallReason. Add turnCount > 0 so only negotiations with at least one completed turn trigger question generation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New Features
questionerEnqueuecallback injection (fire-and-forget, gated byQUESTIONER_ENABLED)Refactors
QuestionerEnqueuePayloadfrom discovery-only narrow interface toQuestionerInput(supports all modes)mcp.controller.tsquestionerEnqueue wrapperTests
it.eachtest covering all four QuestionerAgent modes (discovery, intent, profile, negotiation)Documentation
Test plan
cd packages/protocol && bun test src/questioner/— 21 tests passcd packages/protocol && npx tsc --noEmit— cleancd backend && npx tsc --noEmit— cleancd packages/protocol && bun test src/opportunity/tests/question.generator.spec.ts src/opportunity/tests/question.prompt.spec.ts— regression pass