Skip to content

feat(protocol): QuestionerAgent Slice 4 — intent, profile, negotiation presets#830

Merged
yanekyuk merged 12 commits into
devfrom
feat/questioner-presets
May 25, 2026
Merged

feat(protocol): QuestionerAgent Slice 4 — intent, profile, negotiation presets#830
yanekyuk merged 12 commits into
devfrom
feat/questioner-presets

Conversation

@yanekyuk
Copy link
Copy Markdown
Contributor

@yanekyuk yanekyuk commented May 25, 2026

New Features

  • Intent preset: generates clarifying questions after intent creation to refine vague signals or surface missing detail
  • Profile preset: generates gap-filling questions after profile save when location, skills, interests, or context are missing
  • Negotiation preset: generates reflective questions when negotiations stall (at capacity, timeout, or general stall)
  • Attachment points in intent, profile, and negotiation graphs via questionerEnqueue callback injection (fire-and-forget, gated by QUESTIONER_ENABLED)

Refactors

  • Widen QuestionerEnqueuePayload from discovery-only narrow interface to QuestionerInput (supports all modes)
  • Remove unnecessary type cast in mcp.controller.ts questionerEnqueue wrapper

Tests

  • Parameterized it.each test covering all four QuestionerAgent modes (discovery, intent, profile, negotiation)
  • Remove obsolete "throws for unimplemented mode" tests from agent and presets suites

Documentation

  • Update protocol-deep-dive.md §4.20 to reflect all four presets and graph attachment points

Test plan

  • cd packages/protocol && bun test src/questioner/ — 21 tests pass
  • cd packages/protocol && npx tsc --noEmit — clean
  • cd backend && npx tsc --noEmit — clean
  • cd packages/protocol && bun test src/opportunity/tests/question.generator.spec.ts src/opportunity/tests/question.prompt.spec.ts — regression pass

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and negotiation presets (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 questionerEnqueue into 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.

Comment thread packages/protocol/package.json
Comment thread packages/protocol/src/profile/profile.graph.ts
Comment thread packages/protocol/src/intent/intent.graph.ts Outdated
Comment thread docs/design/protocol-deep-dive.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Comment thread packages/protocol/src/intent/intent.graph.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Comment thread packages/protocol/src/negotiation/negotiation.graph.ts Outdated
Comment thread backend/src/controllers/mcp.controller.ts
Comment thread docs/superpowers/specs/2026-05-25-self-healing-connect-links-design.md Outdated
Comment thread docs/superpowers/plans/2026-05-25-self-healing-connect-links.md Outdated
yanekyuk added 8 commits May 25, 2026 05:17
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.
@yanekyuk yanekyuk force-pushed the feat/questioner-presets branch from fa1b68d to ee2a0b0 Compare May 25, 2026 02:18
…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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Comment thread packages/protocol/src/questioner/questioner.types.ts
Comment thread packages/protocol/src/questioner/tests/questioner.presets.spec.ts Outdated
Profile graph pushes "current work" but the preset test used "current
project". Align the test to match the actual enqueue payload.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Comment thread packages/protocol/src/questioner/questioner.presets.ts Outdated
…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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Comment thread packages/protocol/src/negotiation/negotiation.graph.ts Outdated
…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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.

@yanekyuk yanekyuk merged commit 88701f5 into dev May 25, 2026
4 checks passed
@yanekyuk yanekyuk deleted the feat/questioner-presets branch May 25, 2026 03:04
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.

2 participants